/// <summary> /// Get Data From Date X to Date Y on Symbol V /// </summary> /// <param name="From"></param> /// <param name="To"></param> /// <param name="Symbol"></param> public void GetDataFromTo(DateTime From, DateTime To, string Symbol) { Console.WriteLine("Core - Loading data for : {0}", Symbol); if (From > To) { throw new Exception(string.Format("From : {0} is superior to To : {1}", From, To)); } var CandleMin = this.bclient.Client.GetKlines(Symbol, KlineInterval.OneMinute, startTime: From, endTime: To, limit: int.MaxValue); foreach (var data in CandleMin.Data) { BinanceStreamKlineData formated = new BinanceStreamKlineData(); formated.Data = new BinanceStreamKline(); formated.EventTime = data.CloseTime; formated.Symbol = Symbol; formated.Data.Close = data.Close; formated.Data.CloseTime = data.CloseTime; formated.Data.Final = true; formated.Data.High = data.High; formated.Data.Low = data.Low; formated.Data.OpenTime = data.OpenTime; formated.Data.Symbol = Symbol; formated.Data.Open = data.Open; formated.Data.Volume = data.Volume; formated.Data.TakerBuyBaseAssetVolume = data.TakerBuyBaseAssetVolume; formated.Data.TakerBuyQuoteAssetVolume = data.TakerBuyQuoteAssetVolume; formated.Data.TradeCount = data.TradeCount; var sourcedata = new Trady.Core.Candle(formated.Data.CloseTime, formated.Data.Open, formated.Data.High, formated.Data.Low, formated.Data.Close, formated.Data.Volume); BinanceCandle Standardize = new BinanceCandle(sourcedata); Standardize.Last = formated.Data.Final; Standardize.Name = formated.Symbol; Standardize.Candle = sourcedata; Type myType = formated.Data.GetType(); //Extract all exchanger candle properties IList <PropertyInfo> props = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in props) { object propValue = prop.GetValue(formated.Data, null); Standardize.Properties.Add(prop.Name, propValue); } Standardize.Update(); this.Candles.Add(Standardize); } Console.WriteLine("Core - Finished to load from {0} to {1} for symbol {2}", From, To, Symbol); }
/// <summary> /// Receive Raw Data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BData_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { //Data caching and moving to Azure Data Table logic goes here switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: var Candle = (BinanceStreamKlineData)e.NewItems[0]; //Remove Extra var sourcedata = new Trady.Core.Candle(Candle.Data.CloseTime, Candle.Data.Open, Candle.Data.High, Candle.Data.Low, Candle.Data.Close, Candle.Data.Volume); BinanceCandle Standardize = new BinanceCandle(sourcedata); Standardize.Last = Candle.Data.Final; Standardize.Name = Candle.Symbol; Standardize.Candle = sourcedata; Type myType = Candle.Data.GetType(); //Extract all exchanger candle properties IList <PropertyInfo> props = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in props) { object propValue = prop.GetValue(Candle.Data, null); Standardize.Properties.Add(prop.Name, propValue); } Standardize.Update(); try { Candles.Add(Standardize); } catch (Exception ex) { Console.WriteLine("Exception during core candle add (computed) : {0} ", ex.Message); } //Until fix try { if (UseSender) { this.Sender.Send(Standardize.Jscontainer); } DataOrganizer.SourceData.Add(Standardize); //if (Moon.Global.shared.table != null) //{ // TableOperation insertOperation = TableOperation.Insert(Standardize); // // Execute the insert operation. // Moon.Global.shared.table.Execute(insertOperation); //} } catch (Exception ex) { } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: break; case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: break; } }