From 1309c2b14f50c55acdbdeaaf217aba34dfd7656b Mon Sep 17 00:00:00 2001 From: Nullart2 Date: Sun, 5 Aug 2018 22:56:14 +0800 Subject: [PATCH] tests update --- freqtrade/freqtradebot.py | 6 +++--- freqtrade/tests/test_freqtradebot.py | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index f1955a9d7..496ef1168 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -260,7 +260,8 @@ class FreqtradeBot(object): if ticker_rate < order_book_rate: logger.info('...using ticker rate instead %0.8f', ticker_rate) used_rate = ticker_rate - used_rate = order_book_rate + else: + used_rate = order_book_rate else: logger.info('Using Last Ask / Last Price') used_rate = ticker_rate @@ -557,8 +558,7 @@ class FreqtradeBot(object): ticker) experimental_ask_strategy = self.config.get('experimental', {}).get('ask_strategy', {}) - if 'use_order_book' in experimental_ask_strategy and\ - experimental_ask_strategy.get('use_order_book', False): + if experimental_ask_strategy.get('use_order_book', False): logger.info('Using order book for selling...') # logger.debug('Order book %s',orderBook) order_book_min = experimental_ask_strategy.get('order_book_min', 1) diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 563f9961b..6282720d6 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -1938,11 +1938,12 @@ def test_order_book_bid_strategy(default_conf) -> None: default_conf['exchange']['name'] = 'binance' default_conf['experimental']['bid_strategy']['use_order_book'] = True default_conf['experimental']['bid_strategy']['order_book_top'] = 2 + default_conf['bid_strategy']['ask_last_balance'] = 0 default_conf['telegram']['enabled'] = False freqtrade = FreqtradeBot(default_conf) - assert freqtrade.get_target_bid('ETH/BTC', {'ask': 20, 'last': 10}) != 20 + assert freqtrade.get_target_bid('BTC/USDT', {'ask': 2, 'last': 2}) == 2 def test_trunc_num(default_conf) -> None: @@ -1990,3 +1991,10 @@ def test_order_book_ask_strategy(default_conf, limit_buy_order, limit_sell_order trade = Trade.query.first() assert trade + + time.sleep(0.01) # Race condition fix + trade.update(limit_buy_order) + assert trade.is_open is True + + patch_get_signal(freqtrade, value=(False, True)) + assert freqtrade.handle_trade(trade) is True