Logo

hw98_console_prompt.avif Backtesting trading strategies on historical data

Reliable portfolio backtesting. Quant research level quant

hamster-bot/tester - Advanced tool for testing your trading systems on historical data.

    hw98_console_prompt.avif Backtester features:
  • Run multiple strategy types across different timeframes simultaneously.
  • All of this with a shared balance, to understand how strategies coexist in one wallet in real time.
  • Tick data support. Simulates strategy behavior inside a candle as in live trading.
  • No limits on input market data. Run tests for any historical period.
  • Test complex custom logic that cannot be accurately tested with off-the-shelf solutions without workarounds.
  • Backtests run on the same production code used by the bot in real time.

Implemented as a separate connector hw98_console_prompt.avif to an "exchange" (a Mock object replacing the real exchange). This makes it possible to test all previously written bot code. The bot thinks it is connected to a real exchange (places orders, receives balances and position info). The virtual exchange stub performs all calculations and generates the report.

hw98_console_prompt.avif Market data for testing

Crypto exchanges publicly share historical market data. Examples: public.bybit.com, data.binance.vision, public.bitmex.com.
The tester downloads the required trade data range and builds candles for the bot. Before the test starts, the tester also downloads extra data to warm up all TA indicators used by the strategy.
Data is saved to hw98_console_prompt.avif folder tester/data/{symbol}. You can also put your own data in CSV format into this folder.


hw98_console_prompt.avif Tester behavior

From the bot’s perspective, the tester is just another exchange. The bot connects to it and starts receiving candles, placing orders, etc. Meanwhile, the tester simply emulates real exchange behavior.
Balance is shared across all strategies. Behavior is similar to BYBIT/BINANCE futures with cross margin. The bot can request Wallet or Margin balance. Margin balance is calculated including all open positions and their unrealized PnL.
Real price behavior. When the bot requests the current unfinished candle, the tester returns trade prices from tick data (until market data inside the candle is exhausted and then moves to the next candle). This allows strategies that depend on intrabar pricing (for example, slippage, trailing stops, etc.) to work correctly.


hw98_console_prompt.avif Report

After testing is complete, a detailed HTML report is saved to hw98_console_prompt.avif folder tester/report.
A record is also added to reports_history.csv with summary test info, so you can quickly find the best parameter combinations during optimization.

    Report includes:
  • Overall metrics for the entire trading system:
    • Starting and ending balance
    • Total profit/loss in USDT and %
    • Maximum drawdown
    • Number of trades
    • Win rate
    • Profit Factor
    Hamster Bot Backtesting
  • Separate candlestick charts for each strategy, with trade markers and strategy TA visualization. Hamster Bot Backtesting
  • Margin balance chart (including all open positions and unrealized PnL) and Wallet balance chart. Hamster Bot Backtesting
  • Chart showing the total size of open positions in USDT (and a separate-axis % line showing the ratio of total open positions to Margin balance)Hamster Bot Backtesting
  • Tables with full trade lists for each strategy. Hamster Bot Backtesting
  • List of strategy settings and tester parameters.
  • Summary information across all strategies. Trading volume and paid commissions.Hamster Bot Backtesting


hw98_console_prompt.avif Tester parameters

file: config_tester.json You can edit this file in any text editor.
name_comment - comment for the test, helps navigate reports
InitialBalance - initial balance for backtesting
StartDate - backtest start date in format 2026-02-03T00:00:00
EndDate - backtest end date in format 2026-02-13T00:00:00
WarmupDays - number of warmup days before the backtest starts
MakerFee - maker fee (0.0001 = 0.01%). Standard BYBIT fee: 0.00036 = 0.0360%. (guide to reduce fees significantly)
TakerFee - taker fee (0.0001 = 0.01%)
SlippagePercent - slippage for market orders (0.0001 = 0.01%)
UpdateData - update data before backtesting (true/false)
use_logger - use logger. If disabled, backtesting runs faster (true/false)
max_parallel_runs - number of parallel tester runs during parameter optimization. If your hardware allows it, this can parallelize runs without slowing individual calculations.

Hamster Bot Backtesting

file: config_tester.json/report Report content settings:
chart_ohlc_height - OHLC chart height in pixels
chart_balance_height - balance chart height in pixels
chart_position_height - open position size chart height in pixels
include_chart_ohlc - include OHLC chart in report (true/false)
include_chart_balance - include balance chart in report (true/false)
include_chart_position - include open position size chart in report (true/false)
include_strategy_settings - include strategy settings in report (true/false)

Hamster Bot Backtesting


hw98_console_prompt.avif Optimizer (parameter sweep)

file: config_tester.json/parameter_mining Optimizer settings:
By default this is an empty list []. Fill it with entries like {"name":"parameter_name", "start": 1, "end": 10, "step": 0.1, "values": ["string1", "string2"]}

name - parameter name to optimize. You can target almost any bot setting. The bot has 4 config groups.
1) Strategy settings (.json files in settings_strategy). Here you configure symbol, timeframe, deposit handling, and strategy-specific options.
Example: settings[*].mrs2.ma_long.type - optimize type for strategy mrs2 entry order
2) Account API-key settings (.json files in settings_accounts). Here you configure account-wide margin take profit and max number of simultaneously open positions.
Example: account[*].close_by_margin.profit - optimize profit in close_by_margin
3) Global bot program settings (settings_program.json). Here you configure global options like risk multiplier.
Example: settings_program.risk_multiplier - optimize risk_multiplier
4) Global tester settings (config_tester.json). Here you can optimize tester parameters like commissions.
Example: config_tester.MakerFee - optimize MakerFee

start - start value
end - end value
step - increment step
values - list of string values to iterate. Used for string parameters, for example MA type ["SMA", "EMA"] or price source ["close", "open", "ohlc4"]. The same approach can be used to iterate trading pairs when testing one settings file at a time (a more convenient pair-sweep flow will be added later).

Hamster Bot Backtesting
If you optimize two parameters in the range 1..10 with step 1, the tester will run 100 combinations (10 variants of the first parameter * 10 variants of the second). Results are saved as separate HTML reports and in the summary table (reports_history.csv). This helps quickly find the best parameter combinations for your strategies.

Also, all bot strategies are available in PineScript format for backtesting on TradingView.