From dc86a6abc5ec9a5423dbfa4e96ad70cb04373699 Mon Sep 17 00:00:00 2001 From: shubhendra Date: Sat, 6 Mar 2021 13:01:05 +0530 Subject: [PATCH] Refactor unnecessary `else` / `elif` when `if` block has a `continue` statement Signed-off-by: shubhendra --- qlib/contrib/backtest/account.py | 7 +++---- qlib/contrib/backtest/exchange.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/qlib/contrib/backtest/account.py b/qlib/contrib/backtest/account.py index d8b285019..a614f08b6 100644 --- a/qlib/contrib/backtest/account.py +++ b/qlib/contrib/backtest/account.py @@ -104,10 +104,9 @@ class Account: # if suspend, no new price to be updated, profit is 0 if trader.check_stock_suspended(code, today): continue - else: - today_close = trader.get_close(code, today) - profit += (today_close - self.current.position[code]["price"]) * self.current.position[code]["amount"] - self.current.update_stock_price(stock_id=code, price=today_close) + today_close = trader.get_close(code, today) + profit += (today_close - self.current.position[code]["price"]) * self.current.position[code]["amount"] + self.current.update_stock_price(stock_id=code, price=today_close) self.rtn += profit # update holding day count self.current.add_count_all() diff --git a/qlib/contrib/backtest/exchange.py b/qlib/contrib/backtest/exchange.py index 5a8b8b2b6..cbb3d7932 100644 --- a/qlib/contrib/backtest/exchange.py +++ b/qlib/contrib/backtest/exchange.py @@ -325,7 +325,7 @@ class Exchange: deal_amount = self.get_real_deal_amount(current_amount, target_amount, factor) if deal_amount == 0: continue - elif deal_amount > 0: + if deal_amount > 0: # buy stock buy_order_list.append( Order(