Add FreezePricing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -4380,8 +4380,6 @@ namespace MarketData.Helper
|
||||
memoryStream = new MemoryStream(streamBytes);
|
||||
HtmlDocument htmlDocument = new HtmlDocument();
|
||||
htmlDocument.Load(memoryStream);
|
||||
// HtmlNodeCollection nodeCollection = htmlDocument.DocumentNode.SelectNodes("//*[@class=\"snapshot-table2\"]");
|
||||
// HtmlNodeCollection nodeCollection = htmlDocument.DocumentNode.SelectNodes("//*[@class=\"snapshot-table2 screener_snapshot-table-body\"]");
|
||||
HtmlNodeCollection nodeCollection = htmlDocument.DocumentNode.SelectNodes("//*[@class=\"js-snapshot-table snapshot-table2 screener_snapshot-table-body\"]");
|
||||
if(null==nodeCollection || nodeCollection.Count<1)return null;
|
||||
fundamental.AsOf=DateTime.Now;
|
||||
@@ -4790,6 +4788,13 @@ namespace MarketData.Helper
|
||||
private delegate Price LatestPriceDelegate(String symbol);
|
||||
public static Price GetLatestPrice(String symbol)
|
||||
{
|
||||
if(null==symbol)return null;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
if(null!=companyProfile && companyProfile.FreezePricing)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Pricing for {0} is frozen.",symbol));
|
||||
return null;
|
||||
}
|
||||
DateTime currentMarketDate=PremarketDA.GetLatestMarketDate();
|
||||
LatestPriceDelegate[] latestPriceDelegates=new LatestPriceDelegate[]{GetLatestPriceYahoo,GetLatestPriceBigCharts,GetLatestPriceGoogle};
|
||||
Price latestPrice=null;
|
||||
@@ -4811,7 +4816,7 @@ namespace MarketData.Helper
|
||||
}
|
||||
latestPrice=GetPriceAsOf(symbol,currentMarketDate); // try to get the price from MarketWatch historical feed using todays date
|
||||
if(null!=latestPrice && latestPrice.Date.Date.Equals(currentMarketDate.Date)) return latestPrice;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
|
||||
if(null!=companyProfile && companyProfile.CanRollPrevious)
|
||||
{
|
||||
latestPrice=PricingMarketDataHelper.RollPriceForward(symbol);
|
||||
@@ -4824,7 +4829,6 @@ namespace MarketData.Helper
|
||||
// ******************** L A T E S T P R I C E R E T R I E V A L F O R I N T R A - D A Y F E E D ********
|
||||
// ***************************************************************************************************************
|
||||
|
||||
|
||||
public static Price GetLatestPriceYahoo(String symbol)
|
||||
{
|
||||
HttpNetResponse httpNetResponse=null;
|
||||
@@ -5297,6 +5301,14 @@ namespace MarketData.Helper
|
||||
public static Prices GetPricesAsOf(String symbol, DateTime startDate,DateTime endDate)
|
||||
{
|
||||
Prices prices=new Prices();
|
||||
|
||||
if(null==symbol)return null;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
if(null!=companyProfile && companyProfile.FreezePricing)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Pricing for {0} is frozen.",symbol));
|
||||
return null;
|
||||
}
|
||||
DateGenerator dateGenerator=new DateGenerator();
|
||||
List<DateTime> dates=dateGenerator.GenerateHistoricalDates(startDate,endDate);
|
||||
for(int index=0;index<dates.Count;index++)
|
||||
@@ -5318,6 +5330,12 @@ namespace MarketData.Helper
|
||||
StringBuilder sb = null;
|
||||
|
||||
if (null == symbol) return null;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
if(null!=companyProfile && companyProfile.FreezePricing)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Pricing for {0} is frozen.",symbol));
|
||||
return null;
|
||||
}
|
||||
String requestSymbol=symbol;
|
||||
if(requestSymbol.StartsWith("^"))requestSymbol=requestSymbol.Substring(1);
|
||||
sb = new StringBuilder();
|
||||
@@ -5375,10 +5393,16 @@ namespace MarketData.Helper
|
||||
//********************************************************************************************************************************************************************************************************
|
||||
// ******************************************************************************** H I S T O R I C A L P R I C I N G Y A H O O *********************************************************************
|
||||
//********************************************************************************************************************************************************************************************************
|
||||
// Implemented 06/10/2022
|
||||
|
||||
public static Price GetDailyPrice(String symbol,DateTime pricingDate)
|
||||
{
|
||||
if(null==symbol)return null;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
if(null!=companyProfile && companyProfile.FreezePricing)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Pricing for {0} is frozen.",symbol));
|
||||
return null;
|
||||
}
|
||||
Prices prices=GetDailyPrices(symbol,pricingDate,pricingDate);
|
||||
if(null==prices||0==prices.Count)return null;
|
||||
Price price=prices.FirstOrDefault();
|
||||
@@ -5395,6 +5419,13 @@ namespace MarketData.Helper
|
||||
HttpNetResponse httpNetResponse=null;
|
||||
try
|
||||
{
|
||||
if(symbol==null)return null;
|
||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
||||
if(null!=companyProfile && companyProfile.FreezePricing)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Pricing for {0} is frozen.",symbol));
|
||||
return null;
|
||||
}
|
||||
startDate=startDate.Date;
|
||||
endDate=endDate.Date;
|
||||
if(startDate>endDate)
|
||||
|
||||
Reference in New Issue
Block a user