Elevate your trading strategies with BacktestJS, the premier CLI tool designed for traders and developers alike. Harness the power of Typescript or Javascript to backtest your strategies with precision, efficiency, and flexibility.
Β
-
π₯οΈ Streamlined CLI Interface: Intuitive command-line interface for streamlined operation.
-
π Candle Data at Your Fingertips: Download historical candle data directly from Binance or import your own from CSV files.
-
ποΈ Seamless SQLite Integration: Efficient storage for your candle data, strategies, and results (no coding required).
-
π Extensive Documentation: Unlock the full potential of BacktestJS with detailed guides and resources.
Β
Follow these one time instructions below to setup the environment.
git clone https://github.com/andrewbaronick/BacktestJS.git
cd BacktestJS
npm i
Enter the world of strategic backtesting with a single command:
npm start
Β
Immerse yourself in the BacktestJS universe with our Full Documentation. Discover tutorials, video guides, and extensive examples. Engage with our community forum for unparalleled support and discussions. Visit our site to unleash the full capabilities of BacktestJS.
Β
Effortlessly download candle data from Binance or import from a CSV for strategy execution β no coding required! Plus, easily export your data to CSV via the CLI at anytime with a few clicks.
Β
Below is an example of a simple 3 over 45 SMA strategy. You buy once the 3 crosses the 45 and sell if not. In this example we dont use the power of params.
import { BTH } from "../infra/interfaces"
import { indicatorSMA } from "../indicators/moving-averages"
export async function sma(bth: BTH) {
// Get Candles
const lowSMACandles = await bth.getCandles('close', 0, 3)
const highSMACandles = await bth.getCandles('close', 0, 45)
// Get SMA
const lowSMA = await indicatorSMA(lowSMACandles, 3)
const highSMA = await indicatorSMA(highSMACandles, 45)
// Perform Buy / Sell when low crosses high
if (lowSMA > highSMA) {
await bth.buy()
} else {
await bth.sell()
}
}
Below is an example of a simple SMA strategy like above but its not hard coded to the 3 over 45. When you run the strategy through the CLI you will be asked to provide a low and high sma. You can even provide multiple lows and multiple highs and all the variations will be tested in one shot.
import { BTH } from "../infra/interfaces"
import { indicatorSMA } from "../indicators/moving-averages"
export async function sma(bth: BTH) {
// Get low and high SMA from input
const lowSMAInput = bth.params.lowSMA
const highSMAInput = bth.params.highSMA
// Get Candles
const lowSMACandles = await bth.getCandles('close', 0, lowSMAInput)
const highSMACandles = await bth.getCandles('close', 0, highSMAInput)
// Get SMA
const lowSMA = await indicatorSMA(lowSMACandles, lowSMAInput)
const highSMA = await indicatorSMA(highSMACandles, highSMAInput)
// Perform Buy / Sell when low crosses high
if (lowSMA > highSMA) {
await bth.buy()
} else {
await bth.sell()
}
}
Β
BacktestJS not only delivers performance insights but also visualizes your strategy's effectiveness through comprehensive charts and statistics.
Explore the visual representation of your trading outcomes, from income results to buy/sell locations, offering you a clear view of your strategy's performance.
Examine permutation results and heatmap visualizations to refine your strategies across different values all in one run.
See if that killer strategy works across the board on many symbols and timeframes with ease. Get all your results in one shot with blazing fast results.
Β