Giter Club home page Giter Club logo

candle-collector's Introduction

candle-collector

Collects markets prices, aggregate them into OHLC buckets and make them available over HTTP.

Markets and timeframes are just entries in the database. Please see sql-data/V1_1__Add_timeframes_and_pairs.sql.

Markets prices are fetched directly on the exchange. Currently, only one exchange is available: Poloniex.

Setup

Prerequisites:

  • NodeJs v8.9.3
  • RabbitMQ 3.6.4
  • MySQL v5.7.21
  • Flyway v5.0.7

Environment variables:

export CANDLE_COLLECTOR_MYSQL_USER="root"
export CANDLE_COLLECTOR_MYSQL_PASS=""
export CANDLE_COLLECTOR_MYSQL_HOST='localhost'
export CANDLE_COLLECTOR_MYSQL_PORT=3306
export CANDLE_COLLECTOR_MYSQL_DATABASE='candle_collector'

export CANDLE_COLLECTOR_PORT=8080

export CANDLE_COLLECTOR_AMQP_HOST="localhost"
export CANDLE_COLLECTOR_AMQP_PORT=5672
export CANDLE_COLLECTOR_AMQP_USER="guest"
export CANDLE_COLLECTOR_AMQP_PASS="guest"

Start the API:

// Start API
npm run api
// Start candle collector
npm run collector
// Start workers:
npm run worker:save-candle

Or you can start all the services at once using Forever

Start collecting candles:

npm run collector

"REST" API:

Method Path Description
GET /timeframes Get available timeframes
GET /pairs Get collected pairs
GET /candles Get collected candles

Errors have to following format:

{
  "code": 2,
  "message": "Error message"
}

Errors codes:

Name Code Status
INTERNAL_ERROR 1 500
NOT_FOUND 2 404
INVALID_PARAMETERS 3 400
MISSING_PARAMETERS 4 400

GET /timeframes

$> http GET localhost:8080/timeframes

HTTP/1.1 200 OK
[
    {
        "unit": "minute",
        "value": 1
    }
]

GET /pairs

Query parameters:

Name Required Description
exchange no Filter by exchange
$> http GET localhost:8080/pairs

HTTP/1.1 200 OK
[
    {
        "base": "ETH",
        "decimals": 8,
        "exchange": "poloniex",
        "quote": "BTC"
    }
]

GET /candles

Query parameters:

Name Required Description
exchange yes Exchange name
pair yes Pair you want (format: {BASE}_{QUOTE})
timeframe yes Timeframe you want (format: {VALUE}_{UNIT})

Errors:

  • INVALID_PARAMETERS: Parameter doesn't conform to pair/timeframe's format
  • MISSING_PARAMETERS: Missing query parameter
  • NOT_FOUND: Pair/exchange/timeframe not found
$> http GET localhost:8080/candles exchange==poloniex pair==ETH_BTC timeframe==1_minute

HTTP/1.1 200 OK
[
    {
        "close": "0.08667571",
        "date": "2018-02-25T11:29:00.000Z",
        "high": "0.08683594",
        "low": "0.0866757",
        "open": "0.08671316",
        "volume": "95.5340148"
    },
    ...
]

Licence

See the LICENSE file for license rights and limitations (MIT).

candle-collector's People

Contributors

jspdown avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.