-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogger.js
More file actions
31 lines (22 loc) · 1.41 KB
/
logger.js
File metadata and controls
31 lines (22 loc) · 1.41 KB
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
"use strict";
const config = require('./config'),
_ = require('underscore'),
Markets = require('./Services/Markets/Markets'),
MarketModel = require('./App/Models/marketModel'),
PriceModel = require('./App/Models/priceModel');
setInterval(async function () {
let marketResults = await MarketModel.findAll({});
for(let marketResult of marketResults){
let marketClass = _.findWhere(Markets, {id: marketResult.id.toString()});
marketClass.class.init(marketResult.default_hashed_username, marketResult.default_hashed_special_key, marketResult.default_hashed_secret_key);
marketClass.class.multiSymbol('BTC/BCH/ETH/USD').then(function (result) {
let BTC_USD = _.findWhere(result.data, {pair: 'BTC:USD'});
let BCH_USD = _.findWhere(result.data, {pair: 'BCH:USD'});
let ETH_USD = _.findWhere(result.data, {pair: 'ETH:USD'});
PriceModel.create({ ask: BTC_USD.ask, bid: BTC_USD.bid, symbol: 'BTC/USD', market_id: marketResult.id, timestamp: BTC_USD.timestamp});
PriceModel.create({ ask: ETH_USD.ask, bid: ETH_USD.bid, symbol: 'ETH/USD', market_id: marketResult.id, timestamp: ETH_USD.timestamp});
PriceModel.create({ ask: BCH_USD.ask, bid: BCH_USD.bid, symbol: 'BCH/USD', market_id: marketResult.id, timestamp: BCH_USD.timestamp});
});
}
},
10000);