Skip to content

Bot Configuration

The TradeHub scripting environment allows you to dynamically configure your bot using the config.set() function.
Each configuration option has a built-in validator to ensure safe and valid values.


Use the config.set() method to set one or multiple configuration values:

// Example: Set multiple configs at once
config.set({
warmupPeriod: 10,
timeout: 15,
log: true,
takeProfit: 5,
stopLoss: 2
})

Each key is validated automatically. Invalid values are rejected and will not overwrite existing settings.


Skip the warmup period number of candles during backtesting to avoid unreliable signals, since indicators need sufficient historical data to initialize properly (e.g., SMA(20) requires 20 candles before producing valid output).

  • Type: Integer
  • Default: 14
  • Min: 1
  • Usage:
config.set({ warmupPeriod: 20 })

Maximum time (in seconds) allowed for updates or operations before timeout.

  • Type: Integer
  • Min: 5
  • Usage:
config.set({ timeout: 30 })

Enables or disables logging within the bot script.

  • Type: Boolean (true or false)
  • Usage:
config.set({ log: true }) // Enable logs
config.set({ log: false }) // Disable logs

Percentage-based target to automatically secure profits.

  • Type: Number (0–100)
  • Usage:
config.set({ takeProfit: 5 }) // Take profit at +5%

Percentage-based limit to minimize losses.

  • Type: Number (0–100)
  • Usage:
config.set({ stopLoss: 2 }) // Stop loss at -2%

Sets the decimal precision for order amounts or prices.

  • Type: Integer (0–8)
  • Usage:
config.set({ precision: 4 })

Limits the maximum number of simultaneously open orders.

  • Type: Number
  • Usage:
config.set({ maxOpenOrder: 3 })

Determines when the script update function is triggered:

  • "tick" – Update on every price tick

  • "candle" – Update once per candle close

  • Usage:

config.set({ updateTrigger: "candle" })

Sets the starting quote balance (only for backtest or paper mode).

  • Type: Number
  • Usage:
config.set({ balance: 1000 }) // Set quote balance to 1000 USDT

Sets the starting base balance (only for backtest or paper mode).

  • Type: Number
  • Usage:
config.set({ baseBalance: 0.5 }) // Set base balance to 0.5 BTC

Each config option:

  • Is automatically checked for type and range validity.
  • Will not update if validation fails.
  • Returns silently if invalid (use logging to confirm).

config.set({
warmupPeriod: 15,
timeout: 20,
log: true,
takeProfit: 4,
stopLoss: 2,
precision: 4,
maxOpenOrder: 5,
updateTrigger: "candle",
balance: 2000,
baseBalance: 0.3
})

This example configures a bot with preloaded data, logging enabled, basic risk settings, and balances for backtesting.