-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js.map
1 lines (1 loc) · 6.65 KB
/
app.js.map
1
{"version":3,"file":"app.js","sources":["src/app.coffee"],"sourcesContent":["# import binance from 'node-binance-api'\nbinance = require 'node-binance-api'\n\nbinance.options\n APIKEY: 'KdVTR61jfhhOj26FXTLDfg4CcvpVlkGV4Zj4COgh1xwdHY3Sug21o96g0MkeR8YN'\n APISECRET: '5jT3Klj4TXlNunhcKOKOjyMjBLacxMKkJCdbpcw5KdcUtT0JE5MBWOvOtnZGq3N4'\n\n# initialize a member of the dict as a struct or update a specific field in the\n# struct\ninitOrMerge = (dict, key, field, value) ->\n if !dict[key]?\n dict[key] = {}\n\n dict[key][field] = value\n\n return dict\n\n# baseUrl for manual request\nbaseUrl = 'https://api.binance.com/api/'\n\n# Period list\nperiods = [\n '1m'\n '3m'\n '5m'\n '15m'\n '30m'\n '1h'\n '1d'\n '3d'\n '1w'\n '1M'\n]\n # '2h'\n # '4h'\n # '6h'\n # '8h'\n # '12h'\n\n# Main loop\ngo = ->\n # Phase 1 promises\n p1s = []\n\n # Time\n millis = (new Date).getTime()\n\n # Dictionary\n dict = {\n # time: millis\n }\n\n p1s.push new Promise((resolve, reject)->\n # Instantaneous Price of Stock\n binance.prices (prices) ->\n for code, price of prices\n initOrMerge dict, code, 'price', parseFloat(price)\n\n # console.log 'prices()', dict\n resolve dict\n ).catch (err)->\n console.log 'prices() error', err\n\n p1s.push new Promise((resolve, reject)->\n # Instantenous Bid/Ask Summary\n binance.bookTickers (tickers) ->\n for code, ticker of tickers\n for k, v of ticker\n ticker[k] = parseFloat v\n initOrMerge dict, code, 'ticker', ticker\n\n # console.log 'bookTickers()', dict\n resolve dict\n ).catch (err)->\n console.log 'bookTickers() error', err\n\n Promise.all(p1s).then ->\n console.log 'Phase 1', dict\n\n # Phase 2 promises\n p2s = []\n\n for code, obj of dict\n p2s.push new Promise((resolve, reject)->\n # Instantenous Bid/Ask List\n binance.depth code, (depth, symbol) ->\n dict[symbol].depth = depth\n\n # console.log 'depth()', dict\n resolve dict\n ).catch (err)->\n console.log 'depth() error', err\n\n offset = 0\n # Seems like overkill, we\n for period in periods\n p2s.push new Promise((resolve, reject)->\n # stagget the calls so we don't spam it to death\n setTimeout ->\n # Historic Candle Sticks\n console.log offset, code, period\n binance.publicRequest baseUrl+'v1/klines', {symbol: code, interval: period, limit: 1}, (ticks) ->\n lastTick = ticks[ticks.length - 1]\n [time, open, high, low, close, volume, closeTime, assetVolume, trades, buyBaseVolume, buyAssetVolume, ignored] = lastTick\n\n dict[code]['candlestick' +period] =\n time: time\n open: parseFloat open\n high: parseFloat high\n low: parseFloat low\n close: parseFloat close\n volume: parseFloat volume\n closeTime: closeTime\n assetVolume: parseFloat assetVolume\n trades: trades\n buyBaseVolume: parseFloat buyBaseVolume\n buyAssetVolume: parseFloat buyAssetVolume\n ignored: parseFloat ignored\n\n console.log 'candlesticks()', dict[code]\n resolve dict\n , offset * 40\n # increment offset\n offset++\n ).catch (err)->\n console.log 'candlesticks() error', err\n\n # setTimeout go, 10000\ngo()\n"],"names":[],"mappings":";;;;AAAA,IAAA,OAAA;IAAA,OAAA;IAAA,EAAA;IAAA,WAAA;IAAA;;AACA,OAAA,GAAU,OAAA,CAAQ,kBAAR;;AAEV,OAAO,CAAC,OAAR,CACE;EAAA,MAAA,EAAW,kEAAX;EACA,SAAA,EAAW;CAFb,EAHA;;;;AASA,WAAA,GAAc,SAAC,IAAD,EAAO,GAAP,EAAY,KAAZ,EAAmB,KAAnB;EACZ,IAAI,iBAAJ;IACE,IAAK,CAAA,GAAA,CAAL,GAAY,GADd;;EAGA,IAAK,CAAA,GAAA,CAAK,CAAA,KAAA,CAAV,GAAmB;SAEZ;EAfT;;;AAkBA,OAAA,GAAU,+BAlBV;;;AAqBA,OAAA,GAAU,CACR,IADQ,EAER,IAFQ,EAGR,IAHQ,EAIR,KAJQ,EAKR,KALQ,EAMR,IANQ,EAOR,IAPQ,EAQR,IARQ,EASR,IATQ,E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