Script Execution
To execute a script, you must define a Strategy
class with the following structure.
Variables List
connectionName
- Name of the connection to the exchange.symbols
- List of symbols for which the strategy is running.interval
- Interval ofrunOnTimer
method in ms.
Methods List
init
- In this method, initialization occurs before the main functionality of the script is launched.stop
- Method for stopping the script.runOnTimer
- Method that is called at a specified interval (ms).runOnTick
- Method that is called on each new tick.runTickEnded
- Method that is called after the end of the tick. (Tester only)runOnOrderChange
- Method that is called when the order status changes.runOnEvent
- Method that is called when websocket event occurs . (Runtime only)runOnError
- Method that is called when an error occurs.runArgsUpdate
- Method that is called when the script parameters are updated.runOnReportAction
- Method that is called when an action is performed in the report.
Script Execution Process
Environment Initialization The environment creates an instance of the
Strategy
class and passes parameters to it through theargs
variable. Additionally, all parameters are accessible globally via theARGS
object. After the class instance is created, theconnectionName
andsymbols
variables must be populated.Using the
connectionName
, the environment subscribes to WebSocket events for all symbols specified in thesymbols
variable. These events include:Ticks: Arrival of a new tick
OrderBook: Changes in the order book
Balance: Updates to the account balance
Positions: Modifications to open positions
Orders: Updates to orders
If the interval
variable is set, the runOnTimer
method will be triggered every interval
milliseconds. In this case, the runOnTick
method will not be called.
Initialization (
init
Method) After the class instance is created, theinit
method is called. This method is used to initialize the script.Stopping the Script (
stop
Method) Thestop
method is called when the script is stopped.