public void Load(List <string> LSProducts, TimeFrame TFrame) { string sTFrame = ABBREVIATIONS.ToString(TFrame); Thread Thrd = new Thread(delegate() { Record DATA = new Record(DTStart, TFrame); foreach (string product in LSProducts) { DateTime DTNow = DateTime.Now.AddMonths(1); DateTime DTCurrent = DTStart; do { List <ChartPoint> LCPoints = DATABASE.Load_ChartPoints(product, DTCurrent, sTFrame); DATA.Set(product, LCPoints); DTCurrent = DTCurrent.AddMonths(1); } while (DTNow.Year >= DTCurrent.Year || DTNow.Month >= DTCurrent.Month); } this.Set(TFrame, DATA); }); Thrd.Priority = ThreadPriority.Highest; Thrd.Start(); LThreadLoad.Add(Thrd); }
public void Save(string product, DateTime DTime, TimeFrame TFrame) { string sTFrame = ABBREVIATIONS.ToString(TFrame); Record DATA = this.Get(TFrame); List <ChartPoint> LCPoints = DATA.GetMonth(product, DTime); DATABASE.Save_ChartPoints(LCPoints, product, DTime, sTFrame); }
public int Update(bool AutoSave, TimeFrame TFrame) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); string sTFrame = ABBREVIATIONS.ToString(TFrame); int iTFMinutes = ABBREVIATIONS.ToMinutes(TFrame); List <string> LSProducts = this.GetProducts(); //LThreadUpdate = new List<Thread>(); int counter = 0; foreach (string product in LSProducts) { if (this.GetDATA(TFrame, product).Last().IsActual(TFrame, 0)) { continue; } //LThreadUpdate.Add(new Thread(delegate() { DateTime DTCurrent = ABBREVIATIONS.GreenwichMeanTime.AddDays(1); Record DATA = this.Get(TFrame); DateTime startDateTime = DTStart; List <ChartPoint> LCPoints = DATA.Get(product); if (LCPoints != null && LCPoints.Count > 0) { startDateTime = LCPoints.Last().Time.AddMinutes(iTFMinutes); } List <DateTime> LDTUpdates = new List <DateTime>(); ChartData CData = null; do { try { CData = CService.GetChartData(TOKEN, product, TFrame, startDateTime, DTCurrent); //Product\Date and Time\Open\High price\Low price\Closing Price } catch { } if (CData == null || CData.Data == "") { break; } List <ChartPoint> LCPointsNew = this.ProcessData(CData.Data); LCPointsNew = new List <ChartPoint>(LCPointsNew.OrderBy(CP => CP.Time).ToArray()); this.SetDATA(TFrame, product, LCPointsNew); counter += LCPointsNew.Count(); DTCurrent = LCPointsNew[0].Time.AddMinutes(-iTFMinutes); if (AutoSave) { this.Save(product, DTCurrent, TFrame); } } while (startDateTime <= DTCurrent); // })); //LThreadUpdate.Last().Start(); } //foreach (Thread Thrd in LThreadUpdate) // Thrd.Join(); return(counter); }
public bool Load(string product, TimeFrame TFrame, int deep, int ahead, int count) { if (DLSCPoints.ContainsKey(product)) //if up to date, refresh data base and return { DLSCPoints[product] = ARCHIVE.GetDATA(TFrame, product); return(false); } else { DLSCPoints.Add(product, ARCHIVE.GetDATA(TFrame, product)); } List <ChartPointsPredition> LDCPsPoints = DATABASE.Load_ChartPointsPrediction(product, ABBREVIATIONS.ToString(TFrame), deep, ahead); int iPosition = DLSCPoints[product].Count - count; if (LDCPsPoints == null || LDCPsPoints.Count == 0) { DATA.Add(product, new List <ChartPointsPredition>()); } else { if (LDCPsPoints.Count > count) { LDCPsPoints.RemoveRange(0, LDCPsPoints.Count - count); } for (int i = 0; i < LDCPsPoints.Count; i++) { LDCPsPoints[i].Prognosis(0); } DATA.Add(product, LDCPsPoints); } return(true); }