make tuples smaller in backtesting loops

This commit is contained in:
Janne Sinivirta 2018-01-02 20:51:07 +02:00
parent f4ccd4609b
commit dc2f048c98

View File

@ -84,7 +84,8 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame],
ticker = populate_sell_trend(populate_buy_trend(pair_data)) ticker = populate_sell_trend(populate_buy_trend(pair_data))
# for each buy point # for each buy point
lock_pair_until = None lock_pair_until = None
for row in ticker[ticker.buy == 1].itertuples(index=True): buy_subset = ticker[ticker.buy == 1][['buy', 'open', 'close', 'date', 'sell']]
for row in buy_subset.itertuples(index=True):
if realistic: if realistic:
if lock_pair_until is not None and row.Index <= lock_pair_until: if lock_pair_until is not None and row.Index <= lock_pair_until:
continue continue
@ -106,7 +107,8 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame],
) )
# calculate win/lose forwards from buy point # calculate win/lose forwards from buy point
for row2 in ticker[row.Index + 1:].itertuples(index=True): sell_subset = ticker[row.Index + 1:][['close', 'date', 'sell']]
for row2 in sell_subset.itertuples(index=True):
if max_open_trades > 0: if max_open_trades > 0:
# Increase trade_count_lock for every iteration # Increase trade_count_lock for every iteration
trade_count_lock[row2.date] = trade_count_lock.get(row2.date, 0) + 1 trade_count_lock[row2.date] = trade_count_lock.get(row2.date, 0) + 1