A grid trading strategy backtester using historical Binance data.
The backtester simulates buying cryptocurrency when the price drops by a set threshold from the peak price, and selling when it rises by the same threshold.
The system tracks max_price, the highest price since the last completed cycle. A buy is triggered when the price drops by the configured threshold percentage from max_price. Each level is bought only once. At a 5% threshold, for example, there can be up to 19 purchase levels, ranging from 5% to 95% below the peak. The grid resets when all positions are closed, and max_price is updated to the current price.
Each buy creates a sell order at buy_price × (1 + threshold). When the target price is reached, the position is closed and the profit is realized.
The backtester supports:
Initial balance
Trade amount
Price change threshold
Commission rate
Trading pair, such as ETHUSDT
Candle time interval
Backend: Python, FastAPI, aiohttp for asynchronous Binance API requests
Frontend: React, Vite, Recharts