kraken-grid 1.2.13 → 1.3.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/.eslintrc +32 -0
- package/.vscode/launch.json +47 -0
- package/JestTesting/logAlot.js +27 -0
- package/JestTesting/testSpy.js +9 -0
- package/README.md +59 -59
- package/allocation.js +421 -273
- package/ava.config.js +3 -0
- package/balancer.js +56 -65
- package/bot.js +858 -649
- package/coverage/clover.xml +3446 -0
- package/coverage/coverage-final.json +12 -0
- package/coverage/lcov-report/allocation.js.html +1825 -0
- package/coverage/lcov-report/balancer.js.html +454 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/bot.js.html +3868 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/init.js.html +205 -0
- package/coverage/lcov-report/kraken-grid/allocation.js.html +1831 -0
- package/coverage/lcov-report/kraken-grid/balancer.js.html +454 -0
- package/coverage/lcov-report/kraken-grid/bot.js.html +3862 -0
- package/coverage/lcov-report/kraken-grid/index.html +251 -0
- package/coverage/lcov-report/kraken-grid/init.js.html +223 -0
- package/coverage/lcov-report/kraken-grid/manager.js.html +1483 -0
- package/coverage/lcov-report/kraken-grid/pricers/index.html +116 -0
- package/coverage/lcov-report/kraken-grid/pricers/openex.js.html +205 -0
- package/coverage/lcov-report/kraken-grid/reports.js.html +475 -0
- package/coverage/lcov-report/kraken-grid/safestore.js.html +433 -0
- package/coverage/lcov-report/kraken-grid/savings.js.html +754 -0
- package/coverage/lcov-report/kraken-grid/testFasterCache.js.html +661 -0
- package/coverage/lcov-report/kraken-grid/web.js.html +736 -0
- package/coverage/lcov-report/manager.js.html +1504 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/reports.js.html +475 -0
- package/coverage/lcov-report/safestore.js.html +433 -0
- package/coverage/lcov-report/savings.js.html +745 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/testFasterCache.js.html +661 -0
- package/coverage/lcov-report/web.js.html +724 -0
- package/coverage/lcov.info +4229 -0
- package/exchange.js +4 -0
- package/gemini.js +212 -0
- package/ginit.js +19 -0
- package/init.js +45 -13
- package/jest.config.mjs +199 -0
- package/krak2gem.js +301 -0
- package/manager.js +288 -320
- package/package.json +22 -17
- package/pricers/openex.js +36 -27
- package/reports.js +131 -0
- package/safestore.js +61 -51
- package/savings.js +115 -94
- package/static/client.js +84 -10
- package/test/7open.json +25 -0
- package/test/8open.json +6 -0
- package/test/DACbCache.json +3319 -0
- package/test/DACsCache.json +3319 -0
- package/test/NotesOnTesting.txt +5125 -0
- package/test/shared.js +1 -0
- package/test/test.js +123 -69
- package/test/testhh631808345.txt +1 -0
- package/testFasterCache.js +118 -81
- package/tt.js +1 -0
- package/web.js +143 -168
package/.eslintrc
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"airbnb/base",
|
|
4
|
+
"plugin:react/recommended",
|
|
5
|
+
"plugin:react-hooks/recommended",
|
|
6
|
+
"prettier"
|
|
7
|
+
],
|
|
8
|
+
"rules": {
|
|
9
|
+
"no-unused-vars": "error",
|
|
10
|
+
"no-console": "warn",
|
|
11
|
+
"no-nested-ternary": "error",
|
|
12
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
13
|
+
"react/prop-types": "error",
|
|
14
|
+
"react/react-in-jsx-scope": "off",
|
|
15
|
+
"import/prefer-default-export": "off"
|
|
16
|
+
},
|
|
17
|
+
"settings": {
|
|
18
|
+
"react": {
|
|
19
|
+
"version": "detect"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"env": {
|
|
23
|
+
"node": true,
|
|
24
|
+
"browser": true,
|
|
25
|
+
"es2021": true
|
|
26
|
+
},
|
|
27
|
+
// "extends": "eslint:recommended",
|
|
28
|
+
"parserOptions": {
|
|
29
|
+
"ecmaVersion": "latest",
|
|
30
|
+
"sourceType": "module"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Launch via NPM",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"runtimeArgs": [
|
|
11
|
+
"test"
|
|
12
|
+
],
|
|
13
|
+
"runtimeExecutable": "npm",
|
|
14
|
+
"skipFiles": [
|
|
15
|
+
"<node_internals>/**"
|
|
16
|
+
],
|
|
17
|
+
"type": "node"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "Attach by Process ID",
|
|
21
|
+
"processId": "${command:PickProcess}",
|
|
22
|
+
"request": "attach",
|
|
23
|
+
"skipFiles": [
|
|
24
|
+
"<node_internals>/**"
|
|
25
|
+
],
|
|
26
|
+
"type": "node"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Attach",
|
|
30
|
+
"port": 9229,
|
|
31
|
+
"request": "attach",
|
|
32
|
+
"skipFiles": [
|
|
33
|
+
"<node_internals>/**"
|
|
34
|
+
],
|
|
35
|
+
"type": "node"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "node",
|
|
39
|
+
"request": "launch",
|
|
40
|
+
"name": "Launch Program",
|
|
41
|
+
"skipFiles": [
|
|
42
|
+
"<node_internals>/**"
|
|
43
|
+
],
|
|
44
|
+
"program": "${workspaceFolder}\\init.js"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function logAlot() {
|
|
2
|
+
function Base64Encode(r){
|
|
3
|
+
if(/([^\u0000-\u00ff])/.test(r))throw Error("String must be ASCII");
|
|
4
|
+
var t,e,n,o,h,a,i=
|
|
5
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
6
|
+
f=[],
|
|
7
|
+
c="";
|
|
8
|
+
if((a=r.length%3)>0)
|
|
9
|
+
for(;a++<3;)
|
|
10
|
+
c+="=",r+="\0";
|
|
11
|
+
for(a=0;a<r.length;a+=3)
|
|
12
|
+
e=(t=r.charCodeAt(a)<<16|r.charCodeAt(a+1)<<8|r.charCodeAt(a+2))>>18&63,
|
|
13
|
+
n=t>>12&63,
|
|
14
|
+
o=t>>6&63,
|
|
15
|
+
h=63&t,
|
|
16
|
+
f[a/3]=i.charAt(e)+i.charAt(n)+i.charAt(o)+i.charAt(h);
|
|
17
|
+
return r=(r=f.join("")).slice(0,r.length-c.length)+c
|
|
18
|
+
}
|
|
19
|
+
function rand3() { return Base64Encode(String(Math.random())).substr(0,3); }
|
|
20
|
+
|
|
21
|
+
function log1000() {
|
|
22
|
+
for(let i = 0; i < 1000; i += 1)
|
|
23
|
+
console.log(rand3());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {log1000};
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {expect, describe, test, jest} from '@jest/globals';
|
|
2
|
+
import { logAlot } from './logAlot.js';
|
|
3
|
+
|
|
4
|
+
test("find AB", async () => {
|
|
5
|
+
const consoleSpy = jest.spyOn(console, "log");
|
|
6
|
+
const LA = logAlot();
|
|
7
|
+
LA.log1000();
|
|
8
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringMatching('AB'));
|
|
9
|
+
} );
|
package/README.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
3
|
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
4
|
-
|
|
5
|
-
- [kraken-grid BETA](#kraken-grid-beta)
|
|
6
|
-
- [Upgrading](#upgrading)
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [How the author (Dave) does it for himself and others:](#how-the-author-dave-does-it-for-himself-and-others)
|
|
10
|
-
- [Discussion of the `adjust` command.](#discussion-of-the-adjust-command)
|
|
11
|
-
- [Web UI](#web-ui)
|
|
12
|
-
- [Orders table](#orders-table)
|
|
13
|
-
- [Allocation table](#allocation-table)
|
|
14
|
-
- [Assets table](#assets-table)
|
|
15
|
-
- [Pie Charts](#pie-charts)
|
|
16
|
-
- [Changing your password](#changing-your-password)
|
|
17
|
-
- [Mistyped passwords](#mistyped-passwords)
|
|
18
|
-
- [Command Line Interface](#command-line-interface)
|
|
19
|
-
- [Trading](#trading)
|
|
20
|
-
- [addlev](#addlev)
|
|
21
|
-
- [delev](#delev)
|
|
22
|
-
- [buy](#buy)
|
|
23
|
-
- [sell](#sell)
|
|
24
|
-
- [kill](#kill)
|
|
25
|
-
- [limits](#limits)
|
|
26
|
-
- [less](#less)
|
|
27
|
-
- [more](#more)
|
|
28
|
-
- [Information Gathering](#information-gathering)
|
|
29
|
-
- [assets](#assets)
|
|
30
|
-
- [list [Search]](#list-search)
|
|
31
|
-
- [margin](#margin)
|
|
32
|
-
- [report](#report)
|
|
33
|
-
- [show](#show)
|
|
34
|
-
- [verbose](#verbose)
|
|
35
|
-
- [web](#web)
|
|
36
|
-
- [Bot Management](#bot-management)
|
|
37
|
-
- [adjust](#adjust)
|
|
38
|
-
- [allocate](#allocate)
|
|
39
|
-
- [allocation](#allocation)
|
|
40
|
-
- [asset](#asset)
|
|
41
|
-
- [auto](#auto)
|
|
42
|
-
- [manual](#manual)
|
|
43
|
-
- [balance](#balance)
|
|
44
|
-
- [quit](#quit)
|
|
45
|
-
- [risky](#risky)
|
|
46
|
-
- [refnum](#refnum)
|
|
47
|
-
- [reset](#reset)
|
|
48
|
-
- [safe](#safe)
|
|
49
|
-
- [set](#set)
|
|
50
|
-
- [Experimental features (Not Recommended and not well tested)](#experimental-features-not-recommended-and-not-well-tested)
|
|
51
|
-
- [ws - EXPERIMENTAL](#ws---experimental)
|
|
52
|
-
- [Internals](#internals)
|
|
53
|
-
- [Userref](#userref)
|
|
54
|
-
- [Partial Execution](#partial-execution)
|
|
55
|
-
- [HELP!](#help)
|
|
56
|
-
|
|
57
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
4
|
+
|
|
5
|
+
- [kraken-grid BETA](#kraken-grid-beta)
|
|
6
|
+
- [Upgrading](#upgrading)
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [How the author (Dave) does it for himself and others:](#how-the-author-dave-does-it-for-himself-and-others)
|
|
10
|
+
- [Discussion of the `adjust` command.](#discussion-of-the-adjust-command)
|
|
11
|
+
- [Web UI](#web-ui)
|
|
12
|
+
- [Orders table](#orders-table)
|
|
13
|
+
- [Allocation table](#allocation-table)
|
|
14
|
+
- [Assets table](#assets-table)
|
|
15
|
+
- [Pie Charts](#pie-charts)
|
|
16
|
+
- [Changing your password](#changing-your-password)
|
|
17
|
+
- [Mistyped passwords](#mistyped-passwords)
|
|
18
|
+
- [Command Line Interface](#command-line-interface)
|
|
19
|
+
- [Trading](#trading)
|
|
20
|
+
- [addlev](#addlev)
|
|
21
|
+
- [delev](#delev)
|
|
22
|
+
- [buy](#buy)
|
|
23
|
+
- [sell](#sell)
|
|
24
|
+
- [kill](#kill)
|
|
25
|
+
- [limits](#limits)
|
|
26
|
+
- [less](#less)
|
|
27
|
+
- [more](#more)
|
|
28
|
+
- [Information Gathering](#information-gathering)
|
|
29
|
+
- [assets](#assets)
|
|
30
|
+
- [list [Search]](#list-search)
|
|
31
|
+
- [margin](#margin)
|
|
32
|
+
- [report](#report)
|
|
33
|
+
- [show](#show)
|
|
34
|
+
- [verbose](#verbose)
|
|
35
|
+
- [web](#web)
|
|
36
|
+
- [Bot Management](#bot-management)
|
|
37
|
+
- [adjust](#adjust)
|
|
38
|
+
- [allocate](#allocate)
|
|
39
|
+
- [allocation](#allocation)
|
|
40
|
+
- [asset](#asset)
|
|
41
|
+
- [auto](#auto)
|
|
42
|
+
- [manual](#manual)
|
|
43
|
+
- [balance](#balance)
|
|
44
|
+
- [quit](#quit)
|
|
45
|
+
- [risky](#risky)
|
|
46
|
+
- [refnum](#refnum)
|
|
47
|
+
- [reset](#reset)
|
|
48
|
+
- [safe](#safe)
|
|
49
|
+
- [set](#set)
|
|
50
|
+
- [Experimental features (Not Recommended and not well tested)](#experimental-features-not-recommended-and-not-well-tested)
|
|
51
|
+
- [ws - EXPERIMENTAL](#ws---experimental)
|
|
52
|
+
- [Internals](#internals)
|
|
53
|
+
- [Userref](#userref)
|
|
54
|
+
- [Partial Execution](#partial-execution)
|
|
55
|
+
- [HELP!](#help)
|
|
56
|
+
|
|
57
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
58
58
|
|
|
59
59
|
# kraken-grid BETA
|
|
60
60
|
A bot that extends grid trading once you use it to create a grid using orders with conditional closes.
|
|
@@ -92,7 +92,7 @@ If you have proceeded with step four of the installation, then you have a runnin
|
|
|
92
92
|
5. If you have some other crypto on the exchange, you can do the same thing with it as I described in step 4 for XXBT (bitcoin). During a heavy drop across all cryptos, this will cause your USD allocation to drop a lot. For this reason, the bot won't let you do an adjustment that would require a negative allocation of USD. It misreports this as "You'd run out of cash" which should be "You'd have to short USD".
|
|
93
93
|
6. Once you have determined the allocation you want, with enough allocated to USD to make adjustments at lower prices, and you've added all the adjustments you want (only one for each crypto), then you can use the `balance` command. In the lower table of the web page, there is a clickable number in the upper left corner which says "Balance Tolerance" when you hover over it. This is used to build a `balance` command that will be proposed to be sent to the bot when you click the price of any asset. We recommend reading the documentation for `balance` as it places trades for you to achieve your target allocation and maintain it when the bot is in `auto` mode.
|
|
94
94
|
#### Discussion of the `adjust` command.
|
|
95
|
-
|
|
95
|
+
Using [adjust](#adjust) can only _increase_ the allocation, and not decrease it. To put it simply, allocation should be set to how much of your savings you want to be in this asset when it's _at the highest price_. Let's say you want the allocation to be perfectly even across all assets. When the prices are (all) at the bottom, you want all your cash to be spent. Here's how to set this up, assuming you want to hold at least half of your target allocation in an asset _at its highest price_ and the full target at the lowest one (This assumes you choose a trading range of 20%):
|
|
96
96
|
|
|
97
97
|
For a single crypto: Set your allocation to 50% (and 50% in USD or EUR or YEN, your _numeraire_, meaning the currency you use). Your adjust command would be `adjust TKR 50 20` where TKR is the ticker for your crypto. For two cryptos, set the allocation for each to 33.33% (leaving 33.33% for your numeraire). Your adjust command would be `adjust TKR 16.67 20` for each one.
|
|
98
98
|
|
|
@@ -144,7 +144,7 @@ The semantics are the same as for [delev](#delev).
|
|
|
144
144
|
|
|
145
145
|
#### delev
|
|
146
146
|
`delev Counter`
|
|
147
|
-
|
|
147
|
+
Counter _must be_ a `Counter` as shown by executing [list](#list). If the identified order uses leverage, this command will first create an order without any leverage to replace it, and then kill the one identified. The order that was killed will still be in the list, prefixed with `Killed:` *NOTE: The new order often (or always?) appears at the top of `list` after this, so the `Counter`s identifying other orders may change.*
|
|
148
148
|
|
|
149
149
|
#### buy
|
|
150
150
|
`buy Ticker Price Amount ClosePrice`
|
|
@@ -206,7 +206,7 @@ XLTC ...
|
|
|
206
206
|
...
|
|
207
207
|
```
|
|
208
208
|
2. Retrieves the list of open orders, which is immediately processed to:
|
|
209
|
-
1. replace conditional closes resulting from partial executions with a single conditional close which, itself, has a conditional close to continue buying and selling between the two prices, but only up to the amount originally specified, and _only_ for orders with a User Reference Number (such as all orders placed through this program).
|
|
209
|
+
1. replace conditional closes resulting from partial executions with a single conditional close which, itself, has a conditional close to continue buying and selling between the two prices, but only up to the amount originally specified, and _only_ for orders with a User Reference Number (such as all orders placed through this program). Note: If you place a conditional close order with a price that matches one side of an existing grid point and it executes, creating the conditional close, that new order will be added in with the others, increasing the size of the trade around that grid point.
|
|
210
210
|
2. fill out the internal record of buy/sell prices using the open orders and their conditional closes (see [set](#set) and [reset](#reset)).
|
|
211
211
|
3. extend the grid if there are only buys or only sells remaining for the crypto identified in each order.
|
|
212
212
|
4. identify any orders that are gone or new using Kraken's Order ID and for new orders, it also describes them.
|