Active Order Interval
This is only applicable for RuntimeMode.LiveTestnet
and RuntimeMode.Live
.
In a scenario where your limit order has not been filled completely after a set given interval, the runtime will invoke the
on_active_order_interval
strategy method.
Attached below is a simple example of a scenario whereby the developer would like to 'cancel' all the unfilled orders followed by buying them at MarketPrice.
class MyStrategy(Strategy):
async def on_active_order_interval(self, strategy, active_orders):
for order in active_orders:
params = order.params
await strategy.cancel(exchange=Exchange.BybitLinear, order.client_order_id)
await strategy.open(
exchange=Exchange.BybitLinear,
side=params.side,
quantity=params.quantity,
take_profit=params.take_profit,
symbol=params.symbol,
stop_loss=params.stop_loss
is_hedge_mode=False,
)
...
The runtime will invoke the method everytime the RuntimeConfig.active_order_interval
has elapsed.
The params.quantity
is guaranteed to be the 'unfilled' size of the order.
The interval
here refers to the active_order_interval
parameter passed in to the RuntimeConfig
.
The passed in value is denoted in seconds.
active_order_interval=1 # active orders will be checked after every 1 second have elapsed.
active_order_interval=7000 # active orders will be checked after every 7000 seconds have elapsed.