Skip to content

Full and easy cli driven tool to get candle data and backtest any trading strategy you want!!

License

Notifications You must be signed in to change notification settings

andrewbaronick/BacktestJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitHub GitHub package.json version

Hits

πŸ“œ Description

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.

Β 

🌟 Key Features

  • πŸ–₯️ 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.

Β 

πŸš€ Quick Start

πŸ“¦ Setup Environment

Follow these one time instructions below to setup the environment.

  git clone https://github.com/andrewbaronick/BacktestJS.git
  cd BacktestJS
  npm i

🌈 Launch BacktestJS

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.

Β 

πŸ”„ Download / Import Historical Candle Data

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.

Β 

πŸ’‘ Examples

No Params

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()
    }
}

With Params

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()
    }
}

Β 

🎨 Showcase of Results

BacktestJS not only delivers performance insights but also visualizes your strategy's effectiveness through comprehensive charts and statistics.

πŸ† Income Results, Buy/Sell Locations, and More

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.

Income Results

Buy Sell Locations

General Info

Total Stats

All Orders

Trade Stats

Trade Buy Sell Stats

Asset Stats

πŸ” Multi Value Results

Examine permutation results and heatmap visualizations to refine your strategies across different values all in one run.

Permutation Results

Heatmap

General Info

Total Stats

🌍 Multi Symbol Results

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.

General Info

Total Stats

Permutation Results

Β 

✍️ Author

Andrew Baronick

Github
LinkedIn

About

Full and easy cli driven tool to get candle data and backtest any trading strategy you want!!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published