There are two approaches for encoding time fields:
1. Using base_time from user_session_2.LogonResult.
2. Representing time as milliseconds since the UNIX epoch (01-01-1970 00:00 UTC).
Fields named *_time are, by default, encoded using base_time. To get the actual value, add the field’s value to base_time.
Example:
•base_time: "2025-04-03T14:23:20"
•Field value (e.g., LogonResult.server_time): 123456789 (milliseconds)
•Actual server time value: "2025-04-05T00:40:56.789"
Fields with the google.protobuf.Timestamp type contain an offset from the UNIX epoch.
Example:
{"seconds": 1743813656, "nanos": 789000000}
corresponds to "2025-04-05T00:40:56.789".
How To Interpret Scaled Prices?
Many server messages containing prices are using scaled integer price format.
In order to get correct prices that can be further used in calculations, correct_price_scale of metadata_2.ContractMetadata message.
For example:
1. contract_metadata for symbol (only significant fields are shown):
{
"information_reports": [
{
"id": 0,
"status_code": 0,
"symbol_resolution_report": {
"contract_metadata": {
"contract_id": 1,
"correct_price_scale": 0.01
}
}
}
]
}
2. time_and_sales_reports for this contract containing scaled price:
{
"time_and_sales_reports": [
{
"request_id": 1,
"result_code": 0,
"quotes": [
{
"type": 2,
"quote_utc_time": 2363664,
"scaled_price": 6521,
"volume": {
"significand": 10
}
}
],
"is_report_complete": true
}
]
}
3. Using correct_price_scale from the first message and scaled_price from the second, correct price will be: 6521 * 0.01 = 65.21
The opposite calculation should be done for requests where scaled prices are required.
For example, to place a limit order with price 65.32 of a contract having correct_price_scale equal to 0.01 (as in above example) scaled limit price should be calculated as: 65.32 / 0.01 = 6532. The resulting message will be:
{
"order_requests": [
{
"request_id": 1,
"new_order": {
"order": {
"account_id": 12345,
"when_utc_timestamp": {
"seconds": 10
},
"contract_id": 1,
"cl_order_id": "12345",
"order_type": 2,
"duration": 1,
"side": 1,
"scaled_limit_price": 6532,
"qty": {
"significand": 1
}
}
}
}
]
}