-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathindex.js
75 lines (65 loc) · 2.12 KB
/
index.js
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
// load logger library
const logger = require('./lib/LoggerCore');
var env = require('node-env-file');
try {
env(__dirname + '/.keys');
} catch (e) {
console.warn('No .keys was provided, running with defaults.');
}
env(__dirname + '/conf.ini');
logger.info('\n\n\n----- Bot Starting : -----\n\n\n');
var exchangeAPI = {};
logger.info('--- Loading Exchange API');
// make exchange module dynamic later
if (process.env.activeExchange == 'binance'){
logger.info('--- \tActive Exchange:' + process.env.activeExchange);
// activePairs = process.env.binancePairs;
const api = require('binance');
const beautifyResponse = false;
exchangeAPI = new api.BinanceRest({
timeout: parseInt(process.env.restTimeout), // Optional, defaults to 15000, is the request time out in milliseconds
recvWindow: parseInt(process.env.restRecvWindow), // Optional, defaults to 5000, increase if you're getting timestamp errors
disableBeautification: beautifyResponse
});
exchangeAPI.WS = new api.BinanceWS(beautifyResponse);
}
var botOptions = {
UI: {
title: 'Top Potential Arbitrage Triplets, via: ' + process.env.binanceColumns
},
arbitrage: {
paths: process.env.binanceColumns.split(','),
start: process.env.binanceStartingPoint
},
storage: {
logHistory: false
},
trading: {
paperOnly: true,
// only candidates with over x% gain potential are queued for trading
minQueuePercentageThreshold: 3,
// how many times we need to see the same opportunity before deciding to act on it
minHitsThreshold: 5
}
},
ctrl = {
options: botOptions,
storage: {
trading: {
// queued triplets
queue: [],
// actively trading triplets
active: []
},
candidates: [],
streams: [],
pairRanks: []
},
logger: logger,
exchange: exchangeAPI
};
ctrl.UI = require('./lib/UI')(ctrl.options),
ctrl.events = require('./lib/EventsCore')(ctrl);
// We're ready to start. Load up the webhook streams and start making it rain.
require('./lib/BotCore')(ctrl);
ctrl.logger.info('----- Bot Startup Finished -----');