UNPKG

ccxt-compiled

Version:

A JavaScript / Python / PHP cryptocurrency trading library with support for 90+ exchanges

74 lines (61 loc) 3.09 kB
"use strict"; // --------------------------------------------------------------------------- var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const zb = require('./zb.js'); const { ExchangeError, ExchangeNotAvailable } = require('./base/errors'); // --------------------------------------------------------------------------- module.exports = class chbtc extends zb { describe() { return this.deepExtend(super.describe(), { 'id': 'chbtc', 'name': 'CHBTC', 'countries': 'CN', 'rateLimit': 1000, 'version': 'v1', 'hasCORS': false, 'hasFetchOrder': true, 'urls': { 'logo': 'https://user-images.githubusercontent.com/1294454/28555659-f0040dc2-7109-11e7-9d99-688a438bf9f4.jpg', 'api': { 'public': 'http://api.chbtc.com/data', // no https for public API 'private': 'https://trade.chbtc.com/api' }, 'www': 'https://trade.chbtc.com/api', 'doc': 'https://www.chbtc.com/i/developer' } }); } getMarketFieldName() { return 'currency'; } fetchMarkets() { return (0, _asyncToGenerator3.default)(function* () { return { 'BTC/CNY': { 'id': 'btc_cny', 'symbol': 'BTC/CNY', 'base': 'BTC', 'quote': 'CNY' }, 'LTC/CNY': { 'id': 'ltc_cny', 'symbol': 'LTC/CNY', 'base': 'LTC', 'quote': 'CNY' }, 'ETH/CNY': { 'id': 'eth_cny', 'symbol': 'ETH/CNY', 'base': 'ETH', 'quote': 'CNY' }, 'ETC/CNY': { 'id': 'etc_cny', 'symbol': 'ETC/CNY', 'base': 'ETC', 'quote': 'CNY' }, 'BTS/CNY': { 'id': 'bts_cny', 'symbol': 'BTS/CNY', 'base': 'BTS', 'quote': 'CNY' }, // 'EOS/CNY': { 'id': 'eos_cny', 'symbol': 'EOS/CNY', 'base': 'EOS', 'quote': 'CNY' }, 'BCH/CNY': { 'id': 'bcc_cny', 'symbol': 'BCH/CNY', 'base': 'BCH', 'quote': 'CNY' }, 'HSR/CNY': { 'id': 'hsr_cny', 'symbol': 'HSR/CNY', 'base': 'HSR', 'quote': 'CNY' }, 'QTUM/CNY': { 'id': 'qtum_cny', 'symbol': 'QTUM/CNY', 'base': 'QTUM', 'quote': 'CNY' } }; })(); } request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) { var _this = this; return (0, _asyncToGenerator3.default)(function* () { let response = yield _this.fetch2(path, api, method, params, headers, body); if (api == 'private') { if ('code' in response) throw new ExchangeError(_this.id + ' ' + _this.json(response)); } if ('result' in response) { if (!response['result']) throw new ExchangeError(_this.id + ' ' + _this.json(response)); } return response; })(); } };