/* * public static void BuildMinuteDayNodes(ThreadControl tc) * { * * List<string> symbols = new List<string>(Global.State.AllSymbols); * * symbols.Remove("spy"); * symbols.Remove("aapl"); * symbols.Add("spy"); * symbols.Add("aapl"); * symbols.Reverse(); * * Dictionary<string, List<FD>> symbolsDataDays = new Dictionary<string, List<FD>>(); * * for(int n = 0; n < symbols.Count; n++) * { * symbolsDataDays.Add(symbols[n], DataMethods.ListOfDataDaysToListOfFD(DBMethods.GetDaysThatHaveDataBySymbol(symbols[n]))); * } * * for (int n = Global.State.DaysThatHaveData.Count - 1; n > 0; n--) * { * tc.Log.AddLine("Starting symbols for new day"); * * Parallel.For(0, symbols.Count, new ParallelOptions { MaxDegreeOfParallelism = 15 }, m => * { * // if the symbol has day data for this date * if (symbolsDataDays[symbols[m]].Exists(d => d.IsEqual(Global.State.DaysThatHaveData[n]))) * { * List<StockNode> nodes = DataMethods.GetCachedDayStockNodes(symbols[m], new List<FD>() { Global.State.DaysThatHaveData[n] }, Interval.OneMinute, false); * tc.Log.AddLine("[" + symbols[m] + "] " + Global.State.DaysThatHaveData[n].ToString() + " Done."); * } * else * { * tc.Log.AddLine("[" + symbols[m] + "] DOES NOT HAVE DAY DATA FOR THIS SYMBOL"); * } * }); * * if (!tc.CheckNotStopped()) * { * tc.Log.AddLine("Breaking!"); * break; * } * } * * * } */ public static void AddSymbols(ThreadControl tc) { List <string> symbols = new List <string>() { "adp", "azo", "avb", "avy", "bhge", "bll", "bac", "bk", "bax", "bbt", "bdx", "bby", "biib", "blk", "hrb", "ba", "bkng", "bwa", "bxp", "bsx", "bhf", "bmy", "avgo", "chrw", "ca", "cog", "cdns", "cpb", "cof", "cah", "kmx" }; int count = 0; for (int n = 0; n < symbols.Count; n++) { if (DBMethods.QuotesDBExists(symbols[n]) || DBMethods.TradesDBExists(symbols[n])) { tc.Log.AddLine("[" + symbols[n] + "] Already have this symbol"); } else { DBMethods.CreateQuotesDB(symbols[n]); DBMethods.CreateTradesDB(symbols[n]); DBMethods.InsertSymbol(symbols[n]); tc.Log.AddLine("[" + symbols[n] + "] Created Quotes and Trades tables and inserting into symbols.db"); count++; } } tc.Log.AddLine("All done. Added " + count + " new symbols."); }
public static void UpdateSingleDayAndSingleSymbolTicks(string symbol, FD fd, ThreadControl tc) { if (DBMethods.TradesDBExists(symbol) && DBMethods.QuotesDBExists(symbol)) { if (!Global.State.DataTracker.SymbolHasDayData(symbol, fd)) { tc.Log.AddLine("[" + fd.ToString() + "]", Verbosity.Verbose); tc.Log.AddLine("[" + symbol + "] Making trades API calls", Verbosity.Verbose); List <Trade> trades = StockAPI.Methods.GetHistoricTradesFull(symbol, fd.DT.Year, fd.DT.Month, fd.DT.Day); tc.Log.AddLine("[" + symbol + "] Bulk inserting " + trades.Count + " trade(s)", Verbosity.Verbose); int tradesInserted = DBMethods.BulkInsertTrades(trades, symbol); tc.Log.AddLine("[" + symbol + "] Inserted " + tradesInserted + " trade(s)", Verbosity.Normal); tc.Log.AddLine("[" + symbol + "] Making quotes API calls", Verbosity.Verbose); List <Quote> quotes = StockAPI.Methods.GetHistoricQuotesFull(symbol, fd.DT.Year, fd.DT.Month, fd.DT.Day); tc.Log.AddLine("[" + symbol + "] Bulk inserting " + quotes.Count + " quote(s)", Verbosity.Verbose); int quotesInserted = DBMethods.BulkInsertQuotes(quotes, symbol); tc.Log.AddLine("[" + symbol + "] Inserted " + quotesInserted + " quote(s)", Verbosity.Normal); int p = DBMethods.MarkSymbolHasDayData(symbol, fd.DT.Month, fd.DT.Day, fd.DT.Year); tc.Log.AddLine("[" + symbol + "] Marked symbol has data (" + p + ")", Verbosity.Minimal); } else { tc.Log.AddLine("[" + symbol + "] Already has data for this date."); } } else { tc.Log.AddLine("[" + symbol + "] DBs not found"); } }