Git Product home page Git Product logo

orderbook-synchronizer's Introduction

Orderbook Synchronizer

DeepScan grade npm npm Coverage Status

This package allow you to keep update your Orderbook snapshot from a given Websocket source of Orders.

Features:

  • Orderbook size limit available to avoid overgrow
  • Lightweight / No dependency
  • Handle Bid/Ask overlaps, best Ask always higher or equal with best Bids

Orderbook output sample(.getOrderBook()):

{
      asks: [
        [8000, 1.9869372781826433],
        [8001, 0.6590219188159661],
        [8002, 1.0430790809329253],
        [8003, 0.1279416255016304],
        [8004, 1.3397780002928084],
        [8005, 1.8250517469118535],
      ],
      bids: [
        [6020, 1.5764351751676466],
        [6019, 1.9678679870588733],
        [6018, 1.7349295266546774],
        [6017, 1.0087743314824977],
        [6016, 0.0942339070977258],
      ]
}

Imports:

import {OrderBookStore} from 'orderbook-synchronizer'; // Multiple OrderBooks in a single class
import {Orderbook} from 'orderbook-synchronizer'; // Single OrderBook

Available methods(OrderBookStore):

Constructor:

const OrderBooks = new OrderBookStore(1000); // Set memory limit / maximum length of Ask/Bid array

updateOrderBook:

OrderBooks.updateOrderBook('BTC/USD', asks: Order[], bids: Order[]); // Create/Update Orderbook

hasOrderBook:

OrderBooks.hasOrderBook('BTC/USD'); // return boolean if Orderbook exist

getOrderBook:

OrderBooks.getOrderBook('BTC/USD'); // return Orderbook | undefined depends on Orderbook exist

getSymbolList:

OrderBooks.getSymbolList(); // return all Orderbook keys in array ['BTC/USD']

Available methods(Orderbook):

Constructor:

const SingleOrderBook = new Orderbook(1000); // Set memory limit / maximum length of Ask/Bid array

getOrderBook:

SingleOrderBook.getOrderBook(); // return Orderbook

updateOrderBook:

SingleOrderBook.updateOrderBook(asks: Order[], bids: Order[]); // Update Orderbook

Original inspiration source:

orderbook-synchronizer's People

Contributors

valamidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tacyarg trasherdk

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.