Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jondubois/proper-order-book
An efficient order book which supports market and limit orders with fast insertion and search.
https://github.com/jondubois/proper-order-book
Last synced: 12 days ago
JSON representation
An efficient order book which supports market and limit orders with fast insertion and search.
- Host: GitHub
- URL: https://github.com/jondubois/proper-order-book
- Owner: jondubois
- License: gpl-3.0
- Created: 2020-01-14T13:47:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-27T19:35:17.000Z (almost 4 years ago)
- Last Synced: 2024-11-07T15:09:28.150Z (2 months ago)
- Language: JavaScript
- Size: 48.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# proper-order-book
An efficient order book which supports market and limit orders with fast insertion and search.This order book was designed with decentralized exchanges (DEXs) in mind.
### Usage
```js
const ProperOrderBook = require('proper-order-book');let orderBook = new ProperOrderBook();
orderBook.add({
id: `ask0`,
type: 'limit',
price: .5,
targetChain: 'lsk',
targetWalletAddress: '22245678912345678222L',
senderId: '11111111111222222222L',
side: 'ask',
size: 100
});let result = orderBook.add({
id: `bid0`,
type: 'limit',
price: .5,
targetChain: 'clsk',
targetWalletAddress: '22245678912345678222L',
senderId: '11111111111222222222L',
side: 'bid',
value: 10
});console.log(result);
``````js
{ taker:
{ id: 'bid0',
type: 'limit',
price: 0.5,
targetChain: 'clsk',
targetWalletAddress: '22245678912345678222L',
senderId: '11111111111222222222L',
side: 'bid',
value: 10,
valueRemaining: 0,
lastSizeTaken: 0,
lastValueTaken: 0 },
makers:
[ { id: 'ask0',
type: 'limit',
price: 0.5,
targetChain: 'lsk',
targetWalletAddress: '22245678912345678222L',
senderId: '11111111111222222222L',
side: 'ask',
size: 100,
sizeRemaining: 80,
lastSizeTaken: 20,
lastValueTaken: 10 } ],
takeSize: 20,
takeValue: 10 }
```### Testing
```
npm test
```### License
Licensed under GPLv3: http://www.gnu.org/licenses/gpl-3.0.html