big-order-book 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -0
- package/package.json +2 -2
- package/test/index.js +55 -0
package/index.js
CHANGED
|
@@ -234,6 +234,7 @@ class BigOrderBook {
|
|
|
234
234
|
}
|
|
235
235
|
currentItem.detach();
|
|
236
236
|
this.bidCount--;
|
|
237
|
+
this.orderItemMap.delete(currentBid.id);
|
|
237
238
|
takeSize += this._convertValueToSize(currentBid.lastValueTaken, currentBid.price);
|
|
238
239
|
takeValue += currentBid.lastValueTaken;
|
|
239
240
|
priceOrderLinkedList.valueRemaining -= currentBid.lastValueTaken;
|
|
@@ -366,6 +367,7 @@ class BigOrderBook {
|
|
|
366
367
|
}
|
|
367
368
|
currentItem.detach();
|
|
368
369
|
this.askCount--;
|
|
370
|
+
this.orderItemMap.delete(currentAsk.id);
|
|
369
371
|
takeSize += currentAsk.lastSizeTaken;
|
|
370
372
|
takeValue += this._convertSizeToValue(currentAsk.lastSizeTaken, currentAsk.price);
|
|
371
373
|
priceOrderLinkedList.sizeRemaining -= currentAsk.lastSizeTaken;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "big-order-book",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "An efficient order book which supports market and limit orders with fast insertion and search - Works with the BigInt type.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"proper-skip-list": "^4.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"mocha": "^
|
|
30
|
+
"mocha": "^11.3.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/test/index.js
CHANGED
|
@@ -637,6 +637,61 @@ describe('BigOrderBook unit tests', async () => {
|
|
|
637
637
|
assert(result.makers[0].lastValueTaken === 1000n);
|
|
638
638
|
assert(result.makers[0].valueRemaining === 0n);
|
|
639
639
|
});
|
|
640
|
+
|
|
641
|
+
it('should fully remove an order which has been filled', async () => {
|
|
642
|
+
orderBook = new BigOrderBook({
|
|
643
|
+
minPartialTakeValue: 51
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
orderBook.add({
|
|
647
|
+
id: `ask0`,
|
|
648
|
+
type: 'limit',
|
|
649
|
+
price: 1,
|
|
650
|
+
targetChain: 'lsk',
|
|
651
|
+
targetWalletAddress: '22245678912345678222L',
|
|
652
|
+
senderId: '11111111111222222222L',
|
|
653
|
+
side: 'ask',
|
|
654
|
+
size: 10
|
|
655
|
+
});
|
|
656
|
+
orderBook.add({
|
|
657
|
+
id: `bid0`,
|
|
658
|
+
type: 'limit',
|
|
659
|
+
price: 1,
|
|
660
|
+
targetChain: 'clsk',
|
|
661
|
+
targetWalletAddress: '22245678912345678222L',
|
|
662
|
+
senderId: '11111111111222223333L',
|
|
663
|
+
side: 'bid',
|
|
664
|
+
value: 10
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
assert(orderBook.has('ask0') === false);
|
|
668
|
+
assert(orderBook.has('bid0') === false);
|
|
669
|
+
|
|
670
|
+
orderBook.add({
|
|
671
|
+
id: `bid0`,
|
|
672
|
+
type: 'limit',
|
|
673
|
+
price: 1,
|
|
674
|
+
targetChain: 'clsk',
|
|
675
|
+
targetWalletAddress: '22245678912345678222L',
|
|
676
|
+
senderId: '11111111111222223333L',
|
|
677
|
+
side: 'bid',
|
|
678
|
+
value: 10
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
orderBook.add({
|
|
682
|
+
id: `ask0`,
|
|
683
|
+
type: 'limit',
|
|
684
|
+
price: 1,
|
|
685
|
+
targetChain: 'lsk',
|
|
686
|
+
targetWalletAddress: '22245678912345678222L',
|
|
687
|
+
senderId: '11111111111222222222L',
|
|
688
|
+
side: 'ask',
|
|
689
|
+
size: 10
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
assert(orderBook.has('bid0') === false);
|
|
693
|
+
assert(orderBook.has('ask0') === false);
|
|
694
|
+
});
|
|
640
695
|
});
|
|
641
696
|
|
|
642
697
|
describe('#has', async () => {
|