-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (24 loc) · 876 Bytes
/
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
const binance = require('node-binance-api');
const binanceConstants = require('./binance.json');
const CronJob = require('cron').CronJob;
const MongoClient = require('mongodb').MongoClient;
binance.options({
APIKEY: binanceConstants.API_KEY,
APISECRET: binanceConstants.API_SECRET,
useServerTime: true, // If you get timestamp errors, synchronize to server time at startup
test: true // If you want to use sandbox mode where orders are simulated
});
const getTicker = () => {
binance.bookTickers((error, ticker) => {
const exchanges = ticker
.filter(x => x.symbol.endsWith(binanceConstants.MARKET))
.map(x => ({
symbol: x.symbol,
price: x.bidPrice
}))
.forEach(x => {
//doCalc on x
});
});
}
const job = new CronJob('0 */60 * * * *', getTicker, () => { /*on complete */ }, true, 'America/Los_Angeles');