Skip to content

Commit

Permalink
added loadTradingLimits to Exchange.js, moved from huobipro, added ha…
Browse files Browse the repository at this point in the history
…s["fetchTradingLimits"] = false to cointiger
  • Loading branch information
kroitor committed May 31, 2018
1 parent e7306ff commit 16c868c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
19 changes: 19 additions & 0 deletions js/base/Exchange.js
Expand Up @@ -100,6 +100,7 @@ module.exports = class Exchange {
'fetchTickers': false,
'fetchTrades': true,
'fetchTradingFees': false,
'fetchTradingLimits': false,
'withdraw': false,
},
'urls': {
Expand Down Expand Up @@ -882,6 +883,24 @@ module.exports = class Exchange {
return this.fetchPartialBalance ('total', params)
}

async loadTradingLimits (symbols = undefined, reload = false, params = {}) {
if (this.has['fetchTradingLimits']) {
if (reload || !('limitsLoaded' in this.options)) {
let response = await this.fetchTradingLimits (symbols);
let limits = response['limits'];
let keys = Object.keys (limits);
for (let i = 0; i < keys.length; i++) {
let symbol = keys[i];
this.markets[symbol] = this.deepExtend (this.markets[symbol], {
'limits': limits[symbol],
});
}
this.options['limitsLoaded'] = this.milliseconds ();
}
}
return this.markets;
}

filterBySinceLimit (array, since = undefined, limit = undefined) {
if (typeof since !== 'undefined')
array = array.filter (entry => entry.timestamp >= since)
Expand Down
1 change: 1 addition & 0 deletions js/cointiger.js
Expand Up @@ -17,6 +17,7 @@ module.exports = class cointiger extends huobipro {
'has': {
'fetchCurrencies': false,
'fetchTickers': true,
'fetchTradingLimits': false,
'fetchOrder': false,
},
'headers': {
Expand Down
15 changes: 0 additions & 15 deletions js/huobipro.js
Expand Up @@ -127,21 +127,6 @@ module.exports = class huobipro extends Exchange {
});
}

async loadTradingLimits (symbols = undefined, reload = false, params = {}) {
if (reload || !('limitsLoaded' in this.options)) {
let response = await this.fetchTradingLimits (symbols);
let limits = response['limits'];
let keys = Object.keys (limits);
for (let i = 0; i < keys.length; i++) {
let symbol = keys[i];
this.markets[symbol] = this.deepExtend (this.markets[symbol], {
'limits': limits[symbol],
});
}
}
return this.markets;
}

async fetchTradingLimits (symbols = undefined, params = {}) {
// by default it will try load withdrawal fees of all currencies (with separate requests)
// however if you define codes = [ 'ETH', 'BTC' ] in args it will only load those
Expand Down

0 comments on commit 16c868c

Please sign in to comment.