Skip to content
/ mextick Public

Parse historical trade data into ticks and aggregate trade bin events

Notifications You must be signed in to change notification settings

azidyn/mextick

Repository files navigation

mextick

Simple example of how to parse historical trade data and emit ticks and aggregate trade bin events (i.e. candlestick bars)

This could be the basis needed to build a very accurate backtesting system able to process intrabar price tick events.

Update: added volume to the output bars.

How to use

First thing you need is some trade data which can be downloaded for free as .csv.gz (zipped csv files) found on BitMEX's public cloud archive here:

https://public.bitmex.com/?prefix=data/trade/ IMPORTANT NOTE THIS WEBSITE ONLY SEEMS TO WORK ON THE Chrome WEB BROWSER

Download the files and unzip the CSVs into the trade folder.

Install the dependency

npm install

Import the module:

    const Aggregate = require('./Aggregate');

Instantiate the object, passing:

  1. the folder containing the csv files you downloaded
  2. the bar resolution you want e.g. 1h, 4h, 15m etc (see Aggregate.js for more info)
let agg = new Aggregate({ files: './trade', resolution: '1h' });

Then subscribe to the events, both optional, that the Aggregate class will fire:

    agg.on('bar', bar => { /* do whatever with your bar */ });

    agg.on('tick', tick => { /* do whatever with your tick */ });

Finally, start the system, specifying which symbol you're interested in. Note that all of the BitMEX symbols are supported!:

    agg.start('ETHUSD');

Notes:

The system processes every single file in the trade folder in order.

About

Parse historical trade data into ticks and aggregate trade bin events

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages