To run the script using Docker, execute ./start.sh
. Alternatively, you can run it using bun start
. Add the credentials to your users creating userSeed.ts according userSeed.example.ts
There are two types of back-testing: Snapshot and Accumulate.
Snapshot back-testing analyzes the pattern of look-back candles, simulates an entry, and evaluates if it wins or loses within the maximum candle length of the next candles. No context about other possible entries is considered. Positions are overlapping, and values like the Sharpe ratio do not make sense.
Accumulate back-testing is oriented toward a more realistic situation where the maximum number of open positions is considered.
- Run
bun DBRestart
to create the local database or clear old data. - Select the amount of time you want for back-testing in
src/Params.lookBackLengthBacktest
in milliseconds (e.g.,(7 * Interval["1d"]) / Interval["5m"]
for 7 days). You can check other parameters here. - Run
bun saveBacktestData
to get the candlestick data for every available symbol from the Binance API. - Check the data by running
bun showBacktestData
. - Fill the
/src/strategies/index.ts/chosenStrategies
array with strategies to test. - Ensure that every strategy in
/src/strategies
hasALLOWED_PAIRS=[]
as desired. - Run
bun saveAccStats
to save statistics to define values for take profit, stop loss, and max trade length. - Check the results by running
bun showAccStats
. - Run
bun saveSnapStats
to save stats for this strategy and define winning symbols. - Run
bun showSnapStats
to see the winning symbols list.
- Add a new file in
/src/strategies
accordingstrategy.example.ts
withsl: params.defaultSL
,tp: params.defaultTP
andALLOWED_PAIRS=[]
- Fill the
/src/strategies/index.ts/chosenStrategies
only with the new strategy. - Go to
src/Params
and set values forbacktestSLArray
,backtestTPArray
,backtestMaxTradeLengthArray
with options to test. - Run
bun saveSnapStats
andbun saveAccStats
and analyze results usingbun showSnapStats
bun showAccStats
. - Go to
src/Params
and set values forbacktestSLArray
,backtestTPArray
,backtestMaxTradeLengthArray
only with the chosen options. - Go to the new strategy file and set values for
sl
,tp
with the chosen options. - Run
bun saveSnapStats
- In the new strategy file set values for
ALLOWED_PAIRS
with the winning symbols result. - Optionally run
bun saveAccStats
again to see the final stats.