-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelper.js
More file actions
29 lines (25 loc) · 752 Bytes
/
helper.js
File metadata and controls
29 lines (25 loc) · 752 Bytes
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
const config = require('./config').api;
const Binance = require('node-binance-api');
const logger = require('./logger').logger();
const binance = new Binance().options({
APIKEY: config.key,
APISECRET: config.secret
});
exports.sleep = function(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
exports.getHistoric = async function (pair, interval, options = {}) {
let params = {
limit: 1000,
...options
}
try {
let values = await binance.candlesticks(pair, interval, null, params);
return values;
} catch (e) {
logger.error('Error while retrieving info, trying again... -> ' + e);
}
}
exports.getPair = function (pair){
return pair.first + pair.second;
}