Support Board
Date/Time: Tue, 26 Nov 2024 19:47:00 +0000
Post From: SerraChart as a DTC Protocol Client
[2023-09-09 03:02:12] |
d9e5c763 - Posts: 108 |
After attempting to write several DTC messages, I realized that if I wanted to implement trading functionality as well, the error rate would be too high. Using CppHeaderParser could also introduce other invisible issues. So, I decided to use GPB (Google Protocol Buffers). After my tests, I found that even if I sent a MARKET_DATA_UPDATE_TRADE message, Sierra Chart internally still treats it as MARKET_DATA_UPDATE_TRADE_COMPACT: Side = trade['side'] Side = dtc_pb2.AtBidOrAskEnum.AT_BID if Side.upper() == "SELL" else dtc_pb2.AtBidOrAskEnum.AT_ASK Price = float(trade['px']) * multiplier Volume = int(trade['sz']) / 1.0 DateTime = int(trade['ts']) / 1000.0 LastTradeId = int(trade['tradeId']) MarketDataUpdateTrade = dtc_pb2.MarketDataUpdateTrade() MarketDataUpdateTrade.SymbolID = SymbolID MarketDataUpdateTrade.AtBidOrAsk = Side MarketDataUpdateTrade.Price = Price MarketDataUpdateTrade.Volume = Volume MarketDataUpdateTrade.DateTime = DateTime SerializedMarketDataUpdateTrade = MarketDataUpdateTrade.SerializeToString() DeserializedMarketDataUpdateTrade = dtc_pb2.MarketDataUpdateTrade() DeserializedMarketDataUpdateTrade.ParseFromString(SerializedMarketDataUpdateTrade) print("Deserialized DateTime: ", DeserializedMarketDataUpdateTrade.DateTime) SerializedMarketDataUpdateTradeSize = len(SerializedMarketDataUpdateTrade) + 4 Header = struct.pack('<HH', SerializedMarketDataUpdateTradeSize, dtc_pb2.DTCMessageType.MARKET_DATA_UPDATE_TRADE) FullSerializedMarketDataUpdateTrade = Header + SerializedMarketDataUpdateTrade writer.write(FullSerializedMarketDataUpdateTrade) await writer.drain() I could see that the data I eventually sent in did indeed have millisecond-precision floating-point numbers, but this data disappeared within the software. MarketDataUpdateBidAskFloatWithMicroseconds did not have this issue. Another point is that writing to SCID files through HistoricalPriceDataTickRecordResponse now also has millisecond precision. So, one of the issues (which would occur when using JSON) has been resolved. I hope this issue can be fully addressed in the future. |