0

In backtesting.py, when looking at the trade statistics, the latest of field Last exit date is always filled with a date which is more recent than the latest date in field Last entry date. This means that the cash is never invested at the end of the backtesting periode, in any of the assets I'm testing on. Why is that and what can I do about it?

The strategy:

class RsiOscillator(Strategy):

rsi_window = 14
lower_bound = 30
upper_bound = 80

def init(self): 
    self.rsi = self.I(talib.RSI, self.data.Close, self.rsi_window) 

def next(self):         
    if crossover(self.rsi, self.upper_bound): 
        self.position.close() 

    elif crossover(self.lower_bound, self.rsi):            
        self.buy(size=1) 

The invocation:

bt = Backtest(data, RsiOscillator, cash = 100, exclusive_orders=True, finalize_trades=False)
stats = bt.run()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.