Coder Social home page Coder Social logo

ohlc-resampler's Introduction

ohlc-resampler

ohlc-resampler is a simple utility to transform trade data from Binance Cryptocurrency market data into OHLCV candles to simulate market behavior and test trading algorithms.

Binance data archives can be found here.

Word of warning!

At the moment this is very raw alpha version and cannot provide any guarantee in data correctness. Also no any further backwards compatibility guaranteed.

Compilation and installation

There is nothing special required to compile and run this software. It has no dependencies and uses only the standard library. Executable file will be saved in your $GOPATH/bin directory.

go build
go install

That's all.

Usage

ohlc-resampler reads data from stdin, similarly, output will be written to stdout. Errors are written to stderr.

ohlc-resampler timeframe n < input.csv
  • timeframe - time frame in string format like: 1m, 5m, 15m, 1h. See Go's time#ParseDuration.
  • n - number of candles, cannot be less than zero, otherwise fallback 20 will be used.

These two parameters are mandatory.

Output to stdout

Be aware that stream data can be very large. It can mess with your terminal and priting can take a lot of time.

ohlc-resampler 5m 20 < DOGEUSDT-trades-2022-10-26.csv

Redirect output to file

ohlc-resampler 5m 20 < DOGEUSDT-trades-2022-10-26.csv > output.csv

cURL example

You can combile cURL and other command line utilities to make interesing combinations like dowloading data from the web.

GNU/Linux

curl -s --output "-" https://data.binance.vision/data/spot/daily/trades/DOGEUSDT/DOGEUSDT-trades-2022-10-22.zip | gunzip | ohlc-resampler 5m 10 > out.csv

MacOS

curl -s --output "-" https://data.binance.vision/data/spot/daily/trades/DOGEUSDT/DOGEUSDT-trades-2022-10-22.zip | tar -x -O | ohlc-resampler 5m 10 > out.csv

Windows

I don't know how to do it on Windows.

Testing

go test

Coverage

go test -cover

With cover profile.

go test -coverprofile c.out
go tool cover -html c.out

Contribution

Any help is appreciated. Found a bug, typo, inaccuracy, etc? Please do not hesitate and make pull request or issue.

License

MIT 2022

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.