Get Balance and Equity evolution over time
edofe99 opened this issue · 1 comments
edofe99 commented
bt = Backtest(initialiseData('ES=F'),DonchainBreakout,cash=10_000)
stats = bt.run()
print(stats_trades)
This only return a dataframe with the list of trades taken, I would like to have a dataframe with equity and balance for every point in time of my original time series data.
How can I do this???
edofe99 commented
Solved like this:
class Test(Strategy):
equity_ = pd.DataFrame()
def init(self):
def next(self):
self.equity_.loc[len(self.data), 'Date'] = self.data.index[-1]
self.equity_.loc[len(self.data), 'Equity'] = self.equity
bt = Backtest(df,DonchainBreakout,cash=10_000)
stats = bt.run()
equity_df = bt._strategy.equity_