Skip to content

Commit

Permalink
Base Exchange class: new property: precisionMode.
Browse files Browse the repository at this point in the history
Defaults to DECIMAL_PLACES but is set to SIGNIFICANT_DIGITS for bitfinex.
  • Loading branch information
mkutny committed Mar 30, 2018
1 parent 7724c76 commit 251449c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions js/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module.exports = class Exchange {
'BCC': 'BCH',
'DRK': 'DASH',
},
'precisionMode': this.DECIMAL_PLACES,
} // return
} // describe ()

Expand Down
10 changes: 5 additions & 5 deletions js/bitfinex.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module.exports = class bitfinex extends Exchange {
'Invalid order': InvalidOrder, // ?
},
},
'significantPrecision': true,
'precisionMode': this.SIGNIFICANT_DIGITS,
});
}

Expand Down Expand Up @@ -329,19 +329,19 @@ module.exports = class bitfinex extends Exchange {
}

costToPrecision (symbol, cost) {
return this.decimalToPrecision (parseFloat (cost), this.ROUND, this.markets[symbol].precision.price, this.SIGNIFICANT_DIGITS);
return this.decimalToPrecision (parseFloat (cost), this.ROUND, this.markets[symbol].precision.price, this.precisionMode);
}

priceToPrecision (symbol, price) {
return this.decimalToPrecision (parseFloat (price), this.ROUND, this.markets[symbol].precision.price, this.SIGNIFICANT_DIGITS);
return this.decimalToPrecision (parseFloat (price), this.ROUND, this.markets[symbol].precision.price, this.precisionMode);
}

amountToPrecision (symbol, amount) {
return this.decimalToPrecision (parseFloat (amount), this.ROUND, this.markets[symbol].precision.amount, this.SIGNIFICANT_DIGITS);
return this.decimalToPrecision (parseFloat (amount), this.ROUND, this.markets[symbol].precision.amount, this.precisionMode);
}

feeToPrecision (currency, fee) {
return this.decimalToPrecision (parseFloat (fee), this.ROUND, this.currencies[currency]['precision'], this.SIGNIFICANT_DIGITS);
return this.decimalToPrecision (parseFloat (fee), this.ROUND, this.currencies[currency]['precision'], this.precisionMode);
}

calculateFee (symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
Expand Down
2 changes: 2 additions & 0 deletions php/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ public function __construct ($options = array ()) {
'withdraw' => false,
);

$this->precisionMode = this->DECIMAL_PLACES;

$this->lastRestRequestTimestamp = 0;
$this->lastRestPollTimestamp = 0;
$this->restRequestQueue = null;
Expand Down
2 changes: 2 additions & 0 deletions python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class Exchange(object):
'withdraw': False,
}

precisionMode = self.DECIMAL_PLACES

minFundingAddressLength = 10 # used in check_address
substituteCommonCurrencyCodes = True
lastRestRequestTimestamp = 0
Expand Down

0 comments on commit 251449c

Please sign in to comment.