cryptobot-types 1.0.3 → 1.0.5
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/package.json +19 -19
- package/types/index.d.ts +6 -6
- package/types/indicators.d.ts +50 -50
- package/types/mongodb.d.ts +42 -42
- package/types/okx.d.ts +160 -160
- package/types/orderHelper.d.ts +47 -41
- package/types/strategy.d.ts +5 -5
- package/types/trading.d.ts +66 -87
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cryptobot-types",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"types": "types/index.d.ts",
|
|
6
|
-
"registry": "https://registry.npmjs.org/",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc -b"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"types"
|
|
12
|
-
],
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@types/node": "^20.8.
|
|
17
|
-
"okx-api": "^1.1.3"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cryptobot-types",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"types": "types/index.d.ts",
|
|
6
|
+
"registry": "https://registry.npmjs.org/",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -b"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"types"
|
|
12
|
+
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@types/node": "^20.8.3",
|
|
17
|
+
"okx-api": "^1.1.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./indicators";
|
|
2
|
-
export * from "./mongodb";
|
|
3
|
-
export * from "./okx";
|
|
4
|
-
export * from "./orderHelper";
|
|
5
|
-
export * from "./strategy";
|
|
6
|
-
export * from "./trading";
|
|
1
|
+
export * from "./indicators";
|
|
2
|
+
export * from "./mongodb";
|
|
3
|
+
export * from "./okx";
|
|
4
|
+
export * from "./orderHelper";
|
|
5
|
+
export * from "./strategy";
|
|
6
|
+
export * from "./trading";
|
package/types/indicators.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Candle } from './mongodb'
|
|
2
|
-
|
|
3
|
-
export interface Indicators {
|
|
4
|
-
granularity: number
|
|
5
|
-
ema_8: number
|
|
6
|
-
ema_13: number
|
|
7
|
-
ema_21: number
|
|
8
|
-
ema_55: number
|
|
9
|
-
bollinger_bands: {
|
|
10
|
-
upper: number
|
|
11
|
-
middle: number
|
|
12
|
-
lower: number
|
|
13
|
-
}
|
|
14
|
-
MACD: {
|
|
15
|
-
macd: number
|
|
16
|
-
emaFast: number
|
|
17
|
-
emaSlow: number
|
|
18
|
-
signal: number
|
|
19
|
-
histogram: number
|
|
20
|
-
}
|
|
21
|
-
vol: number
|
|
22
|
-
RSI: number
|
|
23
|
-
ADX: { adx: number; pdi: number; mdi: number }
|
|
24
|
-
ATR: number
|
|
25
|
-
ATR_percent: number
|
|
26
|
-
candle: Candle
|
|
27
|
-
stochRSI: { k: number; d: number }
|
|
28
|
-
HA: {
|
|
29
|
-
o: number
|
|
30
|
-
c: number
|
|
31
|
-
h: number
|
|
32
|
-
l: number
|
|
33
|
-
}
|
|
34
|
-
CCI: number
|
|
35
|
-
ChaikinOS: number
|
|
36
|
-
ROC: number
|
|
37
|
-
PSAR: number
|
|
38
|
-
OBV: undefined | number
|
|
39
|
-
OBV_RSI: number
|
|
40
|
-
OBV_SMA: number
|
|
41
|
-
VWAP: undefined | number
|
|
42
|
-
VWAP_deviation: {
|
|
43
|
-
basis: number
|
|
44
|
-
upperDeviation2: number
|
|
45
|
-
upperDeviation3: number
|
|
46
|
-
lowerDeviation2: number
|
|
47
|
-
lowerDeviation3: number
|
|
48
|
-
}
|
|
49
|
-
avgCandleSize: number
|
|
50
|
-
}
|
|
1
|
+
import { Candle } from './mongodb'
|
|
2
|
+
|
|
3
|
+
export interface Indicators {
|
|
4
|
+
granularity: number
|
|
5
|
+
ema_8: number
|
|
6
|
+
ema_13: number
|
|
7
|
+
ema_21: number
|
|
8
|
+
ema_55: number
|
|
9
|
+
bollinger_bands: {
|
|
10
|
+
upper: number
|
|
11
|
+
middle: number
|
|
12
|
+
lower: number
|
|
13
|
+
}
|
|
14
|
+
MACD: {
|
|
15
|
+
macd: number
|
|
16
|
+
emaFast: number
|
|
17
|
+
emaSlow: number
|
|
18
|
+
signal: number
|
|
19
|
+
histogram: number
|
|
20
|
+
}
|
|
21
|
+
vol: number
|
|
22
|
+
RSI: number
|
|
23
|
+
ADX: { adx: number; pdi: number; mdi: number }
|
|
24
|
+
ATR: number
|
|
25
|
+
ATR_percent: number
|
|
26
|
+
candle: Candle
|
|
27
|
+
stochRSI: { k: number; d: number }
|
|
28
|
+
HA: {
|
|
29
|
+
o: number
|
|
30
|
+
c: number
|
|
31
|
+
h: number
|
|
32
|
+
l: number
|
|
33
|
+
}
|
|
34
|
+
CCI: number
|
|
35
|
+
ChaikinOS: number
|
|
36
|
+
ROC: number
|
|
37
|
+
PSAR: number
|
|
38
|
+
OBV: undefined | number
|
|
39
|
+
OBV_RSI: number
|
|
40
|
+
OBV_SMA: number
|
|
41
|
+
VWAP: undefined | number
|
|
42
|
+
VWAP_deviation: {
|
|
43
|
+
basis: number
|
|
44
|
+
upperDeviation2: number
|
|
45
|
+
upperDeviation3: number
|
|
46
|
+
lowerDeviation2: number
|
|
47
|
+
lowerDeviation3: number
|
|
48
|
+
}
|
|
49
|
+
avgCandleSize: number
|
|
50
|
+
}
|
package/types/mongodb.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export interface GeneratedCandle {
|
|
2
|
-
open: string;
|
|
3
|
-
high: string;
|
|
4
|
-
low: string;
|
|
5
|
-
close: string;
|
|
6
|
-
volume: number;
|
|
7
|
-
start: Date;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Candle {
|
|
11
|
-
open: number;
|
|
12
|
-
high: number;
|
|
13
|
-
low: number;
|
|
14
|
-
close: number;
|
|
15
|
-
volume: number;
|
|
16
|
-
start: Date;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface GetBacktestOptions {
|
|
20
|
-
_ids?: string[];
|
|
21
|
-
testedAfter?: string;
|
|
22
|
-
rule?: string;
|
|
23
|
-
minProfit?: number;
|
|
24
|
-
start?: {
|
|
25
|
-
$gt: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface TimeAndCloseCandle {
|
|
30
|
-
start: Date;
|
|
31
|
-
close: number;
|
|
32
|
-
volume: number;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface DatabaseType {
|
|
36
|
-
start: Date;
|
|
37
|
-
open: string;
|
|
38
|
-
high: string;
|
|
39
|
-
low: string;
|
|
40
|
-
close: string;
|
|
41
|
-
volume: string;
|
|
42
|
-
}
|
|
1
|
+
export interface GeneratedCandle {
|
|
2
|
+
open: string;
|
|
3
|
+
high: string;
|
|
4
|
+
low: string;
|
|
5
|
+
close: string;
|
|
6
|
+
volume: number;
|
|
7
|
+
start: Date;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Candle {
|
|
11
|
+
open: number;
|
|
12
|
+
high: number;
|
|
13
|
+
low: number;
|
|
14
|
+
close: number;
|
|
15
|
+
volume: number;
|
|
16
|
+
start: Date;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GetBacktestOptions {
|
|
20
|
+
_ids?: string[];
|
|
21
|
+
testedAfter?: string;
|
|
22
|
+
rule?: string;
|
|
23
|
+
minProfit?: number;
|
|
24
|
+
start?: {
|
|
25
|
+
$gt: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TimeAndCloseCandle {
|
|
30
|
+
start: Date;
|
|
31
|
+
close: number;
|
|
32
|
+
volume: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DatabaseType {
|
|
36
|
+
start: Date;
|
|
37
|
+
open: string;
|
|
38
|
+
high: string;
|
|
39
|
+
low: string;
|
|
40
|
+
close: string;
|
|
41
|
+
volume: string;
|
|
42
|
+
}
|
package/types/okx.d.ts
CHANGED
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
import { WsDataEvent } from "okx-api";
|
|
2
|
-
|
|
3
|
-
export interface TickerUpdateData {
|
|
4
|
-
instType: string;
|
|
5
|
-
instId: string;
|
|
6
|
-
last: string;
|
|
7
|
-
lastSz: string;
|
|
8
|
-
askPx: string;
|
|
9
|
-
askSz: string;
|
|
10
|
-
bidPx: string;
|
|
11
|
-
bidSz: string;
|
|
12
|
-
open24h: string;
|
|
13
|
-
high24h: string;
|
|
14
|
-
low24h: string;
|
|
15
|
-
sodUtc0: string;
|
|
16
|
-
sodUtc8: string;
|
|
17
|
-
volCcy24h: string;
|
|
18
|
-
vol24h: string;
|
|
19
|
-
ts: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface PositionUpdateData {
|
|
23
|
-
adl: string;
|
|
24
|
-
availPos: string;
|
|
25
|
-
avgPx: string;
|
|
26
|
-
baseBal: string;
|
|
27
|
-
baseBorrowed: string;
|
|
28
|
-
baseInterest: string;
|
|
29
|
-
bizRefId: string;
|
|
30
|
-
bizRefType: string;
|
|
31
|
-
cTime: string;
|
|
32
|
-
ccy: string;
|
|
33
|
-
closeOrderAlgo: string[];
|
|
34
|
-
deltaBS: string;
|
|
35
|
-
deltaPA: string;
|
|
36
|
-
gammaBS: string;
|
|
37
|
-
gammaPA: string;
|
|
38
|
-
imr: string;
|
|
39
|
-
instId: string;
|
|
40
|
-
instType: string;
|
|
41
|
-
interest: string;
|
|
42
|
-
last: string;
|
|
43
|
-
lever: string;
|
|
44
|
-
liab: string;
|
|
45
|
-
liabCcy: string;
|
|
46
|
-
liqPx: string;
|
|
47
|
-
margin: string;
|
|
48
|
-
markPx: string;
|
|
49
|
-
mgnMode: string;
|
|
50
|
-
mgnRatio: string;
|
|
51
|
-
mmr: string;
|
|
52
|
-
notionalUsd: string;
|
|
53
|
-
optVal: string;
|
|
54
|
-
pTime: string;
|
|
55
|
-
pendingCloseOrdLiabVal: string;
|
|
56
|
-
pos: string;
|
|
57
|
-
posCcy: string;
|
|
58
|
-
posId: string;
|
|
59
|
-
posSide: string;
|
|
60
|
-
quoteBal: string;
|
|
61
|
-
quoteBorrowed: string;
|
|
62
|
-
quoteInterest: string;
|
|
63
|
-
spotInUseAmt: string;
|
|
64
|
-
spotInUseCcy: string;
|
|
65
|
-
thetaBS: string;
|
|
66
|
-
thetaPA: string;
|
|
67
|
-
tradeId: string;
|
|
68
|
-
uTime: string;
|
|
69
|
-
upl: string;
|
|
70
|
-
uplRatio: string;
|
|
71
|
-
usdPx: string;
|
|
72
|
-
vegaBS: string;
|
|
73
|
-
vegaPA: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface OrderUpdateData {
|
|
77
|
-
instType: string;
|
|
78
|
-
instId: string;
|
|
79
|
-
tgtCcy: string;
|
|
80
|
-
ccy: string;
|
|
81
|
-
ordId: string;
|
|
82
|
-
clOrdId: string;
|
|
83
|
-
tag: string;
|
|
84
|
-
px: string;
|
|
85
|
-
sz: string;
|
|
86
|
-
notionalUsd: string;
|
|
87
|
-
ordType: string;
|
|
88
|
-
side: string;
|
|
89
|
-
posSide: string;
|
|
90
|
-
tdMode: string;
|
|
91
|
-
fillPx: string;
|
|
92
|
-
tradeId: string;
|
|
93
|
-
fillSz: string;
|
|
94
|
-
fillFee: string;
|
|
95
|
-
fillFeeCcy: string;
|
|
96
|
-
execType: string;
|
|
97
|
-
accFillSize: string;
|
|
98
|
-
fillNotionalUsd: string;
|
|
99
|
-
avgPx: string;
|
|
100
|
-
state: string;
|
|
101
|
-
lever: string;
|
|
102
|
-
tpTriggerPx: string;
|
|
103
|
-
tpTriggerPxType: string;
|
|
104
|
-
tpOrdPx: string;
|
|
105
|
-
slTriggerPx: string;
|
|
106
|
-
slTriggerPxType: string;
|
|
107
|
-
slOrdPx: string;
|
|
108
|
-
feeCcy: string;
|
|
109
|
-
fee: string;
|
|
110
|
-
rebateCcy: string;
|
|
111
|
-
rebate: string;
|
|
112
|
-
pnl: string;
|
|
113
|
-
source: string;
|
|
114
|
-
cancelSource: string;
|
|
115
|
-
amendSource: string;
|
|
116
|
-
category: string;
|
|
117
|
-
uTIme: string;
|
|
118
|
-
cTime: string;
|
|
119
|
-
reqId: string;
|
|
120
|
-
amendResult: string;
|
|
121
|
-
reduceOnly: string;
|
|
122
|
-
quickMgnType: string;
|
|
123
|
-
algoClOrdId: string;
|
|
124
|
-
algoId: string;
|
|
125
|
-
code: string;
|
|
126
|
-
msg: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export type TickerUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
130
|
-
data: TickerUpdateData[];
|
|
131
|
-
wsKey: string;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export type PositionUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
135
|
-
data: PositionUpdateData[];
|
|
136
|
-
wsKey: string;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export type OrderUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
140
|
-
data: OrderUpdateData[];
|
|
141
|
-
wsKey: string;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const isTickerUpdateEvent = (
|
|
145
|
-
event: WsDataEvent
|
|
146
|
-
): event is TickerUpdateEvent => {
|
|
147
|
-
return event.arg.channel === "tickers";
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const isPositionUpdateEvent = (
|
|
151
|
-
event: WsDataEvent
|
|
152
|
-
): event is PositionUpdateEvent => {
|
|
153
|
-
return event.arg.channel === "positions";
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export const isOrderUpdateEvent = (
|
|
157
|
-
event: WsDataEvent
|
|
158
|
-
): event is OrderUpdateEvent => {
|
|
159
|
-
return event.arg.channel === "orders";
|
|
160
|
-
};
|
|
1
|
+
import { WsDataEvent } from "okx-api";
|
|
2
|
+
|
|
3
|
+
export interface TickerUpdateData {
|
|
4
|
+
instType: string;
|
|
5
|
+
instId: string;
|
|
6
|
+
last: string;
|
|
7
|
+
lastSz: string;
|
|
8
|
+
askPx: string;
|
|
9
|
+
askSz: string;
|
|
10
|
+
bidPx: string;
|
|
11
|
+
bidSz: string;
|
|
12
|
+
open24h: string;
|
|
13
|
+
high24h: string;
|
|
14
|
+
low24h: string;
|
|
15
|
+
sodUtc0: string;
|
|
16
|
+
sodUtc8: string;
|
|
17
|
+
volCcy24h: string;
|
|
18
|
+
vol24h: string;
|
|
19
|
+
ts: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PositionUpdateData {
|
|
23
|
+
adl: string;
|
|
24
|
+
availPos: string;
|
|
25
|
+
avgPx: string;
|
|
26
|
+
baseBal: string;
|
|
27
|
+
baseBorrowed: string;
|
|
28
|
+
baseInterest: string;
|
|
29
|
+
bizRefId: string;
|
|
30
|
+
bizRefType: string;
|
|
31
|
+
cTime: string;
|
|
32
|
+
ccy: string;
|
|
33
|
+
closeOrderAlgo: string[];
|
|
34
|
+
deltaBS: string;
|
|
35
|
+
deltaPA: string;
|
|
36
|
+
gammaBS: string;
|
|
37
|
+
gammaPA: string;
|
|
38
|
+
imr: string;
|
|
39
|
+
instId: string;
|
|
40
|
+
instType: string;
|
|
41
|
+
interest: string;
|
|
42
|
+
last: string;
|
|
43
|
+
lever: string;
|
|
44
|
+
liab: string;
|
|
45
|
+
liabCcy: string;
|
|
46
|
+
liqPx: string;
|
|
47
|
+
margin: string;
|
|
48
|
+
markPx: string;
|
|
49
|
+
mgnMode: string;
|
|
50
|
+
mgnRatio: string;
|
|
51
|
+
mmr: string;
|
|
52
|
+
notionalUsd: string;
|
|
53
|
+
optVal: string;
|
|
54
|
+
pTime: string;
|
|
55
|
+
pendingCloseOrdLiabVal: string;
|
|
56
|
+
pos: string;
|
|
57
|
+
posCcy: string;
|
|
58
|
+
posId: string;
|
|
59
|
+
posSide: string;
|
|
60
|
+
quoteBal: string;
|
|
61
|
+
quoteBorrowed: string;
|
|
62
|
+
quoteInterest: string;
|
|
63
|
+
spotInUseAmt: string;
|
|
64
|
+
spotInUseCcy: string;
|
|
65
|
+
thetaBS: string;
|
|
66
|
+
thetaPA: string;
|
|
67
|
+
tradeId: string;
|
|
68
|
+
uTime: string;
|
|
69
|
+
upl: string;
|
|
70
|
+
uplRatio: string;
|
|
71
|
+
usdPx: string;
|
|
72
|
+
vegaBS: string;
|
|
73
|
+
vegaPA: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OrderUpdateData {
|
|
77
|
+
instType: string;
|
|
78
|
+
instId: string;
|
|
79
|
+
tgtCcy: string;
|
|
80
|
+
ccy: string;
|
|
81
|
+
ordId: string;
|
|
82
|
+
clOrdId: string;
|
|
83
|
+
tag: string;
|
|
84
|
+
px: string;
|
|
85
|
+
sz: string;
|
|
86
|
+
notionalUsd: string;
|
|
87
|
+
ordType: string;
|
|
88
|
+
side: string;
|
|
89
|
+
posSide: string;
|
|
90
|
+
tdMode: string;
|
|
91
|
+
fillPx: string;
|
|
92
|
+
tradeId: string;
|
|
93
|
+
fillSz: string;
|
|
94
|
+
fillFee: string;
|
|
95
|
+
fillFeeCcy: string;
|
|
96
|
+
execType: string;
|
|
97
|
+
accFillSize: string;
|
|
98
|
+
fillNotionalUsd: string;
|
|
99
|
+
avgPx: string;
|
|
100
|
+
state: string;
|
|
101
|
+
lever: string;
|
|
102
|
+
tpTriggerPx: string;
|
|
103
|
+
tpTriggerPxType: string;
|
|
104
|
+
tpOrdPx: string;
|
|
105
|
+
slTriggerPx: string;
|
|
106
|
+
slTriggerPxType: string;
|
|
107
|
+
slOrdPx: string;
|
|
108
|
+
feeCcy: string;
|
|
109
|
+
fee: string;
|
|
110
|
+
rebateCcy: string;
|
|
111
|
+
rebate: string;
|
|
112
|
+
pnl: string;
|
|
113
|
+
source: string;
|
|
114
|
+
cancelSource: string;
|
|
115
|
+
amendSource: string;
|
|
116
|
+
category: string;
|
|
117
|
+
uTIme: string;
|
|
118
|
+
cTime: string;
|
|
119
|
+
reqId: string;
|
|
120
|
+
amendResult: string;
|
|
121
|
+
reduceOnly: string;
|
|
122
|
+
quickMgnType: string;
|
|
123
|
+
algoClOrdId: string;
|
|
124
|
+
algoId: string;
|
|
125
|
+
code: string;
|
|
126
|
+
msg: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type TickerUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
130
|
+
data: TickerUpdateData[];
|
|
131
|
+
wsKey: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type PositionUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
135
|
+
data: PositionUpdateData[];
|
|
136
|
+
wsKey: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export type OrderUpdateEvent = Omit<WsDataEvent, "data"> & {
|
|
140
|
+
data: OrderUpdateData[];
|
|
141
|
+
wsKey: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const isTickerUpdateEvent = (
|
|
145
|
+
event: WsDataEvent
|
|
146
|
+
): event is TickerUpdateEvent => {
|
|
147
|
+
return event.arg.channel === "tickers";
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const isPositionUpdateEvent = (
|
|
151
|
+
event: WsDataEvent
|
|
152
|
+
): event is PositionUpdateEvent => {
|
|
153
|
+
return event.arg.channel === "positions";
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const isOrderUpdateEvent = (
|
|
157
|
+
event: WsDataEvent
|
|
158
|
+
): event is OrderUpdateEvent => {
|
|
159
|
+
return event.arg.channel === "orders";
|
|
160
|
+
};
|
package/types/orderHelper.d.ts
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
interface BasePosition {
|
|
2
|
-
symbol: string
|
|
3
|
-
type:
|
|
4
|
-
ctSize: number
|
|
5
|
-
margin: number
|
|
6
|
-
leverage: number
|
|
7
|
-
avgEntryPrice: number
|
|
8
|
-
liquidationPrice: number
|
|
9
|
-
fee: number
|
|
10
|
-
orders: (Order | CloseOrder)[]
|
|
11
|
-
amountUSD: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
1
|
+
interface BasePosition {
|
|
2
|
+
symbol: string;
|
|
3
|
+
type: "long" | "short";
|
|
4
|
+
ctSize: number;
|
|
5
|
+
margin: number;
|
|
6
|
+
leverage: number;
|
|
7
|
+
avgEntryPrice: number;
|
|
8
|
+
liquidationPrice: number;
|
|
9
|
+
fee: number;
|
|
10
|
+
orders: (Order | CloseOrder)[];
|
|
11
|
+
amountUSD: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface OptionalPositionInfo {
|
|
15
|
+
lowestPrice?: number;
|
|
16
|
+
highestPrice?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Position extends BasePosition, OptionalPositionInfo {
|
|
20
|
+
unrealizedPnlUSD: number;
|
|
21
|
+
unrealizedPnlPcnt: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ClosedPosition extends BasePosition, OptionalPositionInfo {
|
|
25
|
+
realizedPnlUSD: number;
|
|
26
|
+
realizedPnlPcnt: number;
|
|
27
|
+
identifier: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BaseOrder {
|
|
31
|
+
ordId: string;
|
|
32
|
+
avgPrice: number;
|
|
33
|
+
fee: number;
|
|
34
|
+
amountUSD: number;
|
|
35
|
+
size: number;
|
|
36
|
+
time: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface Order extends BaseOrder {
|
|
40
|
+
action: "open";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CloseOrder
|
|
44
|
+
extends Pick<Order, Exclude<keyof Order, "action">> {
|
|
45
|
+
action: "close";
|
|
46
|
+
bruttoPnlUSD: number;
|
|
47
|
+
}
|
package/types/strategy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface Strategy {
|
|
2
|
-
readonly name: string
|
|
3
|
-
readonly startCapital: number
|
|
4
|
-
update(price: number, indicators: unknown[], time: Date): Promise<void>
|
|
5
|
-
}
|
|
1
|
+
export interface Strategy {
|
|
2
|
+
readonly name: string
|
|
3
|
+
readonly startCapital: number
|
|
4
|
+
update(price: number, indicators: unknown[], time: Date): Promise<void>
|
|
5
|
+
}
|
package/types/trading.d.ts
CHANGED
|
@@ -1,87 +1,66 @@
|
|
|
1
|
-
export type Rule = {
|
|
2
|
-
long_entry: boolean[][];
|
|
3
|
-
long_exit: boolean[][];
|
|
4
|
-
short_entry: boolean[][];
|
|
5
|
-
short_exit: boolean[][];
|
|
6
|
-
noStrictVolume?: boolean;
|
|
7
|
-
saveProfits?: boolean;
|
|
8
|
-
isCorrelationTest?: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type Exchanges = "binance" | "coinbase" | "dydx" | "kraken" | "okx";
|
|
12
|
-
|
|
13
|
-
export type EntryOrderTypes = "Long Entry" | "Short Entry";
|
|
14
|
-
type ExitOrderTypes = "Long Exit" | "Short Exit";
|
|
15
|
-
export type OrderTypes = EntryOrderTypes | ExitOrderTypes;
|
|
16
|
-
|
|
17
|
-
export interface BaseOrderObject {
|
|
18
|
-
timestamp: Date;
|
|
19
|
-
platform: Exchanges;
|
|
20
|
-
invest: number;
|
|
21
|
-
netInvest: number;
|
|
22
|
-
portfolio: number;
|
|
23
|
-
clOrdId?: string;
|
|
24
|
-
leverage?: number;
|
|
25
|
-
details: Record<string, unknown>;
|
|
26
|
-
spread?: number;
|
|
27
|
-
canExecuteOrder?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface EntryOrderObject extends BaseOrderObject {
|
|
31
|
-
price: number;
|
|
32
|
-
type: EntryOrderTypes;
|
|
33
|
-
fee: number;
|
|
34
|
-
holdDuration: number;
|
|
35
|
-
//trading
|
|
36
|
-
positionSize?: number;
|
|
37
|
-
netPositionSize?: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ExitOrderObject extends Omit<EntryOrderObject, "type"> {
|
|
41
|
-
type: ExitOrderTypes;
|
|
42
|
-
priceChangePercent: number;
|
|
43
|
-
netProfitInPercent: number;
|
|
44
|
-
netProfit: number;
|
|
45
|
-
profit: number;
|
|
46
|
-
highestPrice?: number;
|
|
47
|
-
lowestPrice?: number;
|
|
48
|
-
isLiquidated: boolean;
|
|
49
|
-
//timeInLoss: number;
|
|
50
|
-
//timeInLossInPercent: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type OrderObject = EntryOrderObject | ExitOrderObject;
|
|
54
|
-
|
|
55
|
-
export interface
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
executedOrders: number;
|
|
68
|
-
key: string | number;
|
|
69
|
-
}[];
|
|
70
|
-
gotLiquidated: boolean;
|
|
71
|
-
shortLongRatio: string;
|
|
72
|
-
executedOrders: number;
|
|
73
|
-
lineOfBestFit: number[];
|
|
74
|
-
//avgTimeInLoss: number;
|
|
75
|
-
//avgTimeInLossInPercent: number;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface BacktestingResult extends BaseBacktestOptions {
|
|
79
|
-
strategyName: string;
|
|
80
|
-
exchange: Exchanges;
|
|
81
|
-
symbol: string;
|
|
82
|
-
start: Date;
|
|
83
|
-
end: Date;
|
|
84
|
-
leverage: number;
|
|
85
|
-
hodlProfitInPercent: number;
|
|
86
|
-
tradesCount: number;
|
|
87
|
-
}
|
|
1
|
+
export type Rule = {
|
|
2
|
+
long_entry: boolean[][];
|
|
3
|
+
long_exit: boolean[][];
|
|
4
|
+
short_entry: boolean[][];
|
|
5
|
+
short_exit: boolean[][];
|
|
6
|
+
noStrictVolume?: boolean;
|
|
7
|
+
saveProfits?: boolean;
|
|
8
|
+
isCorrelationTest?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Exchanges = "binance" | "coinbase" | "dydx" | "kraken" | "okx";
|
|
12
|
+
|
|
13
|
+
export type EntryOrderTypes = "Long Entry" | "Short Entry";
|
|
14
|
+
type ExitOrderTypes = "Long Exit" | "Short Exit";
|
|
15
|
+
export type OrderTypes = EntryOrderTypes | ExitOrderTypes;
|
|
16
|
+
|
|
17
|
+
export interface BaseOrderObject {
|
|
18
|
+
timestamp: Date;
|
|
19
|
+
platform: Exchanges;
|
|
20
|
+
invest: number;
|
|
21
|
+
netInvest: number;
|
|
22
|
+
portfolio: number;
|
|
23
|
+
clOrdId?: string;
|
|
24
|
+
leverage?: number;
|
|
25
|
+
details: Record<string, unknown>;
|
|
26
|
+
spread?: number;
|
|
27
|
+
canExecuteOrder?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface EntryOrderObject extends BaseOrderObject {
|
|
31
|
+
price: number;
|
|
32
|
+
type: EntryOrderTypes;
|
|
33
|
+
fee: number;
|
|
34
|
+
holdDuration: number;
|
|
35
|
+
//trading
|
|
36
|
+
positionSize?: number;
|
|
37
|
+
netPositionSize?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ExitOrderObject extends Omit<EntryOrderObject, "type"> {
|
|
41
|
+
type: ExitOrderTypes;
|
|
42
|
+
priceChangePercent: number;
|
|
43
|
+
netProfitInPercent: number;
|
|
44
|
+
netProfit: number;
|
|
45
|
+
profit: number;
|
|
46
|
+
highestPrice?: number;
|
|
47
|
+
lowestPrice?: number;
|
|
48
|
+
isLiquidated: boolean;
|
|
49
|
+
//timeInLoss: number;
|
|
50
|
+
//timeInLossInPercent: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type OrderObject = EntryOrderObject | ExitOrderObject;
|
|
54
|
+
|
|
55
|
+
export interface BacktestingResult {
|
|
56
|
+
trades: number;
|
|
57
|
+
identifier: string;
|
|
58
|
+
name: string;
|
|
59
|
+
pnl: number;
|
|
60
|
+
winRatio: number;
|
|
61
|
+
stringifiedFunc: string;
|
|
62
|
+
time: Date;
|
|
63
|
+
start: Date;
|
|
64
|
+
end: Date;
|
|
65
|
+
pnl_pct: number;
|
|
66
|
+
}
|