big-order-book 1.0.1 → 2.0.0
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 +16 -4
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -145,11 +145,11 @@ class BigOrderBook {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
_convertSizeToValue(size, price) {
|
|
148
|
-
return size * BigInt(Math.
|
|
148
|
+
return size * BigInt(Math.round(price * this.pricePrecisionFactor)) / BigInt(this.pricePrecisionFactor);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
_convertValueToSize(value, price) {
|
|
152
|
-
return
|
|
152
|
+
return value * BigInt(this.pricePrecisionFactor) / BigInt(Math.round(price * this.pricePrecisionFactor));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
_addAsk(ask) {
|
|
@@ -174,16 +174,22 @@ class BigOrderBook {
|
|
|
174
174
|
`The limit ask order with id ${ask.id} did not have a valid price property`
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
ask.price = Math.
|
|
177
|
+
ask.price = Math.round(ask.price * this.pricePrecisionFactor) / this.pricePrecisionFactor;
|
|
178
178
|
}
|
|
179
179
|
if (ask.sizeRemaining == null) {
|
|
180
180
|
ask.sizeRemaining = BigInt(ask.size);
|
|
181
|
+
} else {
|
|
182
|
+
ask.sizeRemaining = BigInt(ask.sizeRemaining);
|
|
181
183
|
}
|
|
182
184
|
if (ask.lastSizeTaken == null) {
|
|
183
185
|
ask.lastSizeTaken = 0n;
|
|
186
|
+
} else {
|
|
187
|
+
ask.lastSizeTaken = BigInt(ask.lastSizeTaken);
|
|
184
188
|
}
|
|
185
189
|
if (ask.lastValueTaken == null) {
|
|
186
190
|
ask.lastValueTaken = 0n;
|
|
191
|
+
} else {
|
|
192
|
+
ask.lastValueTaken = BigInt(ask.lastValueTaken);
|
|
187
193
|
}
|
|
188
194
|
|
|
189
195
|
let makers = [];
|
|
@@ -300,16 +306,22 @@ class BigOrderBook {
|
|
|
300
306
|
`The limit bid order with id ${bid.id} did not have a valid price property`
|
|
301
307
|
);
|
|
302
308
|
}
|
|
303
|
-
bid.price = Math.
|
|
309
|
+
bid.price = Math.round(bid.price * this.pricePrecisionFactor) / this.pricePrecisionFactor;
|
|
304
310
|
}
|
|
305
311
|
if (bid.valueRemaining == null) {
|
|
306
312
|
bid.valueRemaining = BigInt(bid.value);
|
|
313
|
+
} else {
|
|
314
|
+
bid.valueRemaining = BigInt(bid.valueRemaining);
|
|
307
315
|
}
|
|
308
316
|
if (bid.lastSizeTaken == null) {
|
|
309
317
|
bid.lastSizeTaken = 0n;
|
|
318
|
+
} else {
|
|
319
|
+
bid.lastSizeTaken = BigInt(bid.lastSizeTaken);
|
|
310
320
|
}
|
|
311
321
|
if (bid.lastValueTaken == null) {
|
|
312
322
|
bid.lastValueTaken = 0n;
|
|
323
|
+
} else {
|
|
324
|
+
bid.lastValueTaken = BigInt(bid.lastValueTaken);
|
|
313
325
|
}
|
|
314
326
|
|
|
315
327
|
let makers = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "big-order-book",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/
|
|
11
|
+
"url": "git+https://github.com/Capitalisk/big-order-book.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"order",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"author": "Jonathan Gros-Dubois",
|
|
20
20
|
"license": "GPL-3.0",
|
|
21
21
|
"bugs": {
|
|
22
|
-
"url": "https://github.com/
|
|
22
|
+
"url": "https://github.com/Capitalisk/big-order-book/issues"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://github.com/
|
|
24
|
+
"homepage": "https://github.com/Capitalisk/big-order-book#readme",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"linked-list": "^2.1.0",
|
|
27
27
|
"proper-skip-list": "^4.1.0"
|