All Projects → Grademark → Grademark

Grademark / Grademark

Licence: mit
An API for backtesting trading strategies in JavaScript and TypeScript.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Grademark

Quant
Codera Quant is a Java framework for algorithmic trading strategies development, execution and backtesting via Interactive Brokers TWS API or other brokers API
Stars: ✭ 104 (-25.71%)
Mutual labels:  trading, algorithmic-trading, trading-strategies, quantitative-trading
Sgx Full Orderbook Tick Data Trading Strategy
Providing the solutions for high-frequency trading (HFT) strategies using data science approaches (Machine Learning) on Full Orderbook Tick Data.
Stars: ✭ 733 (+423.57%)
Mutual labels:  trading, algorithmic-trading, trading-strategies, quantitative-trading
Abu
阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构
Stars: ✭ 8,589 (+6035%)
Mutual labels:  trade, trading, algorithmic-trading, quantitative-trading
AutoTrader
A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
Stars: ✭ 227 (+62.14%)
Mutual labels:  trading, trading-strategies, algorithmic-trading, quantitative-trading
Turingtrader
The Open-Source Backtesting Engine/ Market Simulator by Bertram Solutions.
Stars: ✭ 132 (-5.71%)
Mutual labels:  trading, algorithmic-trading, trading-strategies, quantitative-trading
Jesse
An advanced crypto trading bot written in Python
Stars: ✭ 1,038 (+641.43%)
Mutual labels:  trade, trading, algorithmic-trading, trading-strategies
Kupi Terminal
Ccxt based, open source, customized, extendable trading platform that supports 130+ crypto exchanges.
Stars: ✭ 104 (-25.71%)
Mutual labels:  trade, trading, trading-strategies
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (-24.29%)
Mutual labels:  trading, trading-strategies, quantitative-trading
Zvt
modular quant framework.
Stars: ✭ 1,801 (+1186.43%)
Mutual labels:  algorithmic-trading, trading-strategies, quantitative-trading
Aat
Asynchronous, event-driven algorithmic trading in Python and C++
Stars: ✭ 109 (-22.14%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Awesome Algorithmic Trading
A curated list of awesome algorithmic trading frameworks, libraries, software and resources
Stars: ✭ 328 (+134.29%)
Mutual labels:  trading, trading-strategies, quantitative-trading
Introneuralnetworks
Introducing neural networks to predict stock prices
Stars: ✭ 486 (+247.14%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Quant Trading
Python quantitative trading strategies including VIX Calculator, Pattern Recognition, Commodity Trading Advisor, Monte Carlo, Options Straddle, Shooting Star, London Breakout, Heikin-Ashi, Pair Trading, RSI, Bollinger Bands, Parabolic SAR, Dual Thrust, Awesome, MACD
Stars: ✭ 2,407 (+1619.29%)
Mutual labels:  algorithmic-trading, trading-strategies, quantitative-trading
Quantdom
Python-based framework for backtesting trading strategies & analyzing financial markets [GUI ]
Stars: ✭ 449 (+220.71%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Quantitative Notebooks
Educational notebooks on quantitative finance, algorithmic trading, financial modelling and investment strategy
Stars: ✭ 356 (+154.29%)
Mutual labels:  algorithmic-trading, trading-strategies, quantitative-trading
Wolfbot
Crypto currency trading bot written in TypeScript for NodeJS
Stars: ✭ 335 (+139.29%)
Mutual labels:  trade, trading, trading-strategies
Roq Api
API for algorithmic and high-frequency trading
Stars: ✭ 132 (-5.71%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Crypto Signal
Github.com/CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 3,100+ stars, 900+ forks
Stars: ✭ 3,690 (+2535.71%)
Mutual labels:  trading, trading-strategies, algorithmic-trading
51bitquant
51bitquant Python数字货币量化交易视频 CCXT框架 爬取交易所数据 比特币量化交易 交易机器人51bitquant tradingbot cryptocurrency quantitative trading btc trading
Stars: ✭ 284 (+102.86%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Vectorbt
Ultimate Python library for time series analysis and backtesting at scale
Stars: ✭ 855 (+510.71%)
Mutual labels:  trading, algorithmic-trading, trading-strategies

Grademark

Toolkit for algo trading and backtesting in JavaScript and TypeScript.

This API builds on Data-Forge and is best used from Data-Forge Notebook (making it easy to plot charts and visualize).

Check out the release notes to see updates and breaking changes.

Follow the developer on Twitter

Click here to support the developer.

Please see what this looks like in the Grademark first example and the unit tests in this repo.

Love this? Please star this repo!

First example

From the Grademark first example here's some example output. Click to see the first example as a notebook.

Analysis of a sequence of trades looks like this:

Analysis of trades screenshot

Here's a chart that visualizes the equity curve for the example strategy:

Equity curve

Here's another chart, this one is a visualization of the drawdown for the example strategy:

Drawdown

Pre-requisites

  • Make sure your data is sorted in forward chronological order.

Data format

Your data needs to be loaded into memory in the following format:

interface IBar {
    time: Date;
    open: number;
    high: number;
    low: number;
    close: number;
}

const data: IBar[] = ... load your data ...

Features

  • Define a trading strategy with entry and exit rules.
  • Backtest a trading strategy on a single financial instrument.
  • Apply custom indicators to your input data series.
  • Specify lookback period.
  • Built-in intrabar stop loss.
  • Compute and plot equity curve and drawdown charts.
  • Throughly covered by automated tests.
  • Calculation of risk and rmultiples.
  • Intrabar profit target.
  • Intrabar trailing stop loss.
  • Conditional buy on price level (intrabar).
  • Monte carlo simulation.
  • Multiple parameter optimization based on permutations of parameters (using grid search and hill-climb algorithms).
  • Walk forward optimization and backtesting.
  • Plot a chart of trailing stop loss.
  • Short selling.

Data-Forge Notebook comes with example JavaScript notebooks that demonstrate many of these features.

If you need help with new features please reach out!

Maybe coming later

  • Support for precise decimal numbers.
  • Fees.
  • Slippage.
  • Position sizing.
  • Testing multiple instruments / portfolio simulation / ranking instruments.
  • Market filters.

Complete examples

For a ready to go example please see the repo grademark-first-example.

Usage

Instructions here are for JavaScript, but this library is written in TypeScript and so it can also be used from TypeScript.

Installation

npm install --save grademark

Import modules

const dataForge = require('data-forge');
require('data-forge-fs'); // For file loading capability.
require('data-forge-indicators'); // For the moving average indicator.
require('data-forge-plot'); // For rendering charts.
const { backtest, analyze, computeEquityCurve, computeDrawdown } = require('grademark');

Load your data

Use Data-Forge to load and prep your data, make sure your data is sorted in forward chronological order.

This example loads a CSV file, but feel free to load your data from REST API, database or wherever you want!

let inputSeries = dataForge.readFileSync("STW.csv")
    .parseCSV()
    .parseDates("date", "D/MM/YYYY")
    .parseFloats(["open", "high", "low", "close", "volume"])
    .setIndex("date") // Index so we can later merge on date.
    .renameSeries({ date: "time" });

The example data file is available in the example repo.

Add indicators

Add whatever indicators and signals you want to your data.

const movingAverage = inputSeries
    .deflate(bar => bar.close)          // Extract closing price series.
    .sma(30);                           // 30 day moving average.

inputSeries = inputSeries
    .withSeries("sma", movingAverage)   // Integrate moving average into data, indexed on date.
    .skip(30)                           // Skip blank sma entries.

Create a strategy

This is a very simple and very naive mean reversion strategy:

const strategy = {
    entryRule: (enterPosition, args) => {
        if (args.bar.close < args.bar.sma) { // Buy when price is below average.
            enterPosition({ direction: "long" }); // Long is default, pass in "short" to short sell.
        }
    },

    exitRule: (exitPosition, args) => {
        if (args.bar.close > args.bar.sma) {
            exitPosition(); // Sell when price is above average.
        }
    },

    stopLoss: args => { // Optional intrabar stop loss.
        return args.entryPrice * (5/100); // Stop out on 5% loss from entry price.
    },
};

Running a backtest

Backtest your strategy, then compute and print metrics:

const trades = backtest(strategy, inputSeries)
console.log("Made " + trades.length + " trades!");

const startingCapital = 10000;
const analysis = analyze(startingCapital, trades);
console.log(analysis);

Visualizing the results

Use Data-Forge Plot to visualize the equity curve and drawdown chart from your trading strategy:

computeEquityCurve(trades)
    .plot()
    .renderImage("output/my-equity-curve.png");

computeDrawdown(trades)
    .plot()
    .renderImage("output/my-drawdown.png");

Advanced backtesting

We are only just getting started in this example to learn more please follow my blog and YouTube channel.

Resources

Support the developer

Click here to support the developer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].