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.
🔧 How to Set Configurations
Section titled “🔧 How to Set Configurations”Use the config.set() method to set one or multiple configuration values:
// Example: Set multiple configs at onceconfig.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.
⚙️ Available Config Options
Section titled “⚙️ Available Config Options”1. warmupPeriod
Section titled “1. warmupPeriod”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 })2. timeout
Section titled “2. timeout”Maximum time (in seconds) allowed for updates or operations before timeout.
- Type: Integer
- Min:
5 - Usage:
config.set({ timeout: 30 })3. log
Section titled “3. log”Enables or disables logging within the bot script.
- Type: Boolean (
trueorfalse) - Usage:
config.set({ log: true }) // Enable logsconfig.set({ log: false }) // Disable logs4. takeProfit
Section titled “4. takeProfit”Percentage-based target to automatically secure profits.
- Type: Number (0–100)
- Usage:
config.set({ takeProfit: 5 }) // Take profit at +5%5. stopLoss
Section titled “5. stopLoss”Percentage-based limit to minimize losses.
- Type: Number (0–100)
- Usage:
config.set({ stopLoss: 2 }) // Stop loss at -2%6. precision
Section titled “6. precision”Sets the decimal precision for order amounts or prices.
- Type: Integer (0–8)
- Usage:
config.set({ precision: 4 })7. maxOpenOrder
Section titled “7. maxOpenOrder”Limits the maximum number of simultaneously open orders.
- Type: Number
- Usage:
config.set({ maxOpenOrder: 3 })8. updateTrigger
Section titled “8. updateTrigger”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" })9. balance
Section titled “9. balance”Sets the starting quote balance (only for backtest or paper mode).
- Type: Number
- Usage:
config.set({ balance: 1000 }) // Set quote balance to 1000 USDT10. baseBalance
Section titled “10. baseBalance”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🔒 Validation Rules
Section titled “🔒 Validation Rules”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).
✅ Example: Full Config Setup
Section titled “✅ Example: Full Config Setup”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.