
192
|
第
5
章
aperf = self.results['cstrategy'].iloc[-1]
# out-/underperformance of strategy
operf = aperf - self.results['creturns'].iloc[-1]
return round(aperf, 2), round(operf, 2)
def plot_results(self):
''' Plots the cumulative performance of the trading strategy
compared to the symbol.
'''
if self.results is None:
print('No results to plot yet. Run a strategy.')
title = '%s | TC = %.4f' % (self.symbol, self.tc)
self.results[['creturns', 'cstrategy']].plot(title=title,
figsize=(10, 6))
if __name__ == '__main__':
lrbt = LRVectorBacktester('.SPX', '2010-1-1', '2018-06-29', 10000, 0.0)