Skip to content

Configuration

Account Section

Configure your account settings in the account.json file under the account section. This includes API keys, account names, and other related settings.

Parameters:

  • name: Exchange name
  • api_key: Your exchange API key.
  • api_secret: Your exchange API secret.
  • account_name: A name to identify your account configuration.

Accounts

Configure your accounts using 'account.json' in the configs folder.

{
    "exchanges": [
        {
            "name": "bybit",
            "account_name": "account_1",
            "api_key": "your_api_key",
            "api_secret": "your_api_secret"
        },
        {
            "name": "bybit",
            "account_name": "account_2",
            "api_key": "your_api_key",
            "api_secret": "your_api_secret"
        },
        {
            "name": "bybit",
            "account_name": "account_3",
            "api_key": "your_api_key",
            "api_secret": "your_api_secret"
        }
    ]
}

Bot Section

Configure your bot settings in the config.json file under the bot section. This includes strategy parameters, risk management settings, and other related settings.

Risk management parameters

  • Exchange leverage is MAX CROSS on all pairs by default: Changing user_defined_leverage does not change leverage on exchange instead it changes the amount the bot is allowed to use.
  • user_defined_leverage_long: This parameter defines the leverage to use for long positions. Leverage is a multiplier that increases the size of the position and the potential profit/loss. For example, a leverage of 10 means that for every $1 you have, you can place a trade worth $10. Be careful with this setting as higher leverage also increases the risk.
  • user_defined_leverage_short: This parameter defines the leverage to use for short positions. Similar to user_defined_leverage_long, it's a multiplier that increases the size of the position and the potential profit/loss.

Risk Management Explanation

Risk Management plays a crucial role in trading strategies, as it helps protect the trader's capital and limits potential losses. In the provided code snippet, there are several parameters and calculations related to risk management. Let's dive into each of them and provide examples to clarify their usage.

  • user_defined_leverage_long and user_defined_leverage_short:
  • These parameters allow the user to specify the leverage for long and short positions, respectively.
  • Leverage is a multiplier that increases the size of the position and the potential profit/loss.
  • Example:

    • If user_defined_leverage_long is set to 5, it means that for every $1 of the trader's capital, they can open a long position worth $5.
    • Similarly, if user_defined_leverage_short is set to 3, it means that for every $1 of the trader's capital, they can open a short position worth $3.
  • wallet_exposure_limit_long and wallet_exposure_limit_short:

  • These parameters define the maximum percentage of the trader's total equity that can be allocated to long and short positions, respectively.
  • They help limit the overall exposure to risk by controlling the amount of capital deployed in each position.
  • Example:

    • If wallet_exposure_limit_long is set to 0.1 (10%), it means that the maximum amount allocated to long positions cannot exceed 10% of the total equity.
    • Similarly, if wallet_exposure_limit_short is set to 0.05 (5%), it means that the maximum amount allocated to short positions cannot exceed 5% of the total equity.
  • Effective Leverage Calculation:

  • The effective leverage used in trading is calculated as total_equity * wallet_exposure_limit * leverage_used.
  • This calculation determines the maximum position value based on the trader's total equity, wallet exposure limit, and the selected leverage.
  • Example:

    • Let's say a trader has a total equity of $10,000, wallet_exposure_limit_long is set to 0.1 (10%), and user_defined_leverage_long is set to 5.
    • The maximum position value for long positions would be: $10,000 * 0.1 * 5 = $5,000.
    • This means that the trader can open long positions with a total value of up to $5,000.
  • enforce_full_grid:

  • This parameter determines whether the trading strategy should enforce a full grid of positions or allow partial grid usage.
  • If enforce_full_grid is set to True, the code calculates the required notional amount by dividing the maximum position value by the number of levels.
  • If enforce_full_grid is set to False, the code uses the maximum position value as the required notional amount.
  • Example:

    • Let's say the maximum position value is $5,000, and the trading strategy uses 5 levels.
    • If enforce_full_grid is True, the required notional amount for each level would be: $5,000 / 5 = $1,000.
    • If enforce_full_grid is False, the required notional amount would be the full $5,000.
  • Adjusting Maximum Position Value:

  • The code takes into account the current position value (long or short) and adjusts the maximum position value accordingly.
  • It calculates the current position value by multiplying the position quantity (long or short) with the respective best ask or bid price.
  • The adjusted maximum position value is then calculated by subtracting the current position value from the original maximum position value.
  • Example:
    • Let's say the maximum position value is $5,000, and the trader currently holds a long position with a quantity of 2 units at a best ask price of $100.
    • The current position value would be: 2 * $100 = $200.
    • The adjusted maximum position value would be: $5,000 - $200 = $4,800.
    • This means that the trader can open additional positions with a total value of up to $4,800.

These risk management parameters and calculations help traders control their exposure to risk, limit potential losses, and manage their positions effectively. By adjusting these parameters based on their risk tolerance and trading strategy, traders can optimize their risk management approach and protect their capital.

Linear Grid Strategy Parameters

Here are the parameters for the linear_grid strategy in your config.json file:

  • max_qty_percent_long: Defines the maximum percentage of your wallet balance that can be used for long positions.
  • max_qty_percent_short: Defines the maximum percentage of your wallet balance that can be used for short positions.
  • auto_reduce_cooldown_enabled: Boolean parameter that determines whether the auto-reduce cooldown feature is enabled. This feature automatically reduces the size of your positions after a certain period.
  • auto_reduce_cooldown_start_pct: Defines the percentage at which the auto-reduce cooldown feature starts.
  • wallet_exposure_limit_long: Defines the maximum exposure limit for long positions as a percentage of your wallet balance.
  • wallet_exposure_limit_short: Defines the maximum exposure limit for short positions as a percentage of your wallet balance.
  • levels: Defines the number of grid levels, representing the total number of buy and sell orders placed above and below the current price level.
  • strength: Defines the strength of the grid. A higher value means the grid levels are spaced further apart.
  • outer_price_distance: Defines the distance from the current price to the outermost grid levels.
  • min_outer_price_distance: Defines the minimum distance from the current price to the outermost grid levels.
  • max_outer_price_distance: Defines the maximum distance from the current price to the outermost grid levels.
  • long_mode: Boolean parameter that determines whether the bot can open long positions.
  • short_mode: Boolean parameter that determines whether the bot can open short positions.
  • reissue_threshold: Defines the threshold at which the bot will reissue orders that have been partially filled.
  • buffer_percentage: Defines the buffer percentage for the grid. This is the percentage of the price range kept empty between the outermost grid levels and the upper and lower price limits.
  • initial_entry_buffer_pct: Defines the buffer percentage for the initial entry.
  • min_buffer_percentage: Defines the minimum buffer percentage for the grid.
  • max_buffer_percentage: Defines the maximum buffer percentage for the grid.
  • enforce_full_grid: Boolean parameter that determines whether the bot should always maintain a full grid of orders.
  • min_buffer_percentage_ar: Defines the minimum buffer percentage for auto-reduce.
  • max_buffer_percentage_ar: Defines the maximum buffer percentage for auto-reduce.
  • upnl_auto_reduce_threshold_long: Defines the unrealized profit and loss (UPNL) threshold for auto-reducing long positions.
  • upnl_auto_reduce_threshold_short: Defines the UPNL threshold for auto-reducing short positions.
  • failsafe_enabled: Boolean parameter that determines whether the failsafe feature is enabled. This feature automatically closes all positions if the UPNL reaches a certain threshold.
  • failsafe_start_pct: Defines the percentage at which the failsafe feature starts.
  • long_failsafe_upnl_pct: Defines the UPNL percentage for the long failsafe.
  • short_failsafe_upnl_pct: Defines the UPNL percentage for the short failsafe.

Example Configuration Snippet

{
    "api": {
        "filename": "quantdatav2_bybit.json",
        "mode": "remote",
        "url": "https://api.quantumvoid.org/volumedata/",
        "data_source_exchange": "bybit"
    },
    "bot": {
        "bot_name": "your_bot_name",
        "volume_check": false,
        "min_distance": 0.15,
        "min_volume": 10000,
        "upnl_profit_pct": 0.0029,
        "max_upnl_profit_pct": 0.0040,
        "auto_reduce_enabled": false,
        "auto_reduce_start_pct": 0.068,
        "entry_during_autoreduce": false,
        "stoploss_enabled": false,
        "stoploss_upnl_pct": 0.05,
        "liq_stoploss_enabled": false,
        "liq_price_stop_pct": 0.50,
        "percentile_auto_reduce_enabled": false,
        "upnl_threshold_pct": 0.50,
        "max_pos_balance_pct": 0.50,
        "auto_reduce_wallet_exposure_pct": 0.20,
        "auto_reduce_maxloss_pct": 0.30,
        "auto_reduce_marginbased_enabled": false,
        "hedge_ratio": 0.10,
        "hedge_price_difference_threshold": 0.10,
        "test_orders_enabled": false,
        "max_usd_value": 50,
        "min_qty_threshold": 0,
        "MaxAbsFundingRate": 0.0002,
        "blacklist": ["BTCUSDT", "ETHUSDT"],
        "whitelist": [],
        "dashboard_enabled": false,
        "shared_data_path": "data/",
        "linear_grid": {
            "grid_behavior": "infinite",
            "drawdown_behavior": "maxqtypercent",
            "target_coins_mode": false,
            "auto_graceful_stop": false,
            "entry_signal_type": "lorentzian",
            "additional_entries_from_signal": true,
            "graceful_stop_long": false,
            "graceful_stop_short": false,
            "max_qty_percent_long": 30,
            "max_qty_percent_short": 30,
            "auto_reduce_cooldown_enabled": false,
            "auto_reduce_cooldown_start_pct": 0.051,
            "wallet_exposure_limit_long": 0.006,
            "wallet_exposure_limit_short": 0.002,
            "levels": 4,
            "strength": 1.4,
            "min_outer_price_distance": 0.019,
            "max_outer_price_distance_long": 0.039,
            "max_outer_price_distance_short": 0.049,
            "long_mode": true,
            "short_mode": true,
            "reissue_threshold": 0.001,
            "buffer_percentage": 0.10,
            "initial_entry_buffer_pct": 0.0001,
            "min_buffer_percentage": 0.0035,
            "max_buffer_percentage": 0.010,
            "enforce_full_grid": true,
            "min_buffer_percentage_ar": 0.002,
            "max_buffer_percentage_ar": 0.004,
            "upnl_auto_reduce_threshold_long": 30.0,
            "upnl_auto_reduce_threshold_short": 30.0,
            "failsafe_enabled": false,
            "failsafe_start_pct": 0.07,
            "long_failsafe_upnl_pct": 10.0,
            "short_failsafe_upnl_pct": 10.0,
            "stop_loss_enabled": true,
            "stop_loss_long": 15.0,
            "stop_loss_short": 15.0
        },
        "hotkeys": {
            "hotkeys_enabled": false,
            "enter_long": "1",
            "take_profit_long": "2",
            "enter_short": "3",
            "take_profit_short": "4"
        }
    },
    "exchanges": [
        {
          "name": "bybit",
          "account_name": "account_1",
          "symbols_allowed": 10
        },
        {
            "name": "bybit_spot",
            "account_name": "account_2",
            "symbols_allowed": 5
        },
        {
            "name": "bybit_unified",
            "account_name": "account_3",
            "symbols_allowed": 5
        }
    ],
    "logger": {
        "level": "info"
    },
    "messengers": {
        "discord": {
            "active": false,
            "embedded_messages": true,
            "messenger_type": "discord",
            "webhook_url": "https://discord.com/api/webhooks/your_webhook_id/your_webhook_token"
        },
        "telegram": {
            "active": false,
            "embedded_messages": true,
            "messenger_type": "telegram",
            "bot_token": "your_bot_token",
            "chat_id": "your_chat_id"
        }
    }
  }