DSL Trade API¶
Trade API is available to robot scripts through the trade.* namespace.
Robots do not access the trading API directly. Every trade action is sent through the platform bridge.
trade.buy¶
Opens a buy position.
trade.buy(symbol="BTCUSD", volume=0.01)
Options:
| Field | Required | Description |
|---|---|---|
symbol |
Yes | Trading symbol |
volume |
Yes | Position volume |
tp |
No | Take profit. Defaults to 0 |
sl |
No | Stop loss. Defaults to 0 |
If tp or sl is missing or empty, the platform sends 0.
trade.sell¶
Opens a sell position.
trade.sell(symbol="BTCUSD", volume=0.01)
Options are the same as trade.buy.
trade.closeAll¶
Closes all positions for a symbol.
trade.closeAll(symbol="BTCUSD")
trade.positionsCount¶
Returns the number of open positions, optionally filtered by symbol.
count = trade.positionsCount(symbol="BTCUSD")
In dry-run mode this method includes simulated positions from the current robot runtime.
Runtime Guards¶
Before executing trade.buy or trade.sell, the platform checks:
maxPositions;cooldownSeconds;maxActionsPerEvent.
Skipped actions are written to the script log as warnings.