General updates

This commit is contained in:
2024-04-09 18:07:51 -04:00
parent f794f215dc
commit 97569dca2a
5 changed files with 52 additions and 14 deletions

View File

@@ -5227,6 +5227,7 @@ namespace MarketData.Helper
}
return prices;
}
public static Price GetPriceAsOf(String symbol, DateTime asOf)
{
HttpNetResponse httpNetResponse=null;
@@ -5293,12 +5294,6 @@ 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 *********************************************************************
//********************************************************************************************************************************************************************************************************
// *********************************************************************************************************************************************************
// *********************************************************************************************************************************************************
// ********************************************************************************************************************************************************************************************************************
// ******************************************************************************************************** N E W V E R S I O N *************************************************************************************
// ********************************************************************************************************************************************************************************************************************
// Implemented 06/10/2022
public static Price GetDailyPrice(String symbol,DateTime pricingDate)
@@ -5319,12 +5314,15 @@ namespace MarketData.Helper
HttpNetResponse httpNetResponse=null;
try
{
startDate=startDate.Date;
endDate=endDate.Date;
if(startDate>endDate)
{
DateTime tempDate=startDate;
startDate=endDate;
endDate=tempDate;
}
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[MarketDataHelper:GetDailyPrices]{0} start:{1} end:{2}",symbol,Utility.DateTimeToStringMMHDDHYYYY(startDate),Utility.DateTimeToStringMMHDDHYYYY(endDate)));
StringBuilder sb = new StringBuilder();
String strRequest;

View File

@@ -6,6 +6,7 @@ using System.Threading;
using MarketData.MarketDataModel;
using MarketData.DataAccess;
using MarketData.Utils;
using System.Net;
namespace MarketData.Helper
{
@@ -49,7 +50,8 @@ namespace MarketData.Helper
}
public class PricingMarketDataHelper
{
private static int MaxThreads = (int)ThreadHelperEnum.MaxThreads;
private static int MaxThreads = 20; // (int)ThreadHelperEnum.MaxThreads;
private static int WaitBetweenRequests=300;
private List<String> symbols;
private int currentIndex = 0;
@@ -97,7 +99,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index],resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdateLatestPriceAll, pricingThreadHelper);
try{Thread.Sleep(250);}catch(Exception){;}
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdateLatestPriceAll, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -131,6 +133,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index],startDate.Value,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesBigCharts, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesBigCharts, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -164,6 +167,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper=new PricingThreadHelper(queueSymbols[index],startDate.Value,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesYahoo,pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesYahoo, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -197,6 +201,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper=new PricingThreadHelper(queueSymbols[index],startDate.Value,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesYahooSweep,pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesYahooSweep, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -229,6 +234,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], resetEvents[index],asOf);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesAsOf, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesAsOfSymbol, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -261,6 +267,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper=new PricingThreadHelper(queueSymbols[index],asOf,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesYahoo,pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesAsOfSymbol, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -292,6 +299,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], resetEvents[index],asOf);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdatePricesAsOf, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"UpdatePricesAsOf, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -325,6 +333,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], resetEvents[index],startDate);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackGetMissingPrice, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"Get missing prices, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -356,6 +365,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], resetEvents[index],startDate);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackGetMissingPrice, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"Get missing prices, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -394,7 +404,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], pricingDate,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackUpdateLatestPrice, pricingThreadHelper);
try{Thread.Sleep(250);}catch(Exception){;}
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"Load prices, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);
@@ -427,6 +437,7 @@ namespace MarketData.Helper
{
PricingThreadHelper pricingThreadHelper = new PricingThreadHelper(queueSymbols[index], pricingDate,resetEvents[index]);
ThreadPool.QueueUserWorkItem(ThreadPoolCallbackLoadPrices, pricingThreadHelper);
try{Thread.Sleep(WaitBetweenRequests);}catch(Exception){;}
}
MDTrace.WriteLine(LogLevel.DEBUG,"Load prices, waiting for queued items to complete.");
WaitHandle.WaitAll(resetEvents);