kraken-grid 1.3.0 → 1.3.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/allocation.js +3 -2
- package/bot.js +17 -14
- package/coverage/clover.xml +1346 -1331
- package/coverage/coverage-final.json +7 -7
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov-report/kraken-grid/allocation.js.html +201 -198
- package/coverage/lcov-report/kraken-grid/balancer.js.html +1 -1
- package/coverage/lcov-report/kraken-grid/bot.js.html +589 -580
- package/coverage/lcov-report/kraken-grid/index.html +72 -72
- package/coverage/lcov-report/kraken-grid/init.js.html +1 -1
- package/coverage/lcov-report/kraken-grid/manager.js.html +114 -114
- package/coverage/lcov-report/kraken-grid/pricers/index.html +1 -1
- package/coverage/lcov-report/kraken-grid/pricers/openex.js.html +1 -1
- package/coverage/lcov-report/kraken-grid/reports.js.html +99 -90
- package/coverage/lcov-report/kraken-grid/safestore.js.html +1 -1
- package/coverage/lcov-report/kraken-grid/savings.js.html +133 -109
- package/coverage/lcov-report/kraken-grid/testFasterCache.js.html +66 -66
- package/coverage/lcov-report/kraken-grid/web.js.html +247 -247
- package/coverage/lcov.info +1789 -1697
- package/package.json +1 -1
- package/reports.js +11 -8
- package/savings.js +15 -7
- package/test/test.js +61 -0
- package/test/typing.js +21 -0
- package/testFasterCache.js +8 -8
- package/web.js +1 -1
package/allocation.js
CHANGED
|
@@ -494,8 +494,9 @@ export const AllocCon = (config, assets = [{ticker:'ZUSD',target:1}]) => {
|
|
|
494
494
|
moved = true;
|
|
495
495
|
}
|
|
496
496
|
if(moved) console.log("Range for",tk,"updated: ",ranges[tk]);
|
|
497
|
-
else
|
|
498
|
-
|
|
497
|
+
else if( config.bot.FLAGS.verbose )
|
|
498
|
+
console.log("No range was changed:[t,tk,mr,rt0,rt1,tl,th,p,moved]:"
|
|
499
|
+
+`${[pair,tk,mr,rt[0],rt[1],tl,th,p,moved]}.`);
|
|
499
500
|
} // If !ranges[tk] then we don't have a range to set!
|
|
500
501
|
});
|
|
501
502
|
}
|
package/bot.js
CHANGED
|
@@ -352,11 +352,12 @@ export const Bot = (config) => {
|
|
|
352
352
|
lCOts = closed.orders[closedIDs.pop()].closetm;
|
|
353
353
|
let counter = closedIDs.length-1;
|
|
354
354
|
console.log("Last five executed orders:");
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
closed.keysBkwd().forEach((o) => { // fill in the grid prices from existing orders.
|
|
356
|
+
const oo = closed.orders[o];
|
|
357
|
+
const od = oo.descr;
|
|
358
|
+
const op = od.price;
|
|
359
|
+
const ur = oo.userref;
|
|
360
|
+
const cd = new Date(oo.closetm * 1000);
|
|
360
361
|
let gp = gPrices.find(x => x.userref===ur); // If we already saw this grid point.
|
|
361
362
|
if( counter < 6 ) {
|
|
362
363
|
console.log(o,ur,op,od.type,od.close,`${cd.getFullYear()}/${1+cd.getMonth()
|
|
@@ -904,9 +905,9 @@ console.log("[p,np,dp,t,hp,lp,b,ma,f,tot1,ov,a,a2,t2,t2s]:",
|
|
|
904
905
|
|
|
905
906
|
async function report(showBalance=true) {
|
|
906
907
|
const balP = kapi('Balance');
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
908
|
+
const tikP = kapi(['TradeBalance',{ctr:30}]);
|
|
909
|
+
const marP = marginReport(false);
|
|
910
|
+
const [bal,trb,mar] = await Promise.all([balP,tikP,marP]);
|
|
910
911
|
portfolio.M = mar;
|
|
911
912
|
portfolio.lastUpdate = new Date;
|
|
912
913
|
Object.keys(bal.result).forEach(p => {
|
|
@@ -1016,8 +1017,9 @@ console.log("[p,np,dp,t,hp,lp,b,ma,f,tot1,ov,a,a2,t2,t2s]:",
|
|
|
1016
1017
|
}
|
|
1017
1018
|
orders = [];
|
|
1018
1019
|
const closed = await moreOrders();
|
|
1019
|
-
closed.
|
|
1020
|
-
|
|
1020
|
+
(early ? closed.keysFwd() : closed.keysBkwd())
|
|
1021
|
+
.forEach((o) => {
|
|
1022
|
+
const oo = closed.orders[o];
|
|
1021
1023
|
if(orders.length < count && (!ur || oo.userref===ur))
|
|
1022
1024
|
orders.push([o,oo]);
|
|
1023
1025
|
});
|
|
@@ -1030,9 +1032,10 @@ console.log("[p,np,dp,t,hp,lp,b,ma,f,tot1,ov,a,a2,t2,t2s]:",
|
|
|
1030
1032
|
orders.forEach((x,i) => {
|
|
1031
1033
|
const ldo = x[1].descr.order;
|
|
1032
1034
|
if(args.length===1 || RegExp(args[1]).test(ldo))
|
|
1033
|
-
console.log(x[0]
|
|
1034
|
-
|
|
1035
|
-
|
|
1035
|
+
console.log(`${x[0]} ${i+1} ${ldo} ${x[1].userref
|
|
1036
|
+
} ${x[1].status==='closed'
|
|
1037
|
+
? new Date(1000*x[1].closetm).toISOString()
|
|
1038
|
+
: x[1].descr.close}`);
|
|
1036
1039
|
else if(x[1][args[1]]) sortedA[i+1]=x;
|
|
1037
1040
|
else if(x[1].descr[args[1]]) sortedA[i+1]=x;
|
|
1038
1041
|
});
|
|
@@ -1058,7 +1061,7 @@ console.log("[p,np,dp,t,hp,lp,b,ma,f,tot1,ov,a,a2,t2,t2s]:",
|
|
|
1058
1061
|
ldo,x[1].userref,x[1].descr.close);
|
|
1059
1062
|
});
|
|
1060
1063
|
};
|
|
1061
|
-
const isMore = portfolio.Closed.
|
|
1064
|
+
const isMore = !portfolio.Closed.hasFirst;
|
|
1062
1065
|
console.log("We have collected", isMore
|
|
1063
1066
|
? portfolio.Closed.offset : "all",
|
|
1064
1067
|
"orders.", isMore ? "Try again for more." : "");
|