Add pricing fetches. Add unit test.
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -41,6 +41,8 @@ namespace MarketData.Services
|
|||||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFINANCIALSTATEMENTS");
|
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFINANCIALSTATEMENTS");
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFUNDAMENTALS");
|
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFUNDAMENTALS");
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEHISTORICAL");
|
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEHISTORICAL");
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOL /SYMBOL: Loads all available prices from Yahoo for symbol ");
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADPRICESYMBOLDATE /SYMBOL: /DATE: {optional} - reloads all prices from Yahoo for specified SYMBOL for DATE");
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,"CALCSTICKER /WAITFORCOMPLETION:{argument1,argument2,...} For example CALCSTICKER /WAITFORCOMPLETION:UPDATEFINANCIALSTATEMENTS,UPDATEFUNDAMENTALS,UPDATEHISTORICAL");
|
MDTrace.WriteLine(LogLevel.DEBUG,"CALCSTICKER /WAITFORCOMPLETION:{argument1,argument2,...} For example CALCSTICKER /WAITFORCOMPLETION:UPDATEFINANCIALSTATEMENTS,UPDATEFUNDAMENTALS,UPDATEHISTORICAL");
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,"MGSHSESSION /SESSIONFILE:");
|
MDTrace.WriteLine(LogLevel.DEBUG,"MGSHSESSION /SESSIONFILE:");
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,"MGSHRUNBACKTEST /USEHEDGING: /HEDGEINITIALCASH: /USESTOPLIMITS: /KEEPSLOTPOSITIONS: /STARTDATE: /MAXPOSITIONS: /INITIALCASH: /HOLDINGPERIOD: /{ENDDATE}: /SESSIONFILE: ");
|
MDTrace.WriteLine(LogLevel.DEBUG,"MGSHRUNBACKTEST /USEHEDGING: /HEDGEINITIALCASH: /USESTOPLIMITS: /KEEPSLOTPOSITIONS: /STARTDATE: /MAXPOSITIONS: /INITIALCASH: /HOLDINGPERIOD: /{ENDDATE}: /SESSIONFILE: ");
|
||||||
@@ -101,6 +103,8 @@ namespace MarketData.Services
|
|||||||
tasks.Add("CALCBETAS",TaskCalcBetas);
|
tasks.Add("CALCBETAS",TaskCalcBetas);
|
||||||
tasks.Add("OPTIMIZEDB",TaskOptimizeDatabase);
|
tasks.Add("OPTIMIZEDB",TaskOptimizeDatabase);
|
||||||
tasks.Add("UPDATEPRICESBARCHARTSWEEP", TaskUpdatePricesBarChartSweep);
|
tasks.Add("UPDATEPRICESBARCHARTSWEEP", TaskUpdatePricesBarChartSweep);
|
||||||
|
tasks.Add("LOADALLPRICESSYMBOL", TaskLoadAllPricesSymbol);
|
||||||
|
tasks.Add("LOADPRICESYMBOLDATE",TaskLoadPriceSymbolDate);
|
||||||
tasks.Add("ECHO",TaskEcho);
|
tasks.Add("ECHO",TaskEcho);
|
||||||
GlobalConfig.Instance.Configuration = configuration; // This call sets up configuration stuff so it needs to be first.
|
GlobalConfig.Instance.Configuration = configuration; // This call sets up configuration stuff so it needs to be first.
|
||||||
|
|
||||||
@@ -189,7 +193,6 @@ namespace MarketData.Services
|
|||||||
await Task.FromResult(true);
|
await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task TaskUpdateFundamentals(CommandArgs commandArgs)
|
public async Task TaskUpdateFundamentals(CommandArgs commandArgs)
|
||||||
{
|
{
|
||||||
UpdateFundamentalsFinViz();
|
UpdateFundamentalsFinViz();
|
||||||
@@ -464,6 +467,102 @@ namespace MarketData.Services
|
|||||||
await Task.FromResult(true);
|
await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TaskLoadAllPricesSymbol - Load price from Yahoo for SYMBOL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="commandArgs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TaskLoadAllPricesSymbol(CommandArgs commandArgs)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,String.Format("Loading/Deleting prices can change the pricing of positions... please confirm Y/N:?"));
|
||||||
|
String result=Console.ReadLine();
|
||||||
|
if(null==result || !(result.ToUpper().Equals("Y") || result.ToUpper().Equals("YES")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!commandArgs.Has("SYMBOL"))
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOL REQUIRES SYMBOL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String symbol = commandArgs.Coalesce<String>("SYMBOL").Trim().ToUpper();
|
||||||
|
if(String.IsNullOrEmpty(symbol))
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOLDATE Invalid arguments, please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DateTime startDate =Constants.MIN_PRICING_DATE;
|
||||||
|
DateTime endDate = DateTime.Now;
|
||||||
|
Prices prices=MarketDataHelper.GetDailyPrices(symbol,startDate,endDate); // use the Yahoo JSON bulk feed
|
||||||
|
if(null==prices||0==prices.Count)
|
||||||
|
{
|
||||||
|
if(!Utility.GetVerificationToProceed(String.Format("No prices from Yahoo for symbol{0}. Would you like to try BigCharts?",symbol)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null == prices || 0==prices.Count)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"No prices for '" + symbol + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int secIndex = 0; secIndex < prices.Count; secIndex++)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,prices[secIndex].ToString());
|
||||||
|
}
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"Inserting....");
|
||||||
|
PricingDA.InsertPrices(prices);
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"Done.");
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TaskLoadAllPricesSymbolDate - Load price from Yahoo for SYMBOL and DATE
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="commandArgs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TaskLoadPriceSymbolDate(CommandArgs commandArgs)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,String.Format("Loading/Deleting prices can change the pricing of positions... please confirm Y/N:?"));
|
||||||
|
String result=Console.ReadLine();
|
||||||
|
if(null==result || !(result.ToUpper().Equals("Y") || result.ToUpper().Equals("YES")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!commandArgs.Has("SYMBOL"))
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOLDATE REQUIRES SYMBOL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!commandArgs.Has("DATE"))
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOLDATE REQUIRES DATE");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String symbol = commandArgs.Coalesce<String>("SYMBOL").Trim().ToUpper();
|
||||||
|
DateTime startDate = commandArgs.Coalesce<DateTime>("DATE");
|
||||||
|
if(String.IsNullOrEmpty(symbol) || Utility.IsEpoch(startDate))
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"LOADALLPRICESSYMBOLDATE Invalid arguments, please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Prices prices=MarketDataHelper.GetDailyPrices(symbol,startDate,startDate); // use the Yahoo JSON bulk feed
|
||||||
|
if (null == prices || 0==prices.Count)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"No prices for '" + symbol + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int secIndex = 0; secIndex < prices.Count; secIndex++)
|
||||||
|
{
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,prices[secIndex].ToString());
|
||||||
|
}
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"Inserting....");
|
||||||
|
PricingDA.InsertPrices(prices);
|
||||||
|
MDTrace.WriteLine(LogLevel.DEBUG,"Done.");
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
// *********************************************************************************************************************************************************
|
// *********************************************************************************************************************************************************
|
||||||
// ******************************************************************* E N D T A S K S ********************************************************************
|
// ******************************************************************* E N D T A S K S ********************************************************************
|
||||||
// *********************************************************************************************************************************************************
|
// *********************************************************************************************************************************************************
|
||||||
|
|||||||
@@ -5375,7 +5375,12 @@ 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 *********************************************************************
|
||||||
//********************************************************************************************************************************************************************************************************
|
//********************************************************************************************************************************************************************************************************
|
||||||
|
/// <summary>
|
||||||
|
/// GetDailyPrice - This feed returns a single price for the given pricing date.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="symbol"></param>
|
||||||
|
/// <param name="pricingDate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Price GetDailyPrice(String symbol, DateTime pricingDate)
|
public static Price GetDailyPrice(String symbol, DateTime pricingDate)
|
||||||
{
|
{
|
||||||
if (null == symbol) return null;
|
if (null == symbol) return null;
|
||||||
@@ -5396,6 +5401,13 @@ namespace MarketData.Helper
|
|||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetDailyPrices - Retrieve prices from Yahoo. This feed can retrieve historical prices from Yahoo as well as current day price
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="symbol"></param>
|
||||||
|
/// <param name="startDate"></param>
|
||||||
|
/// <param name="endDate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Prices GetDailyPrices(String symbol, DateTime startDate, DateTime endDate)
|
public static Prices GetDailyPrices(String symbol, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
HttpNetResponse httpNetResponse=null;
|
HttpNetResponse httpNetResponse=null;
|
||||||
|
|||||||
@@ -130,6 +130,9 @@ public class MarketDataUnitTestClass
|
|||||||
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DailyPricesYahoo - This test confirms if we are able to retrieve a current (last business day) price from Yahoo.
|
||||||
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void DailyPricesYahoo()
|
public void DailyPricesYahoo()
|
||||||
{
|
{
|
||||||
@@ -146,26 +149,29 @@ public class MarketDataUnitTestClass
|
|||||||
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
|
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
|
||||||
}
|
}
|
||||||
|
|
||||||
// [TestMethod]
|
/// <summary>
|
||||||
// public void CNNPredictionTest()
|
/// HistoricalPricesYahoo - This test confirms if we are able to retrieve historical dates from Yahoo
|
||||||
// {
|
/// </summary>
|
||||||
// String cnnHostName = "10.0.0.240";
|
[TestMethod]
|
||||||
// CMCandidate cmCandidate = new CMCandidate();
|
public void HistoricalPricesYahoo()
|
||||||
// CMParams cmParams = new CMParams();
|
{
|
||||||
|
String symbol = "AAPL";
|
||||||
|
DateGenerator dateGenerator = new DateGenerator();
|
||||||
|
DateTime lastBusinessDate = DateTime.Now;
|
||||||
|
DateTime historicalDate = Utility.Epoch;
|
||||||
|
|
||||||
// cmParams.UseCNN = true;
|
lastBusinessDate = dateGenerator.GetPrevBusinessDay(lastBusinessDate);
|
||||||
// cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
List<DateTime> historicalDates = dateGenerator.GenerateHistoricalDates(lastBusinessDate,30);
|
||||||
// cmParams.UseCNNDayCount = 270;
|
DateTime minDate = historicalDates.Min();
|
||||||
// cmParams.UseCNNRewardPercentDecimal = 0.25;
|
|
||||||
|
|
||||||
// cmCandidate.Symbol = "MIDD";
|
Prices prices = MarketDataHelper.GetDailyPrices(symbol, lastBusinessDate, minDate);
|
||||||
// cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
|
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
|
||||||
|
Assert.IsTrue(prices.Count>1, "No Historical Prices from DailyPricesYahoo");
|
||||||
// bool result = CMMomentumGenerator.PredictCandidate(cmCandidate, cmParams);
|
}
|
||||||
|
|
||||||
// Assert.IsTrue(result);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CNNPredictionTest - This runs the Prediction using the CMMMomentumGenerator
|
||||||
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CNNPredictionTest()
|
public void CNNPredictionTest()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user