Market Depth Data File Format
- Market Depth Data File Structures Used
- s_MarketDepthFileRecord Structure Member Descriptions
- Identifying Full Market Depth Data Snapshot
Market Depth Data File Structures Used
The market depth data file header file is as follows. The size of this data structure is 64 bytes. This header is at the beginning of a market depth data file.
struct s_MarketDepthFileHeader { //--- Static Members --------------------------------------------- // This is the minimum number of bytes that must be read in order // to verify the file as a depth file and read in the rest of the // header. static const int MINIMAL_HEADER_SIZE = 16; static const uint32_t UNIQUE_HEADER_ID = 0x44444353; // "SCDD" //--- Members ---------------------------------------------------- uint32_t FileTypeUniqueHeaderID; // "SCDD" uint32_t HeaderSize; uint32_t RecordSize; uint32_t Version; char Reserve[48]; //--- Methods ---------------------------------------------------- s_Header() : FileTypeUniqueHeaderID(UNIQUE_HEADER_ID) , HeaderSize(sizeof(s_Header)) , RecordSize(sizeof(s_Record)) , Version(1) { memset(Reserve, 0, sizeof(Reserve)); } };
The market depth data file record structure is as follows. The size of this data structure is 24 bytes.
A market depth data file consists of a single header at the beginning of the file followed by records of the s_MarketDepthFileRecord structure type.
struct s_MarketDepthFileRecord { //--- Types ------------------------------------------------------ enum CommandEnum : t_Byte { NO_COMMAND = 0 , COMMAND_CLEAR_BOOK = 1 , COMMAND_ADD_BID_LEVEL = 2 , COMMAND_ADD_ASK_LEVEL = 3 , COMMAND_MODIFY_BID_LEVEL = 4 , COMMAND_MODIFY_ASK_LEVEL = 5 , COMMAND_DELETE_BID_LEVEL = 6 , COMMAND_DELETE_ASK_LEVEL = 7 }; //This flag indicates the end of a batch of market depth updates. static const uint8_t FLAG_END_OF_BATCH = 0x01; //--- Members ---------------------------------------------------- SCDateTimeMS DateTime; CommandEnum Command = NO_COMMAND; uint8_t Flags = 0; uint16_t NumOrders = 0; float Price = 0.0f; uint32_t Quantity = 0; uint32_t Reserved = 0; // Not used, but exists due to byte padding. //--- Methods ---------------------------------------------------- s_Record() { } };
s_MarketDepthFileRecord Structure Member Descriptions
Command
This variable is of type CommandEnum. The possible values are listed below.
enum CommandEnum : uint8_t { NO_COMMAND = 0 , COMMAND_CLEAR_BOOK = 1 , COMMAND_ADD_BID_LEVEL = 2 , COMMAND_ADD_ASK_LEVEL = 3 , COMMAND_MODIFY_BID_LEVEL = 4 , COMMAND_MODIFY_ASK_LEVEL = 5 , COMMAND_DELETE_BID_LEVEL = 6 , COMMAND_DELETE_ASK_LEVEL = 7 };
Flags
This variable provides one or more flags with information about the record. The possible values are listed below.
static const uint8_t FLAG_END_OF_BATCH = 0x01;
DateTime
The DateTime member variable is a SCDateTimeMS variable. It represents the timestamp of the market depth data record command.
This is a 64-bit integer. It represents the number of microseconds since the SCDateTime epoch of December 30, 1899.
Versions prior to 2151, use a double precision floating point type variable to represent Date-Time values. For a complete explanation of the Date component of this value, refer to Date Value. The date value is the integer portion of the double. The fractional portion is the Time value which is represented as a fraction of one day where 1/86400000 is 1 ms. 86400000 is the number of milliseconds in a day.
This Date and Time value must be in the UTC time zone.
Sierra Chart provides the /ACS_Source/SCDateTime.h file with various functions for working with these Date-Time values.
NumOrders
NumOrders is the number of limit orders at the Price.
Price
Price is the price of the market depth level.
Quantity
Quantity is the total quantity of all the limit orders at the Price.
Reserved3
This field is unused. It exists for padding purposes and for future use.
Identifying Full Market Depth Data Snapshot
In a market depth data file the full snapshot of all market depth levels is written to the file every 10 minutes.
You can identify a snapshot by the following pattern of s_MarketDepthFileRecord records.
A s_MarketDepthFileRecord where s_MarketDepthFileRecord::Command = s_MarketDepthFileRecord::COMMAND_CLEAR_BOOK.
Zero or more s_MarketDepthFileRecord records where s_MarketDepthFileRecord::Command = s_MarketDepthFileRecord::COMMAND_ADD_BID_LEVEL or COMMAND_ADD_ASK_LEVEL.
The final record in this snapshot batch will have s_MarketDepthFileRecord::Flags = s_MarketDepthFileRecord::FLAG_END_OF_BATCH;
*Last modified Wednesday, 22nd February, 2023.