The strategy State is serialised as JSON
The raw state is written to the disk as a flat JSON file
The web frontend downloads the same JSON file to display the strategy execution state to the user
State is defined as nested, tree-like, structure of Python
Here are some gotchas.
Python dataclasses-json library is used to seralise everything.
JSON does not have native date type.
Dates are serialised as UTC UNIX timestamps, or integer seconds since 1970.
Because we are doing algorithmic trading, not accounting, prices do not need to be exact.
Prices are serialised as floats.
Numbers needing accounting purposes, like quantity of token holdings,
are presented by Python
decimal.Decimal. Because JSON
cannot present these numbers, they are serialised as infinite accurate
Inline token and trading pair identifiers#
Token and trading pair identifiers are not passed by a reference, lie trading pair id or address, but by a copy. This copy contains information like token names and decimals. This information is duplicated in every copy, making this inefficient, but it greatly simplifies client side and executor side coding, because the Trading universe may be dynamic.