Skip to content

Commit

Permalink
Allow forcebuy price to be a string by converting it to float
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Nov 21, 2020
1 parent aa0c3dc commit 5ed8596
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions freqtrade/rpc/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ def _forcebuy(self):
"""
asset = request.json.get("pair")
price = request.json.get("price", None)
price = float(price) if price is not None else price

trade = self._rpc_forcebuy(asset, price)
if trade:
return jsonify(trade.to_json())
Expand Down
2 changes: 1 addition & 1 deletion freqtrade/rpc/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def _rpc_forcebuy(self, pair: str, price: Optional[float]) -> Optional[Trade]:
stake_currency = self._freqtrade.config.get('stake_currency')
if not self._freqtrade.exchange.get_pair_quote_currency(pair) == stake_currency:
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 pair already has an open pair
Expand Down
3 changes: 2 additions & 1 deletion tests/rpc/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ def test_rpcforcebuy(mocker, default_conf, ticker, fee, limit_buy_order_open) ->
assert trade.open_rate == 0.0001

# 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)
pair = 'XRP/BTC'

Expand Down

0 comments on commit 5ed8596

Please sign in to comment.