private void EventsOnOnTrade(QuikSharp.DataStructures.Transaction.Trade qTrade) { lock (myTradeLocker) { try { MyTrade trade = new MyTrade(); trade.NumberTrade = qTrade.TradeNum.ToString(); trade.SecurityNameCode = qTrade.SecCode + "_" + qTrade.ClassCode; trade.NumberOrderParent = qTrade.OrderNum.ToString(); trade.Price = Convert.ToDecimal(qTrade.Price); trade.Volume = qTrade.Quantity; trade.Time = new DateTime(qTrade.QuikDateTime.year, qTrade.QuikDateTime.month, qTrade.QuikDateTime.day, qTrade.QuikDateTime.hour, qTrade.QuikDateTime.min, qTrade.QuikDateTime.sec); trade.Side = qTrade.Flags == OrderTradeFlags.IsSell ? Side.Sell : Side.Buy; if (MyTradeEvent != null) { MyTradeEvent(trade); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } } }
private void EventsOnOnTrade(QuikSharp.DataStructures.Transaction.Trade qTrade) { lock (myTradeLocker) { try { MyTrade trade = new MyTrade(); trade.NumberTrade = qTrade.TradeNum.ToString(); trade.SecurityNameCode = qTrade.SecCode + "_" + qTrade.ClassCode; trade.NumberOrderParent = qTrade.OrderNum.ToString(); trade.Price = Convert.ToDecimal(qTrade.Price); trade.Volume = qTrade.Quantity; trade.Time = new DateTime(qTrade.QuikDateTime.year, qTrade.QuikDateTime.month, qTrade.QuikDateTime.day, qTrade.QuikDateTime.hour, qTrade.QuikDateTime.min, qTrade.QuikDateTime.sec, qTrade.QuikDateTime.ms); trade.Side = qTrade.Flags == OrderTradeFlags.IsSell ? Side.Sell : Side.Buy; trade.MicroSeconds = qTrade.QuikDateTime.mcs; MyTrade tradeWithSameNumber = _myTrades.Find(t => t.NumberTrade == qTrade.TradeNum.ToString()); if (tradeWithSameNumber != null) { // нашли трейд с тем же номером. if (tradeWithSameNumber.Time == trade.Time && tradeWithSameNumber.Price == trade.Price && tradeWithSameNumber.Volume == trade.Volume && tradeWithSameNumber.MicroSeconds == trade.MicroSeconds) { // повтор return; } else { // ошибка в КвикШарп по номеру сделки. Даём ей свою trade.NumberTrade = NumberGen.GetNumberOrder(StartProgram.IsOsTrader).ToString(); } } _myTrades.Add(trade); if (MyTradeEvent != null) { MyTradeEvent(trade); } if (_myTrades.Count > 1000) { _myTrades.RemoveAt(0); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } } }