forked from Haehnchen/crypto-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.js.dist
257 lines (231 loc) · 6.8 KB
/
instance.js.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
var c = module.exports = {}
c.symbols = []
/*
const InstanceUtil = require('./src/utils/instance_util');
c.init = async () => {
// Bitmex contracts + examples
c.symbols.push(
...(await InstanceUtil.bitmexInit(pair => {
// inverse contracts; trade with 1 USD
// you can also provide a "capital" instead for trade with fixed BTC or ETH
if (['XBTUSD', 'ETHUSD'].includes(pair.symbol) || pair.symbol.startsWith('XBT')) {
pair.trade = { currency_capital: 1 };
return pair;
}
// trade with 1 ETH on "BTC-ETH" contract, but ignore USD pair
if (pair.symbol.startsWith('ETH') && !pair.symbol.includes('USD')) {
pair.trade = { capital: 1 };
return pair;
}
// trade ADA-BTC; as ADA is low priced BTC; good for testing
if (pair.symbol.startsWith('ADA')) {
pair.trade = { capital: 1 };
return pair;
}
// remove others; we can not use all pairs in one instance; (only on when we not in quarterly contract change window)
return undefined;
}))
);
// FTX all "perp" / futures contracts
c.symbols.push(...(await InstanceUtil.ftxInitPerp()));
// Binance all USDT pairs
c.symbols.push(...(await InstanceUtil.binanceInitUsd()));
// Binance all USDT pairs spot or margin
// c.symbols.push(...(await InstanceUtil.binanceInitMarginUsd()));
// c.symbols.push(...(await InstanceUtil.binanceInitSpotUsd()));
// Binance futures
c.symbols.push(...(await InstanceUtil.binanceFuturesInit()));
// Binance futures or trade with 2 USD
c.symbols.push(
...(await InstanceUtil.binanceFuturesInit(pair => {
pair.trade = { currency_capital: 2 };
return pair;
}))
);
// Bitfinex USD margin pairs
c.symbols.push(...(await InstanceUtil.bitfinexUsdMarginInit()));
// Bybit USD pairs
c.symbols.push(...(await InstanceUtil.bybitInit()));
};
*/
/*
// external loading; lazy init
c.init = () => {
return new Promise(resolve => {
require('request')('https://api.binance.com/api/v1/exchangeInfo', (error, response, body) => {
let z = [
'BNBBTC', 'QKCBTC', 'XVGBTC', 'STRATBTC', 'LUNBTC', 'NANOBTC', 'LOOMBTC', 'VIBEBTC', 'PIVXBTC', 'MCOBTC', 'APPCBTC', 'STORJBTC', 'ELFBTC', 'ENJBTC', 'KNCBTC', 'RVNBTC', 'WANBTC', 'HCBTC',
]
let trading = {
//'BTCUSDT': 50,
'TNTBTC': 6622,
'ADAUSDT': 300,
//'TUSDUSDT': 50,
'ONTUSDT': 40,
}
// only USDT pairs, because of its volume and ignore stable coin pairing
JSON.parse(body)['symbols']
.filter(p => p['quoteAsset'] === 'USDT' && !['USDC', 'PAX', 'USDS', 'TUSD'].includes(p['baseAsset']) && p['status'].toLowerCase() === 'trading')
.forEach(p => {
z.push(p['symbol'])
trading[p['symbol']] = 50
}
)
z.forEach((pair) => {
let cfg = {
'symbol': pair,
'periods': ['1m', '15m', '1h'],
'exchange': 'binance',
'state': 'watch',
'watchdogs': [
{
'name': 'stoploss_watch',
'stop': 1.5,
}
],
'strategies': [
{
'strategy': 'cci',
'options': {
'period': '15m'
}
},
{
'strategy': 'obv_pump_dump'
},
{
'strategy': 'macd',
'options': {
'period': '1h'
}
}
]
};
if (pair in trading) {
cfg['trade'] = {
'capital': trading[pair],
}
}
c.symbols.push(cfg)
})
resolve()
})
})
}
*/
// bitmex
let y = [
'XBTUSD', 'ETHUSD'
]
y.forEach((pair) => {
c.symbols.push({
'symbol': pair,
'periods': ['1m', '15m', '1h'],
'exchange': 'bitmex',
'state': 'watch',
'extra': {
'bitmex_leverage': 5,
'bitmex_rest_order_sync': 45000
},
//'trade': {
// 'currency_capital': 1 // trade with 1 USD dollar
//},
//'watchdogs': [
// {
// 'name': 'stoploss',
// 'percent': 3,
// },
// {
// 'name': 'risk_reward_ratio',
// 'target_percent': 3,
// 'stop_percent': 3,
// }
//],
'strategies': [
{
'strategy': 'cci',
'options': {
'period': '15m'
}
},
{
'strategy': 'obv_pump_dump'
},
{
'strategy': 'macd',
'options': {
'period': '1h'
}
}
]
})
})
// bitmex testnet
let l = [
'XBTUSD'
]
l.forEach((pair) => {
c.symbols.push({
'symbol': pair,
'periods': ['1m', '15m', '1h'],
'exchange': 'bitmex_testnet',
'state': 'watch',
'watchdogs': [
{
'name': 'stoploss',
'percent': 3,
}
],
'extra': {
'bitmex_leverage': 5,
},
'trade': {
'capital': 50,
},
'strategies': [
{
'strategy': 'cci',
'options': {
'period': '15m'
}
},
{
'strategy': 'obv_pump_dump'
},
{
'strategy': 'macd',
'options': {
'period': '1h'
}
}
]
})
})
let z = [
'BTCUSDT', 'XLMUSDT', 'BNBBTC', 'BNBUSDT'
]
z.forEach((pair) => {
c.symbols.push({
'symbol': pair,
'periods': ['1m', '15m', '1h'],
'exchange': 'binance',
'state': 'watch',
'strategies': [
{
'strategy': 'cci',
'options': {
'period': '15m'
}
},
{
'strategy': 'obv_pump_dump'
},
{
'strategy': 'macd',
'options': {
'period': '1h'
}
}
]
})
})