Merge pull request #880 from freqtrade/fix/636

Fixes issue 636
This commit is contained in:
Janne Sinivirta 2018-06-09 08:59:12 +03:00 committed by GitHub
commit 8db3dfa8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -252,8 +252,6 @@ class FreqtradeBot(object):
""" """
Checks the implemented trading indicator(s) for a randomly picked pair, Checks the implemented trading indicator(s) for a randomly picked pair,
if one pair triggers the buy_signal a new trade record gets created if one pair triggers the buy_signal a new trade record gets created
:param stake_amount: amount of btc to spend
:param interval: Ticker interval used for Analyze
:return: True if a trade object has been created and persisted, False otherwise :return: True if a trade object has been created and persisted, False otherwise
""" """
stake_amount = self.config['stake_amount'] stake_amount = self.config['stake_amount']
@ -448,6 +446,12 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
for trade in Trade.query.filter(Trade.open_order_id.isnot(None)).all(): for trade in Trade.query.filter(Trade.open_order_id.isnot(None)).all():
try: try:
# FIXME: Somehow the query above returns results
# where the open_order_id is in fact None.
# This is probably because the record got
# updated via /forcesell in a different thread.
if not trade.open_order_id:
continue
order = exchange.get_order(trade.open_order_id, trade.pair) order = exchange.get_order(trade.open_order_id, trade.pair)
except requests.exceptions.RequestException: except requests.exceptions.RequestException:
logger.info( logger.info(
@ -478,8 +482,6 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
if order['remaining'] == order['amount']: if order['remaining'] == order['amount']:
# if trade is not partially completed, just delete the trade # if trade is not partially completed, just delete the trade
Trade.session.delete(trade) Trade.session.delete(trade)
# FIX? do we really need to flush, caller of
# check_handle_timedout will flush afterwards
Trade.session.flush() Trade.session.flush()
logger.info('Buy order timeout for %s.', trade) logger.info('Buy order timeout for %s.', trade)
self.rpc.send_msg(f'*Timeout:* Unfilled buy order for {pair_s} cancelled') self.rpc.send_msg(f'*Timeout:* Unfilled buy order for {pair_s} cancelled')

View File

@ -354,6 +354,7 @@ class RPC(object):
return True, 'Invalid argument.' return True, 'Invalid argument.'
_exec_forcesell(trade) _exec_forcesell(trade)
Trade.session.flush()
return False, '' return False, ''
def rpc_performance(self) -> Tuple[bool, Any]: def rpc_performance(self) -> Tuple[bool, Any]: