innblockchain-exchange-matching-engine
v1.0.1
Published
A Light Weight Matching Engine for Crypto Exchange
Downloads
5
Maintainers
Readme
InnblockchainExchangeMatchingEngine
A Light Weight Matching Engine for Crypto Exchange
Installation
$ npm i innblockchain-exchange-matching-engine --save
Usage
import { MatchingEngine, OrderSide } from 'innblockchain-exchange-matching-engine';
const matchingEngine = new MatchingEngine();
/**
* Place New Order (Instrument, Price, Quantity, Side)
*/
matchingEngine.newOrder('Instrument', 12.5, 5, OrderSide.buy);
/**
* Trade Order
*/
matchingEngine.newOrder('Instrument', 12.5, 5, OrderSide.sell);
/**
* Cancel Order (Order Id, Instrument)
*/
const orderResponse = matchingEngine.newOrder('Instrument', 12.5, 5, OrderSide.sell);
const order = orderResponse.data.order;
matchingEngine.cancelOrder(order.orderId, order.instrument);