Allow forcebuy price to be a string by converting it to float

fix #3970
This commit is contained in:
Matthias 2020-11-21 10:39:49 +01:00
parent aa0c3dced8
commit 5ed85963a9
3 changed files with 5 additions and 2 deletions

View File

@ -508,6 +508,8 @@ class ApiServer(RPC):
""" """
asset = request.json.get("pair") asset = request.json.get("pair")
price = request.json.get("price", None) price = request.json.get("price", None)
price = float(price) if price is not None else price
trade = self._rpc_forcebuy(asset, price) trade = self._rpc_forcebuy(asset, price)
if trade: if trade:
return jsonify(trade.to_json()) return jsonify(trade.to_json())

View File

@ -524,7 +524,7 @@ class RPC:
stake_currency = self._freqtrade.config.get('stake_currency') stake_currency = self._freqtrade.config.get('stake_currency')
if not self._freqtrade.exchange.get_pair_quote_currency(pair) == stake_currency: if not self._freqtrade.exchange.get_pair_quote_currency(pair) == stake_currency:
raise RPCException( raise RPCException(
f'Wrong pair selected. Please pairs with stake {stake_currency} pairs only') f'Wrong pair selected. Only pairs with stake-currency {stake_currency} allowed.')
# check if valid pair # check if valid pair
# check if pair already has an open pair # check if pair already has an open pair

View File

@ -868,7 +868,8 @@ def test_rpcforcebuy(mocker, default_conf, ticker, fee, limit_buy_order_open) ->
assert trade.open_rate == 0.0001 assert trade.open_rate == 0.0001
# Test buy pair not with stakes # Test buy pair not with stakes
with pytest.raises(RPCException, match=r'Wrong pair selected. Please pairs with stake.*'): with pytest.raises(RPCException,
match=r'Wrong pair selected. Only pairs with stake-currency.*'):
rpc._rpc_forcebuy('LTC/ETH', 0.0001) rpc._rpc_forcebuy('LTC/ETH', 0.0001)
pair = 'XRP/BTC' pair = 'XRP/BTC'