diff --git a/MarketData/MarketData/Services/MainService.cs b/MarketData/MarketData/Services/MainService.cs
index d2f12b0..87be6e8 100755
--- a/MarketData/MarketData/Services/MainService.cs
+++ b/MarketData/MarketData/Services/MainService.cs
@@ -41,6 +41,8 @@ namespace MarketData.Services
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFINANCIALSTATEMENTS");
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEFUNDAMENTALS");
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,"MGSHSESSION /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("OPTIMIZEDB",TaskOptimizeDatabase);
tasks.Add("UPDATEPRICESBARCHARTSWEEP", TaskUpdatePricesBarChartSweep);
+ tasks.Add("LOADALLPRICESSYMBOL", TaskLoadAllPricesSymbol);
+ tasks.Add("LOADPRICESYMBOLDATE",TaskLoadPriceSymbolDate);
tasks.Add("ECHO",TaskEcho);
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);
}
-
public async Task TaskUpdateFundamentals(CommandArgs commandArgs)
{
UpdateFundamentalsFinViz();
@@ -464,6 +467,102 @@ namespace MarketData.Services
await Task.FromResult(true);
}
+ ///
+ /// TaskLoadAllPricesSymbol - Load price from Yahoo for SYMBOL
+ ///
+ ///
+ ///
+ 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("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;
+ }
+
+ ///
+ /// TaskLoadAllPricesSymbolDate - Load price from Yahoo for SYMBOL and DATE
+ ///
+ ///
+ ///
+ 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("SYMBOL").Trim().ToUpper();
+ DateTime startDate = commandArgs.Coalesce("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 ********************************************************************
// *********************************************************************************************************************************************************
diff --git a/MarketData/MarketDataLib/Helper/MarketDataHelper.cs b/MarketData/MarketDataLib/Helper/MarketDataHelper.cs
index 8cbf223..c5024ea 100755
--- a/MarketData/MarketDataLib/Helper/MarketDataHelper.cs
+++ b/MarketData/MarketDataLib/Helper/MarketDataHelper.cs
@@ -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 *********************************************************************
//********************************************************************************************************************************************************************************************************
-
+ ///
+ /// GetDailyPrice - This feed returns a single price for the given pricing date.
+ ///
+ ///
+ ///
+ ///
public static Price GetDailyPrice(String symbol, DateTime pricingDate)
{
if (null == symbol) return null;
@@ -5396,6 +5401,13 @@ namespace MarketData.Helper
return price;
}
+ ///
+ /// GetDailyPrices - Retrieve prices from Yahoo. This feed can retrieve historical prices from Yahoo as well as current day price
+ ///
+ ///
+ ///
+ ///
+ ///
public static Prices GetDailyPrices(String symbol, DateTime startDate, DateTime endDate)
{
HttpNetResponse httpNetResponse=null;
diff --git a/MarketDataUnitTests/MarketDataUnitTestClass.cs b/MarketDataUnitTests/MarketDataUnitTestClass.cs
index c4846cd..32956f1 100644
--- a/MarketDataUnitTests/MarketDataUnitTestClass.cs
+++ b/MarketDataUnitTests/MarketDataUnitTestClass.cs
@@ -130,6 +130,9 @@ public class MarketDataUnitTestClass
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
}
+ ///
+ /// DailyPricesYahoo - This test confirms if we are able to retrieve a current (last business day) price from Yahoo.
+ ///
[TestMethod]
public void DailyPricesYahoo()
{
@@ -146,26 +149,29 @@ public class MarketDataUnitTestClass
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
}
- // [TestMethod]
- // public void CNNPredictionTest()
- // {
- // String cnnHostName = "10.0.0.240";
- // CMCandidate cmCandidate = new CMCandidate();
- // CMParams cmParams = new CMParams();
+ ///
+ /// HistoricalPricesYahoo - This test confirms if we are able to retrieve historical dates from Yahoo
+ ///
+ [TestMethod]
+ public void HistoricalPricesYahoo()
+ {
+ String symbol = "AAPL";
+ DateGenerator dateGenerator = new DateGenerator();
+ DateTime lastBusinessDate = DateTime.Now;
+ DateTime historicalDate = Utility.Epoch;
- // cmParams.UseCNN = true;
- // cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
- // cmParams.UseCNNDayCount = 270;
- // cmParams.UseCNNRewardPercentDecimal = 0.25;
+ lastBusinessDate = dateGenerator.GetPrevBusinessDay(lastBusinessDate);
+ List historicalDates = dateGenerator.GenerateHistoricalDates(lastBusinessDate,30);
+ DateTime minDate = historicalDates.Min();
- // cmCandidate.Symbol = "MIDD";
- // cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
-
- // bool result = CMMomentumGenerator.PredictCandidate(cmCandidate, cmParams);
-
- // Assert.IsTrue(result);
- // }
+ Prices prices = MarketDataHelper.GetDailyPrices(symbol, lastBusinessDate, minDate);
+ Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
+ Assert.IsTrue(prices.Count>1, "No Historical Prices from DailyPricesYahoo");
+ }
+ ///
+ /// CNNPredictionTest - This runs the Prediction using the CMMMomentumGenerator
+ ///
[TestMethod]
public void CNNPredictionTest()
{