private void HandleMyTradeMessage(JToken data) { List <MyTrade> new_my_trades = BybitTradesCreator.CreateMyTrades(data.SelectToken("data")); foreach (var trade in new_my_trades) { OnMyTradeEvent(trade); } }
private List <Trade> GetTrades(string security, DateTime start_time, DateTime end_time) { lock (locker_candles) { List <Trade> result_trades = new List <Trade>(); DateTime end_over = end_time; List <Trade> point_trades = BybitTradesCreator.GetTradesCollection(client, security, 1, -1); int last_trade_id = Convert.ToInt32(point_trades.Last().Id); while (true) { List <Trade> new_trades = BybitTradesCreator.GetTradesCollection(client, security, 1000, last_trade_id - 1000); if (new_trades != null && new_trades.Count != 0) { last_trade_id = Convert.ToInt32(new_trades.First().Id); new_trades.AddRange(result_trades); result_trades = new_trades; if (result_trades.First().Time <= start_time) { break; } } else { break; } Thread.Sleep(20); } for (int i = result_trades.Count - 1; i > 0; i--) { if (result_trades[i].Time > end_time) { result_trades.Remove(result_trades[i]); } } result_trades.Reverse(); for (int i = result_trades.Count - 1; i > 0; i--) { if (result_trades[i].Time < start_time) { result_trades.Remove(result_trades[i]); } } result_trades.Reverse(); return(result_trades); } }
private void HandleTradesMessage(JToken response) { List <Trade> new_trades = BybitTradesCreator.CreateFromWS(response.SelectToken("data")); foreach (var trade in new_trades) { OnTradeEvent(trade); } }