The account book to record the match of order asks and bids.
npm install order-match

The account book to record the match of order asks and bids.
``sh`
$ npm i order-match
`js
const OrderMatch = require('order-match')
const om = new OrderMatch()
`
Creates an acount book of asks and bids
- price numbernumber
- amount
Ask a price
Bid with a price
Returns the plan against the resistance if we want to reach the price level.undefined
- which indicates there is no resistance.Object
- Enum
- action Array<{price, amount}>
- orders
`js
const om = new OrderMatch()
om.ask(100, 50)
om.ask(120, 10)
// Then the asks are:
// price: 120, amount: 10
// price: 100, amount: 50
const plan = om.resistance(130)
console.log(plan.action)
// BID, we need bid orders to buy the asks
console.log(plan.orders)
// [
// {price: 100, amount: 50},
// {price: 120, amount: 50}
// ]
`
Get the current price. The initial price is 0.
Get current asks which is an ascending array of {price, amount} ordered by price
Get current bids which is an decendng array of {price, amount} ordered by price
- e.price number the actual price of the tradenumber
- e.amount the amount of the tradeEnum
- e.type
`js``
om.on('trade', e => {
console.log()
})
MIT