Add FreezePricing
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -4380,8 +4380,6 @@ namespace MarketData.Helper
|
|||||||
memoryStream = new MemoryStream(streamBytes);
|
memoryStream = new MemoryStream(streamBytes);
|
||||||
HtmlDocument htmlDocument = new HtmlDocument();
|
HtmlDocument htmlDocument = new HtmlDocument();
|
||||||
htmlDocument.Load(memoryStream);
|
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\"]");
|
HtmlNodeCollection nodeCollection = htmlDocument.DocumentNode.SelectNodes("//*[@class=\"js-snapshot-table snapshot-table2 screener_snapshot-table-body\"]");
|
||||||
if(null==nodeCollection || nodeCollection.Count<1)return null;
|
if(null==nodeCollection || nodeCollection.Count<1)return null;
|
||||||
fundamental.AsOf=DateTime.Now;
|
fundamental.AsOf=DateTime.Now;
|
||||||
@@ -4790,6 +4788,13 @@ namespace MarketData.Helper
|
|||||||
private delegate Price LatestPriceDelegate(String symbol);
|
private delegate Price LatestPriceDelegate(String symbol);
|
||||||
public static Price GetLatestPrice(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();
|
DateTime currentMarketDate=PremarketDA.GetLatestMarketDate();
|
||||||
LatestPriceDelegate[] latestPriceDelegates=new LatestPriceDelegate[]{GetLatestPriceYahoo,GetLatestPriceBigCharts,GetLatestPriceGoogle};
|
LatestPriceDelegate[] latestPriceDelegates=new LatestPriceDelegate[]{GetLatestPriceYahoo,GetLatestPriceBigCharts,GetLatestPriceGoogle};
|
||||||
Price latestPrice=null;
|
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
|
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;
|
if(null!=latestPrice && latestPrice.Date.Date.Equals(currentMarketDate.Date)) return latestPrice;
|
||||||
CompanyProfile companyProfile=CompanyProfileDA.GetCompanyProfile(symbol);
|
|
||||||
if(null!=companyProfile && companyProfile.CanRollPrevious)
|
if(null!=companyProfile && companyProfile.CanRollPrevious)
|
||||||
{
|
{
|
||||||
latestPrice=PricingMarketDataHelper.RollPriceForward(symbol);
|
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 ********
|
// ******************** 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)
|
public static Price GetLatestPriceYahoo(String symbol)
|
||||||
{
|
{
|
||||||
HttpNetResponse httpNetResponse=null;
|
HttpNetResponse httpNetResponse=null;
|
||||||
@@ -5297,6 +5301,14 @@ namespace MarketData.Helper
|
|||||||
public static Prices GetPricesAsOf(String symbol, DateTime startDate,DateTime endDate)
|
public static Prices GetPricesAsOf(String symbol, DateTime startDate,DateTime endDate)
|
||||||
{
|
{
|
||||||
Prices prices=new Prices();
|
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();
|
DateGenerator dateGenerator=new DateGenerator();
|
||||||
List<DateTime> dates=dateGenerator.GenerateHistoricalDates(startDate,endDate);
|
List<DateTime> dates=dateGenerator.GenerateHistoricalDates(startDate,endDate);
|
||||||
for(int index=0;index<dates.Count;index++)
|
for(int index=0;index<dates.Count;index++)
|
||||||
@@ -5318,6 +5330,12 @@ namespace MarketData.Helper
|
|||||||
StringBuilder sb = null;
|
StringBuilder sb = null;
|
||||||
|
|
||||||
if (null == symbol) return 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;
|
String requestSymbol=symbol;
|
||||||
if(requestSymbol.StartsWith("^"))requestSymbol=requestSymbol.Substring(1);
|
if(requestSymbol.StartsWith("^"))requestSymbol=requestSymbol.Substring(1);
|
||||||
sb = new StringBuilder();
|
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 *********************************************************************
|
// ******************************************************************************** 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)
|
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);
|
Prices prices=GetDailyPrices(symbol,pricingDate,pricingDate);
|
||||||
if(null==prices||0==prices.Count)return null;
|
if(null==prices||0==prices.Count)return null;
|
||||||
Price price=prices.FirstOrDefault();
|
Price price=prices.FirstOrDefault();
|
||||||
@@ -5395,6 +5419,13 @@ namespace MarketData.Helper
|
|||||||
HttpNetResponse httpNetResponse=null;
|
HttpNetResponse httpNetResponse=null;
|
||||||
try
|
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;
|
startDate=startDate.Date;
|
||||||
endDate=endDate.Date;
|
endDate=endDate.Date;
|
||||||
if(startDate>endDate)
|
if(startDate>endDate)
|
||||||
|
|||||||
Reference in New Issue
Block a user