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