private void ReadTradeUpdateData(byte[] data, ref int offset) { string tradeUpdateJsonPacket = Encoding.UTF8.GetString(data.SubArray(5, data.Length - 5)); var deserializedPacket = JsonConvert.DeserializeObject <Dictionary <string, object> >(tradeUpdateJsonPacket); TradeUpdate trade = new TradeUpdate(); trade.Exchange = deserializedPacket["exchange"].ToString(); trade.Product = deserializedPacket["product"].ToString(); trade.TradingSymbol = deserializedPacket["trading_symbol"].ToString(); trade.TradePrice = Convert.ToDouble(deserializedPacket["trade_price"]); trade.TradeNumber = deserializedPacket["trade_id"].ToString(); trade.OrderSide = deserializedPacket["order_side"].ToString(); trade.OmsOrderId = deserializedPacket["oms_order_id"].ToString(); trade.LoginId = deserializedPacket["login_id"].ToString(); trade.InstrumentToken = Convert.ToInt32(deserializedPacket["instrument_token"]); trade.TradeQuantity = Convert.ToInt32(deserializedPacket["filled_quantity"]); trade.TradeTime = Convert.ToInt64(deserializedPacket["exchange_time"]); trade.ExchangeOrderId = deserializedPacket["exchange_order_id"].ToString(); trade.ClientId = deserializedPacket["client_id"].ToString(); OnTradeUpdateReceive(trade); }
private void OnTradeUpdateReceive(TradeUpdate tradeUpdate) { var handler = TradeUpdateEvent; handler?.Invoke(tradeUpdate); }