I get a tick by tick market data stream in a IP Address with a specified port in a TCP/IP packet format continuously. I want to log that in a csv file or work around the data stream for trading and data analysis.
Server sends all the packets in following format
typedef struct
{
CHAR cCompOrNot
SHORT nDataSize;
SHORT iNoOfPackets;
}ST_COMP_BATCH_HEADER
typedef struct
{
SHORT iCode;
SHORT iLen;
LONG lSeqNo;
} ST_INFO_HEADER;
typedef struct
{
.
.
}ST_DATA_INFO;
typedef struct
{
SHORT iCheckSum;
CHAR cEOT;
} ST_INFO_TRAILER;
typedef struct
{
ST_INFO_HEADER stInfoHdr;
ST_DATA_INFO stDataInfo;
ST_INFO_TRAILER stInfoTrailer;
.
}ST_DATA_PACKET
All the packets received from server consist of compress batch header. Compress batch header gives the information about the data packet compressed or not, number of packets in the following data packet and the total size of data packet. Client needs to decompress the data packet using LZO decompression algorithm. After decompression each data packet consists of ST_INFO_HEADER, which has the iCode field to identify the type of the packet. Using iCode field, data info packet is mapped to the respective data packet.
So is there any way that I can decode the data in those packets using some Python Library and work around.
Thanks in advance!