I have a simple code as follows:

class definition:

class MySMAStrategy(Strategy):
    day1 = 10
    day2 = 50

def init(self):
    self.ma1 = self.I(talib.SMA, self.data.Close, self.day1)
    self.ma2 = self.I(talib.SMA, self.data.Close, self.day2)
    
def next(self):
    price = (self.data.Close[-1])*1.02
    
    if crossover(price, self.ma1):
        self.buy()
    elif crossover(self.ma2, self.ma1):
        self.position.close()

bt= Backtest(GOOG,MySMAStrategy, cash=10000)

bt.run()

bt.plot()

How can I obtain only the "equity" part from the graph I plotted for the backtest result? I want to plot this part separately as its own graph.

I would likte to extract only the "equity" section, as indicated, from the graph as I marked.enter image description here

1

There are 1 best solutions below

0
On

I've solved the issue. For those who are curious or facing the same problem:

bt.run()['_equity_curve']["Equity"].plot()