Backtest Kit uses sensible defaults for all configuration — override only what you need. The configuration is global and process-wide; values set withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-docs/llms.txt
Use this file to discover all available pages before exploring further.
setConfig apply to every strategy, exchange, and frame registered in the same process.
setConfig(options)
Updates the global configuration. Accepts a partial object — only the keys you provide are changed; all others retain their defaults.Configuration Options
Slippage percentage applied to entry and exit prices, simulating market impact. Expressed as a percentage (e.g.
0.1 = 0.1%). Applied per side: once when the position opens and once when it closes. See the PnL formula below for how slippage affects the final result.Trading fee percentage applied to entry and exit prices. Expressed as a percentage (e.g.
0.1 = 0.1%). Applied per side like slippage. Represents the exchange maker/taker fee.Minutes before a scheduled signal (pending entry at a limit price) times out and is automatically cancelled. After this duration, the signal is discarded and the strategy returns to idle, free to generate a new signal. Set to a large value (e.g.
99999) for signals that should wait indefinitely.Number of 1-minute candles used to compute the VWAP price for all entry and exit decisions. Increasing this value smooths the VWAP over a longer window; decreasing it makes it more responsive to recent price action. Also used by
getAveragePrice().Time window in minutes for order book alignment.
getOrderBook() aligns the request to the nearest multiple of this value. For example, with CC_ORDER_BOOK_TIME_OFFSET_MINUTES = 10, a call at 00:12 UTC will align to the [00:00, 00:10) window.Default depth (number of bid/ask levels) passed to the exchange adapter’s
getOrderBook implementation when depth is not explicitly provided to getOrderBook().Time window in minutes for a single
getAggregatedTrades fetch page. When paginating (with a limit argument), the function fetches in chunks of this width, going backwards until enough trades are collected.setLogger(options)
Plugs in a custom logging implementation. The framework adds context (strategy name, exchange name, symbol) to each log message automatically. CallingsetLogger before any other setup ensures all internal lifecycle messages are captured.
General-purpose log function. Used for important state changes and lifecycle events (position opened, signal persisted, etc.).
Debug-level log function. Used for detailed internal events (candle alignment calculations, cache hits/misses, etc.). Safe to set to a no-op in production.
Info-level log function. Used for successful high-level operations (schema registered, backtest started, etc.).
Warning-level log function. Used for recoverable anomalies (signal rejected by validation, missing data, deprecated usage patterns).
Environment Variables (CLI / Docker)
When using@backtest-kit/cli or the Docker deployment, the following environment variables configure optional integrations. These are read at CLI startup, not via setConfig.
Telegram Bot API token. When set along with
CC_TELEGRAM_CHANNEL, the CLI sends formatted trade notifications (opened, closed, PnL) to the specified channel.Telegram channel username (e.g.
@my_trading_alerts) or numeric chat ID.Host to bind the
@backtest-kit/ui dashboard server to. Defaults to 0.0.0.0.Port for the
@backtest-kit/ui dashboard server. Defaults to 8080.Base URL for the QuickChart service used to render candlestick chart images in Telegram notifications. Defaults to
https://quickchart.io. Set to a self-hosted instance for air-gapped deployments.PnL Calculation Formula
Backtest Kit applies slippage and fee to both entry and exit prices. The direction of slippage depends on the position side — slippage always works against the trader.priceOpenWithCosts = 1000 * (1 + 0.001 + 0.001) = 1002.00priceCloseWithCosts = 1100 * (1 - 0.001 - 0.001) = 1097.80pnlPercent = (1097.80 - 1002.00) / 1002.00 * 100 ≈ +9.56%
2 * (slippage + fee) = 0.4% with default settings. The getBreakeven(symbol, currentPrice) helper checks this threshold automatically.