-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-repeat.js
30 lines (27 loc) · 988 Bytes
/
index-repeat.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
const coinTicker = require('coin-ticker')
const INTERVAL = 10000 // 60 * 60 * 1000
const DATA_TO_LOAD = [
{exchange: "poloniex", pair: "BTC_USD"},
{exchange: "poloniex", pair: "ETH_USD"},
{exchange: "poloniex", pair: "DASH_USD"},
{exchange: "poloniex", pair: "XRP_USD"},
{exchange: "poloniex", pair: "XMR_USD"},
{exchange: "poloniex", pair: "ETC_USD"},
{exchange: "poloniex", pair: "ZEC_USD"},
{exchange: "poloniex", pair: "LTC_USD"}
]
const config = require('./config.json')
const gcs = require('@google-cloud/storage')({
projectId: config.GOOGLE_STORAGE.PROJECT_ID,
keyFilename: config.GOOGLE_STORAGE.CREDENTIALS_FILE
})
const storeInGcs = require('./store-gcs')(config, gcs)
refresh = (exchange, pair) => coinTicker(exchange, pair)
repeat = () => setTimeout(() => loadData(), INTERVAL)
loadData = () => {
for (i in DATA_TO_LOAD) {
refresh(DATA_TO_LOAD[i].exchange, DATA_TO_LOAD[i].pair).then((result) => storeInGcs(result))
}
repeat()
}
loadData()