Support Board
Date/Time: Tue, 03 Dec 2024 18:01:05 +0000
Post From: Sierra Fix connection
[2024-11-19 10:30:18] |
Marco Tortoli - Posts: 6 |
Hello, i am using GRPC Protocol Buffer, Java implementation (DTC Protocol: Google Protocol Buffers (GPB)) Testing how to fetch HistorcalPriceData (Historical Price Data Messages) (DTC Messages and Procedures: Historical Price Data) Configured the Server following up the guide (Data and Trading Communications (DTC) Protocol Server: Server Usage) Client Java Socket Settings Host 127.0.0.1 Port: 11098 Standard Output Console LogonRequest:
ProtocolVersion: 8 ClientName: "MyTradingApp" Logon response received:
ProtocolVersion: 8 Result: LOGON_SUCCESS ResultText: "Logon successful. Compression not supported." ServerName: "SC HistoricalDataServer" OrderCancelReplaceSupported: 1 HistoricalPriceDataSupported: 1 MarketDepthIsSupported: 1 OneHistoricalPriceDataRequestPerConnection: 1 HistoricalPriceDataRequest:
HistoricalPriceDataRequest: RequestID: 12345 Symbol: "EURUSD" RecordInterval: INTERVAL_1_DAY StartDateTime: 1731922993156 EndDateTime: 1732009393157 MaxDaysToReturn: 30 UseZLibCompression: 1 Integer_1: 42 Then for a time i get a lot of: Unexpected end of ZLIB input stream
It seems like is not receiving the right data, that according with the Doc i should receive one of the below messages HistoricalPriceDataResponseHeader
HistoricalPriceDataReject HistoricalPriceDataRecordResponse According with the Proto // Historical price data
HISTORICAL_PRICE_DATA_REQUEST= 800; HISTORICAL_PRICE_DATA_RESPONSE_HEADER = 801; HISTORICAL_PRICE_DATA_REJECT = 802; HISTORICAL_PRICE_DATA_RECORD_RESPONSE = 803; HISTORICAL_PRICE_DATA_TICK_RECORD_RESPONSE = 804; HISTORICAL_PRICE_DATA_RESPONSE_TRAILER = 807; Log from SierraChart 2700 2024-11-19 09:43:12.822 | HD Server Manager | Incoming connection from IP: 127.0.0.1
2024-11-19 09:43:12.824 | HD Server Manager | Started new historical data server. Count=1 2024-11-19 09:43:12.847 | HD Server | Thread:36 (1) | Creating socket. 2024-11-19 09:43:12.847 | HD Server | Thread:36 (1) | New receive buffer size: 262144 2024-11-19 09:43:12.848 | HD Server | Thread:36 (1) | Allocated send buffers: 32 of 4096 bytes. 2024-11-19 09:43:12.985 | HD Server | Received login. Requesting authorization. | Username: (none). | Thread:36 2024-11-19 09:43:12.985 | HD Server | Login has been authorized. | Username: (none). | Thread:36 2024-11-19 09:43:23.843 | HD Server | Timed out waiting for historical data request. | Username: (none). | Thread:36 2024-11-19 09:43:23.843 | HD Server | Thread:36 (1) | CloseSocket call. 2024-11-19 09:43:23.844 | HD Server | Thread:36 (1) | Shutdown started. Waiting for graceful close. 2024-11-19 09:43:23.844 | HD Server | Thread:36 (0) | CloseSocket call. 2024-11-19 09:43:23.853 | HD Server | Thread:36 (1) | Socket gracefully closed by remote side. 2024-11-19 09:43:23.853 | HD Server | Thread:36 (1) | Closed. 2024-11-19 09:43:23.994 | HD Server | Server thread ending. Closing socket. | Username: (none). | Thread:36 2024-11-19 09:43:23.994 | HD Server Manager | Current server count=0 What am i missing here? I tested using also with HeartbeatIntervalInSeconds but it's not clear in the doc if i should use or not, btw i am getting the same outcome LogonRequest logonRequest = LogonRequest.newBuilder()
.setProtocolVersion(8) .setClientName("MyTradingApp") .setHeartbeatIntervalInSeconds(10) .build(); Same for the HistoricalPriceDataRequest i used both values for UseZLibCompression (1 and 0) HistoricalPriceDataRequest historicalPriceDataRequest = HistoricalPriceDataRequest.newBuilder()
.setRequestID(12345) .setSymbol("EURUSD") // .setExchange("NASDAQ") .setRecordInterval(HistoricalDataIntervalEnum.INTERVAL_1_DAY) // Example interval .setStartDateTime(ZonedDateTime.now().minusDays(1).toInstant().toEpochMilli()) .setEndDateTime(ZonedDateTime.now().toInstant().toEpochMilli()) .setMaxDaysToReturn(30) .setUseZLibCompression(1) // 1 for compression, 0 for no compression // .setRequestDividendAdjustedStockData(1) .setInteger1(42) .build(); Some note. Debugging the response i notice that sometimes i get a message less than 4 bytes, Is there is any valid reason? As far i understand only the Header it should contain the Size of the Body Payload and the Type is used to see what is the message incoming, from the enum DTCMessageType. If above is correct i am expecting reading after an HistoricaPriceDataRequest something like the code snippet provided below, also according with the Doc (DTC Protocol: Google Protocol Buffers (GPB)) From the doc: The header Size field is set to the length of the encoded message plus the size of the header. The Size field allows the receiver to know when an entire message has been received. The Type field contains the DTC Message type, which are all defined in the DTCMessageType enum in the proto file. byte[] buffer = new byte[4096];
int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { ByteBuffer byteBuffer = ByteBuffer.wrap(buffer, 0, bytesRead).order(ByteOrder.LITTLE_ENDIAN); short messageSize = byteBuffer.getShort(); short messageType = byteBuffer.getShort(); byte[] messageBody = new byte[messageSize - 4]; byteBuffer.get(messageBody); try { switch (messageType) { case 801: // HistoricalPriceDataResponseHeader HistoricalPriceDataResponseHeader header = HistoricalPriceDataResponseHeader.parseFrom(messageBody); log.info("Historical data response header: " + header); break; case 802: // HistoricalPriceDataRecordResponse HistoricalPriceDataRecordResponse record = HistoricalPriceDataRecordResponse.parseFrom(messageBody); log.info("Historical data record: " + record); break; case 803: // HistoricalPriceDataReject HistoricalPriceDataReject reject = HistoricalPriceDataReject.parseFrom(messageBody); System.err.println("Historical data request rejected: " + reject); return; // Exit on rejection case 3: // Heartbeat Heartbeat heartbeat = Heartbeat.parseFrom(messageBody); log.info("Heartbeat received at: " + heartbeat); break; default: log.info("Unknown message type: " + messageType); break; } } catch (IOException e) { log.error("Failed to decompress or parse message: " + e.getMessage()); } } Date Time Of Last Edit: 2024-11-19 10:39:43
|
SierraChart--config.png / V - Attached On 2024-11-19 10:28:07 UTC - Size: 113.45 KB - 22 views |