@icgio/icg-utils 1.7.22 → 1.7.23
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/lib/utils.js +64 -41
- package/package.json +1 -1
package/lib/utils.js
CHANGED
|
@@ -296,6 +296,9 @@ module.exports.vol_position = function (input_array, vol_target) {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
module.exports.sum_position_orderbook = (input_array, sum_target) => {
|
|
299
|
+
if (sum_target === 0) {
|
|
300
|
+
return []
|
|
301
|
+
}
|
|
299
302
|
let { sum_original, pos } = module.exports.sum_position(input_array, sum_target)
|
|
300
303
|
let result = JSON.parse(JSON.stringify(input_array.slice(0, pos + 1)))
|
|
301
304
|
result[pos][1] += (sum_target - sum_original) / result[pos][0]
|
|
@@ -303,53 +306,72 @@ module.exports.sum_position_orderbook = (input_array, sum_target) => {
|
|
|
303
306
|
}
|
|
304
307
|
|
|
305
308
|
module.exports.vol_position_orderbook = (input_array, vol_target) => {
|
|
309
|
+
if (vol_target === 0) {
|
|
310
|
+
return []
|
|
311
|
+
}
|
|
306
312
|
let { vol_original, pos } = module.exports.vol_position(input_array, vol_target)
|
|
307
313
|
let result = JSON.parse(JSON.stringify(input_array.slice(0, pos + 1)))
|
|
308
314
|
result[pos][1] += vol_target - vol_original
|
|
309
315
|
return result
|
|
310
316
|
}
|
|
311
317
|
|
|
312
|
-
// console.log(
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
//
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
//
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
//
|
|
318
|
+
// console.log(
|
|
319
|
+
// module.exports.sum_position_orderbook(
|
|
320
|
+
// [
|
|
321
|
+
// [2, 1],
|
|
322
|
+
// [6, 6],
|
|
323
|
+
// [7, 7],
|
|
324
|
+
// ],
|
|
325
|
+
// 0
|
|
326
|
+
// )
|
|
327
|
+
// )
|
|
328
|
+
// console.log(
|
|
329
|
+
// module.exports.vol_position_orderbook(
|
|
330
|
+
// [
|
|
331
|
+
// [0.00004637, 14.12],
|
|
332
|
+
// [0.00004636, 19.37],
|
|
333
|
+
// [0.0000463, 77.76],
|
|
334
|
+
// [0.00004625, 17.93],
|
|
335
|
+
// [0.00004623, 14.89],
|
|
336
|
+
// [0.00004621, 34.25],
|
|
337
|
+
// [0.0000462, 131.77],
|
|
338
|
+
// [0.00004619, 24.79],
|
|
339
|
+
// [0.00004618, 36.71],
|
|
340
|
+
// [0.00004617, 18.36],
|
|
341
|
+
// [0.00004616, 9],
|
|
342
|
+
// [0.00004615, 67.22],
|
|
343
|
+
// [0.00004614, 74.74],
|
|
344
|
+
// [0.00004613, 31.89],
|
|
345
|
+
// [0.00004608, 31.25],
|
|
346
|
+
// [0.00004606, 72],
|
|
347
|
+
// [0.00004605, 11.69],
|
|
348
|
+
// [0.00004604, 36.68],
|
|
349
|
+
// [0.00004601, 29.77],
|
|
350
|
+
// [0.00004598, 11.17],
|
|
351
|
+
// [0.00004596, 25.19],
|
|
352
|
+
// [0.00004593, 9.01],
|
|
353
|
+
// [0.00004592, 15.56],
|
|
354
|
+
// [0.00004589, 15.21],
|
|
355
|
+
// [0.00004588, 21.25],
|
|
356
|
+
// [0.00004583, 25.19],
|
|
357
|
+
// [0.00004582, 81.02],
|
|
358
|
+
// [0.00004581, 24.55],
|
|
359
|
+
// [0.0000458, 0.26],
|
|
360
|
+
// [0.00004577, 71.32],
|
|
361
|
+
// [0.00004576, 43.39],
|
|
362
|
+
// [0.00004574, 41.3],
|
|
363
|
+
// [0.00004573, 0.75],
|
|
364
|
+
// [0.0000457, 10.84],
|
|
365
|
+
// [0.00004567, 0.26],
|
|
366
|
+
// [0.00004549, 239.91],
|
|
367
|
+
// [0.00004548, 115.89],
|
|
368
|
+
// [0.00004542, 192.91],
|
|
369
|
+
// [0.00004512, 0.64],
|
|
370
|
+
// [0.000045, 3.24],
|
|
371
|
+
// ],
|
|
372
|
+
// 1
|
|
373
|
+
// )
|
|
374
|
+
// )
|
|
353
375
|
|
|
354
376
|
module.exports.combine_orderbooks = (orderbooks_dict, length = undefined) => {
|
|
355
377
|
function merge_sorted(type) {
|
|
@@ -400,6 +422,7 @@ module.exports.combine_orderbooks = (orderbooks_dict, length = undefined) => {
|
|
|
400
422
|
// bids: [[0.95, 0.9], [0.7, 0.5], [0.4, 0.2]]
|
|
401
423
|
// }
|
|
402
424
|
// }, 3))
|
|
425
|
+
// console.log(module.exports.combine_orderbooks({}, 100))
|
|
403
426
|
|
|
404
427
|
module.exports.arb_opportunities_from_combined_orderbook = (orderbook_combined, profit_percentage = 0, amount_cap = 0) => {
|
|
405
428
|
let i = 0,
|