UNPKG

@azteam/huobi-api

Version:

N/A

32 lines (25 loc) 821 B
import {CandlestickChart, TIME_CHART} from '@azteam/candlestick-chart'; import {timeout} from '@azteam/util'; import HuobiAPI from './HuobiAPI'; class HuobiTradeTool extends CandlestickChart { constructor({symbol, pricePrecision}) { super('Asia/Singapore', pricePrecision); this.symbol = symbol; } async getHistoryData(time, timeChart = TIME_CHART._1_MIN.name) { let data = []; let retry = 200; do { try { data = await HuobiAPI.getLinearSwapHistory(this.symbol, timeChart, time); retry = 0; } catch (err) { console.error(err); retry -= 1; await timeout(5000); } } while (retry); return data; } } export default HuobiTradeTool;