Use ccxt.decimal_to_precision instead of our own calculation
This commit is contained in:
@@ -181,6 +181,11 @@ def test_symbol_amount_prec(default_conf, mocker):
|
||||
markets = PropertyMock(return_value={'ETH/BTC': {'precision': {'amount': 4}}})
|
||||
|
||||
exchange = get_patched_exchange(mocker, default_conf, id="binance")
|
||||
# digits counting mode
|
||||
# DECIMAL_PLACES = 2
|
||||
# SIGNIFICANT_DIGITS = 3
|
||||
# TICK_SIZE = 4
|
||||
mocker.patch('freqtrade.exchange.Exchange.precisionMode', PropertyMock(return_value=2))
|
||||
mocker.patch('freqtrade.exchange.Exchange.markets', markets)
|
||||
|
||||
amount = 2.34559
|
||||
@@ -188,6 +193,12 @@ def test_symbol_amount_prec(default_conf, mocker):
|
||||
amount = exchange.symbol_amount_prec(pair, amount)
|
||||
assert amount == 2.3455
|
||||
|
||||
markets = PropertyMock(return_value={'ETH/BTC': {'precision': {'amount': 0.0001}}})
|
||||
mocker.patch('freqtrade.exchange.Exchange.precisionMode', PropertyMock(return_value=4))
|
||||
mocker.patch('freqtrade.exchange.Exchange.markets', markets)
|
||||
amount = exchange.symbol_amount_prec(pair, amount)
|
||||
assert amount == 2.3455
|
||||
|
||||
|
||||
def test_symbol_price_prec(default_conf, mocker):
|
||||
'''
|
||||
@@ -197,12 +208,20 @@ def test_symbol_price_prec(default_conf, mocker):
|
||||
|
||||
exchange = get_patched_exchange(mocker, default_conf, id="binance")
|
||||
mocker.patch('freqtrade.exchange.Exchange.markets', markets)
|
||||
mocker.patch('freqtrade.exchange.Exchange.precisionMode', PropertyMock(return_value=2))
|
||||
|
||||
price = 2.34559
|
||||
pair = 'ETH/BTC'
|
||||
price = exchange.symbol_price_prec(pair, price)
|
||||
assert price == 2.3456
|
||||
|
||||
markets = PropertyMock(return_value={'ETH/BTC': {'precision': {'price': 0.0001}}})
|
||||
mocker.patch('freqtrade.exchange.Exchange.precisionMode', PropertyMock(return_value=4))
|
||||
mocker.patch('freqtrade.exchange.Exchange.markets', markets)
|
||||
|
||||
price = exchange.symbol_price_prec(pair, price)
|
||||
assert price == 2.3456
|
||||
|
||||
|
||||
def test_set_sandbox(default_conf, mocker):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user