simplify return from _get_sell_trade_entry

This commit is contained in:
xmatthias 2018-06-10 09:07:04 +02:00
parent 3094acc7fb
commit c1b2e06eda

View File

@ -128,8 +128,7 @@ class Backtesting(object):
trade.calc_profit_percent(rate=sell_row.close), trade.calc_profit_percent(rate=sell_row.close),
trade.calc_profit(rate=sell_row.close), trade.calc_profit(rate=sell_row.close),
(sell_row.date - buy_row.date).seconds // 60 (sell_row.date - buy_row.date).seconds // 60
), \ )
sell_row.date
if partial_ticker: if partial_ticker:
# no sell condition found - trade stil open at end of backtest period # no sell condition found - trade stil open at end of backtest period
sell_row = partial_ticker[-1] sell_row = partial_ticker[-1]
@ -143,8 +142,7 @@ class Backtesting(object):
trade.calc_profit_percent(rate=sell_row.close), trade.calc_profit_percent(rate=sell_row.close),
trade.calc_profit(rate=sell_row.close), trade.calc_profit(rate=sell_row.close),
(sell_row.date - buy_row.date).seconds // 60 (sell_row.date - buy_row.date).seconds // 60
), \ )
sell_row.date
return None return None
def backtest(self, args: Dict) -> DataFrame: def backtest(self, args: Dict) -> DataFrame:
@ -208,8 +206,8 @@ class Backtesting(object):
trade_count_lock, args) trade_count_lock, args)
if ret: if ret:
row2, trade_entry, next_date = ret row2, trade_entry = ret
lock_pair_until = next_date lock_pair_until = row2.date
trades.append(trade_entry) trades.append(trade_entry)
if record: if record:
# Note, need to be json.dump friendly # Note, need to be json.dump friendly