Drawdown behaviours
In our grid trading strategy, we have multiple behaviors that determine how the bot places orders and distributes amounts across different grid levels. This section will explain the three primary drawdown behaviors: Full Distribution, Progressive Drawdown, and MaxQtyPercent.
1. Full Distribution
Full Distribution aggressively distributes the maximum position value across all grid levels. This strategy ensures that each subsequent grid level will have an order size greater than the previous one. It aims to stay "sticky" to price action, making it ideal for high-frequency trading.
Objective: To distribute the entire position value across the specified number of grid levels, ensuring that each level is larger than the previous.
Behavior: - It does not subtract the open position from the max position value, ensuring that each order is larger than the open position. - The maximum wallet exposure for the side (long or short) is respected. - If the position is already open, the initial entry is placed at the best bid or ask, and subsequent levels ensure larger amounts.
Function: calculate_order_amounts_aggressive_drawdown
Key Formula:
adjusted_max_position_value = max_position_value - current_pos_value
Application:
- Used when the configuration specifies drawdown_behavior = "full_distribution"
.
2. Progressive Drawdown
The Progressive Drawdown behavior ensures that each subsequent level progressively increases in order size, but in a less aggressive manner than Full Distribution. This strategy is more conservative and focuses on ensuring that orders are progressively larger without immediately distributing the full position.
Objective: To progressively increase the size of orders across levels, making sure that each level is larger than the previous one while respecting wallet exposure and position limits.
Behavior: - The total position value is distributed more gradually across levels, ensuring progressively larger grid entries. - If the current position is already open, each new order ensures a meaningful increase in size.
Function: calculate_order_amounts_progressive_distribution
Key Formula:
quantity = max(cumulative_position_value / current_price + (i + 1) * qty_precision, amounts[-1] + (i + 1) * qty_precision)
Application:
- Used when the configuration specifies drawdown_behavior = "progressive_drawdown"
.
3. Max qty percent
Max qty percent drawdown behavior is designed for grid setups that are continually re-issued based on the current market price. This behavior is much more flexible and does not adhere to a strict drawdown behavior. The grid strategy will continue placing orders based on the grid configuration until either the grid or position limits are hit.
Objective: To continually issue grid orders based on the market price without a fixed drawdown behavior, allowing the strategy to function indefinitely.
Behavior:
- The total grid orders are issued based on the user's settings, but there is no aggressive or progressive drawdown.
- The position size can be dynamically recalculated based on market conditions.
- Works in conjunction with the calculate_total_amount_refactor
function to ensure position sizing is done properly.
Function: calculate_total_amount_refactor
Key Formula:
total_amount = calculate_total_amount_notional_ls_properdca(
symbol, total_equity, best_ask_price, best_bid_price,
wallet_exposure_limit_long, wallet_exposure_limit_short,
side, levels, enforce_full_grid, long_pos_qty, short_pos_qty
)
Application:
- This behavior is used when grid_behavior = "maxqtypercent"
.
How to Use
- Configure Drawdown Behaviors:
- To use Full Distribution or Progressive Drawdown, configure the
drawdown_behavior
parameter in your settings. -
To use the Infinite behavior, configure the
drawdown_behaviour
parameter as "maxqtypercent". -
Adjusting Levels:
- You can adjust the number of levels and strength in the strategy configuration to change the aggressiveness of the grid strategy for both Full Distribution and Progressive Drawdown behaviors.
This structure allows you to choose between different levels of aggressiveness or continuous grid management depending on market conditions and your risk tolerance.
Example Configuration for one coin long biased using long and short
grid_bheavior: "dbscanalgo"
drawdown_behavior: "progressive_drawdown"
levels: 4
strength: 1.4
wallet_exposure_limit_long: 0.5
wallet_exposure_limit_short: 0.001
enforce_full_grid: true