Add BarChart

This commit is contained in:
2025-06-30 13:17:13 -04:00
parent 99fa821f79
commit 332ed89e5a
3 changed files with 125 additions and 48 deletions

View File

@@ -105,8 +105,13 @@ namespace MarketData.Generator.MGSHMomentum
MGSHPosition position = activePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault();
if (null == position)
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Cannot locate position for symbol '{0}' purchased on {1}.", symbol, purchaseDate.ToShortDateString()));
return false;
MGSHPositions hedgePositions = HedgePositions;
position = hedgePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault();
if(null == position)
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Cannot locate position for symbol '{0}' purchased on {1}.", symbol, purchaseDate.ToShortDateString()));
return false;
}
}
if (!position.PurchaseDate.Equals(purchaseDate)) position.PurchaseDate = purchaseDate;
if (!position.TrailingStopLimit.Equals(trailingStop)) position.TrailingStopLimit = trailingStop;

View File

@@ -316,7 +316,7 @@ namespace MarketData.MarketDataModel
// ***************************************************************************************************************************************************************************
public class Price
{
public enum PriceSource{Other=0,BigCharts=1,Yahoo=2,Fidelity=3,Google=4};
public enum PriceSource{Other=0,BigCharts=1,Yahoo=2,Fidelity=3,Google=4,BarChart=5};
private String symbol;
private DateTime date;
private double open;
@@ -377,6 +377,8 @@ namespace MarketData.MarketDataModel
return "Fidelity";
case PriceSource.Google :
return "Google";
case PriceSource.BarChart :
return "BarChart";
default :
return Constants.CONST_QUESTION;
}

View File

@@ -79,9 +79,9 @@ namespace MarketData
MDTrace.WriteLine(LogLevel.DEBUG," UPDATEPRICESDATE /DATE: - fetched prices for this date");
MDTrace.WriteLine(LogLevel.DEBUG," UPDATEPRICESSYMBOL /SYMBOL: - brings prices current for specified symbol");
MDTrace.WriteLine(LogLevel.DEBUG," LOADALLPRICESSYMBOL /SYMBOL: - reloads all prices for specified symbol from 01-01-2009");
MDTrace.WriteLine(LogLevel.DEBUG," SHOWALLPRICESSYMBOL /SYMBOL: - shows all prices for specified symbol from 01-01-2009");
MDTrace.WriteLine(LogLevel.DEBUG," LOADALLPRICESSYMBOLDATE /SYMBOL: /DATE:{optional} - reloads all prices for specified symbol from DATE");
MDTrace.WriteLine(LogLevel.DEBUG," LOADALLPRICESWATCHLIST /WATCHLIST: - reloads all prices for watchlist from 01-01-2009");
MDTrace.WriteLine(LogLevel.DEBUG," SHOWALLPRICESSYMBOL /SYMBOL: - shows all prices for specified symbol from 01-01-2009");
MDTrace.WriteLine(LogLevel.DEBUG," ADDPRICE /SYMBOL: /DATE: /TYPE:[OPEN][HIGH][LOW][CLOSE][VOLUME] - updates symbol with price for specified date");
MDTrace.WriteLine(LogLevel.DEBUG," UPDATELATESTPRICEWATCHLIST /WATCHLIST- updates database with latest price for the symbols in the watchlist");
MDTrace.WriteLine(LogLevel.DEBUG," UPDATELATESTPRICEOPENPOSITIONS - updates database with latest price for the symbols in open positions");
@@ -1230,9 +1230,14 @@ namespace MarketData
}
else if (arg.Equals("DELETEPRICEWATCHLIST"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("WATCHLIST,DATE")){Console.WriteLine("DELETEPRICEWATCHLIST REQUIRES WATCHLIST,DATE");return 0;}
Program.DeletePriceWatchList(commandArgs.Coalesce<String>("WATCHLIST"),commandArgs.Coalesce<String>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("WATCHLIST,DATE")){Console.WriteLine("DELETEPRICEWATCHLIST REQUIRES WATCHLIST,DATE");return 0;}
Program.DeletePriceWatchList(commandArgs.Coalesce<String>("WATCHLIST"),commandArgs.Coalesce<String>("DATE"));
}
}
else if (arg.Equals("FINDALLSYMBOLSMISSINGPRICEON"))
{
@@ -1247,73 +1252,145 @@ namespace MarketData
//MDTrace.WriteLine(LogLevel.DEBUG," ROLLPRICEFORWARD /SYMBOL: /FROMDATE: /TODATE: Roll price forward from the given date to the specified date.");
else if(arg.Equals("ROLLPRICEFORWARD"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,FROMDATE,TODATE")){Console.WriteLine("ROLLPRICEFORWARD REQUIRES SYMBOL,FROMDATE,TODATE");return 0;}
Program.RollPriceForward(commandArgs.Get<String>("SYMBOL"),commandArgs.Get<DateTime>("FROMDATE"),commandArgs.Get<DateTime>("TODATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,FROMDATE,TODATE")){Console.WriteLine("ROLLPRICEFORWARD REQUIRES SYMBOL,FROMDATE,TODATE");return 0;}
Program.RollPriceForward(commandArgs.Get<String>("SYMBOL"),commandArgs.Get<DateTime>("FROMDATE"),commandArgs.Get<DateTime>("TODATE"));
}
}
else if (arg.Equals("UPDATEPRICESASOF"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEPRICESASOF REQUIRES DATE");return 0;}
Program.UpdatePricesAsOf(commandArgs.Coalesce<DateTime>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEPRICESASOF REQUIRES DATE");return 0;}
Program.UpdatePricesAsOf(commandArgs.Coalesce<DateTime>("DATE"));
}
}
else if (arg.Equals("UPDATEPRICEASOFSYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,DATE")){Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL,DATE");return 0;}
Program.UpdatePricesAsOfSymbol(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,DATE")){Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL,DATE");return 0;}
Program.UpdatePricesAsOfSymbol(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
}
}
else if(arg.Equals("UPDATEPRICEASOFSYMBOLYAHOO"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,DATE")) { Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL,DATE"); return 0; }
Program.UpdatePricesAsOfSymbolYahoo(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL,DATE")) { Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL,DATE"); return 0; }
Program.UpdatePricesAsOfSymbolYahoo(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
}
}
else if (arg.Equals("UPDATELATESTPRICESYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL");return 0;}
Program.UpdateLatestPriceSymbol(commandArgs.Coalesce<String>("SYMBOL").ToUpper());
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("UPDATEPRICEASOFSYMBOL REQUIRES SYMBOL");return 0;}
Program.UpdateLatestPriceSymbol(commandArgs.Coalesce<String>("SYMBOL").ToUpper());
}
}
else if (arg.Equals("UPDATELATESTPRICESALL"))
{
Program.UpdateLatestPriceAll();
Console.WriteLine(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")))
{
Program.UpdateLatestPriceAll();
}
}
else if (arg.Equals("DELETELATESTPRICESYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("DELETELATESTPRICESYMBOL REQUIRES SYMBOL");return 0;}
Program.DeleteLatestPriceSymbol(commandArgs.Coalesce<String>("SYMBOL"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("DELETELATESTPRICESYMBOL REQUIRES SYMBOL");return 0;}
Program.DeleteLatestPriceSymbol(commandArgs.Coalesce<String>("SYMBOL"));
}
}
else if (arg.Equals("DELETEPRICESASOF"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("DELETEPRICESASOF REQUIRES DATE");return 0;}
Program.DeletePricesAsOf(commandArgs.Coalesce<String>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("DELETEPRICESASOF REQUIRES DATE");return 0;}
Program.DeletePricesAsOf(commandArgs.Coalesce<String>("DATE"));
}
}
else if (arg.Equals("UPDATEPRICESDATE"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEPRICESDATE REQUIRES DATE");return 0;}
Program.UpdatePricesDate(commandArgs.Coalesce<String>("DATE"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEPRICESDATE REQUIRES DATE");return 0;}
Program.UpdatePricesDate(commandArgs.Coalesce<String>("DATE"));
}
}
else if (arg.Equals("UPDATEPRICESSYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("UPDATEPRICESSYMBOL REQUIRES SYMBOL");return 0;}
Program.UpdatePricesSymbol(commandArgs.Coalesce<String>("SYMBOL"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("UPDATEPRICESSYMBOL REQUIRES SYMBOL");return 0;}
Program.UpdatePricesSymbol(commandArgs.Coalesce<String>("SYMBOL"));
}
}
else if (arg.Equals("LOADALLPRICESWATCHLIST"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("LOADALLPRICESWATCHLIST REQUIRES WATCHLIST");return 0;}
Program.LoadAllPricesWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("LOADALLPRICESWATCHLIST REQUIRES WATCHLIST");return 0;}
Program.LoadAllPricesWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
}
}
else if (arg.Equals("LOADALLPRICESSYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("LOADALLPRICESSYMBOL REQUIRES SYMBOL");return 0;}
Program.LoadAllPricesSymbol(commandArgs.Coalesce<String>("SYMBOL"));
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("LOADALLPRICESSYMBOL REQUIRES SYMBOL");return 0;}
Program.LoadAllPricesSymbol(commandArgs.Coalesce<String>("SYMBOL"));
}
}
else if (arg.Equals("LOADALLPRICESSYMBOLDATE"))
{
Console.WriteLine(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")))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("LOADALLPRICESSYMBOLDATE REQUIRES SYMBOL");return 0;}
if(!commandArgs.Has("DATE")){Console.WriteLine("LOADALLPRICESSYMBOLDATE REQUIRES DATE");return 0;}
Program.LoadAllPricesSymbolDate(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
}
}
else if (arg.Equals("SHOWALLPRICESSYMBOL"))
{
@@ -1321,13 +1398,6 @@ namespace MarketData
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("LOADALLPRICESSYMBOL REQUIRES SYMBOL");return 0;}
Program.ShowAllPricesSymbol(commandArgs.Coalesce<String>("SYMBOL"));
}
else if (arg.Equals("LOADALLPRICESSYMBOLDATE"))
{
CommandArgs commandArgs=new CommandArgs(args);
if(!commandArgs.Has("SYMBOL")){Console.WriteLine("LOADALLPRICESSYMBOLDATE REQUIRES SYMBOL");return 0;}
if(!commandArgs.Has("DATE")){Console.WriteLine("LOADALLPRICESSYMBOLDATE REQUIRES DATE");return 0;}
Program.LoadAllPricesSymbolDate(commandArgs.Coalesce<String>("SYMBOL"),commandArgs.Coalesce<DateTime>("DATE"));
}
else if (arg.Equals("LOADFINANCIALSTATEMENTSSYMBOL"))
{
CommandArgs commandArgs=new CommandArgs(args);