Merge pull request #488 from jblestang/fixing_bug_in_backtesting_causing_to_much_sells

Fixing bug in backtesting preventing sell events to be executed
This commit is contained in:
Janne Sinivirta 2018-01-31 16:42:02 +02:00 committed by GitHub
commit 5b71d5f3a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,7 +84,9 @@ def get_sell_trade_entry(pair, row, buy_subset, ticker, trade_count_lock, args):
# 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
buy_signal = buy_subset[buy_subset.date == row2.date].empty # Buy is on is in the buy_subset there is a row that matches the date
# of the sell event
buy_signal = not buy_subset[buy_subset.date == row2.date].empty
if(should_sell(trade, row2.close, row2.date, buy_signal, row2.sell)): if(should_sell(trade, row2.close, row2.date, buy_signal, row2.sell)):
return row2, (pair, return row2, (pair,
trade.calc_profit_percent(rate=row2.close), trade.calc_profit_percent(rate=row2.close),