strategy.risk
Functions
allow_entry_in
strategy.risk.allow_entry_in(simple string dir)Sets which direction strategy entries are allowed in.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dir | simple string |
max_cons_loss_days
strategy.risk.max_cons_loss_days(simple int count)Sets the maximum number of consecutive losing days allowed.
A losing day is one where the equity at the end of the day is lower than at the start. When the number of consecutive losing days reaches the limit, all pending orders are cancelled and all positions are closed. Trading is permanently disabled for the rest of the backtest.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
count | simple int | The maximum number of consecutive losing days. |
max_drawdown
strategy.risk.max_drawdown(simple float value, simple string type)Sets the maximum allowed drawdown for the strategy.
When the strategy's equity drawdown exceeds this limit, all pending orders are cancelled and all positions are closed. Trading is permanently disabled for the rest of the backtest.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value | simple float | The maximum drawdown value. | |
type | simple string | The value type: strategy.cash or strategy.percent_of_equity. |
max_intraday_filled_orders
strategy.risk.max_intraday_filled_orders(simple int count)Sets the maximum number of filled orders allowed per trading day.
When the daily limit is reached, no further orders will be filled for the rest of that trading day. The counter resets at the start of each new trading day.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
count | simple int | The maximum number of filled orders per day. |
max_intraday_loss
strategy.risk.max_intraday_loss(simple float value, simple string type)Sets the maximum allowed intraday loss for the strategy.
When the intraday loss exceeds this limit, all pending orders are cancelled and all positions are closed. Trading is disabled for the rest of the trading day and resumes on the next day.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value | simple float | The maximum intraday loss value. | |
type | simple string | The value type: strategy.cash or strategy.percent_of_equity. |
max_position_size
strategy.risk.max_position_size(simple float size)Sets the max absolute position size.
Orders that would exceed this limit will be capped; if the minimum possible order still exceeds, no order is placed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
size | simple float |