For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

To get multiple windows for plotting each multiple assets

  • Hi, I am currently running a simple Long & Short model for multiple equities.

    This is my final part of the codes :

    #Variable for our starting cash
    startcash = 1000000000
    #Create an instance of cerebro
    cerebro = bt.Cerebro(cheat_on_open=False)
    #Add our strategy
    datalist = []
    for i in bascket:
        datalist.append(('{}.csv'.format(i), i))
    for i in range(len(datalist)):
        data = EIKON_HLOC(dataname = datalist[i][0])
        cerebro.adddata(data, name=datalist[i][1])
    # Set our desired cash start
    # add analyzers
    cerebro.addanalyzer(trade_list, _name='trade_list')
    cerebro.addanalyzer(open_list, _name='open_list')
    # run backtest
    strats =
    # get analyzers data
    trade_list = strats[0].analyzers.trade_list.get_analysis()
    open_list = strats[0].analyzers.open_list.get_analysis()
    print (tabulate(open_list, headers="keys"))
    print (tabulate(trade_list, headers="keys"))
    #Finally plot the end results

    and I get this packed window


    What I want here is to get separate windows for each equity.
    I tried :


    But it rather gave me 5 different windows for all equities with different time-horizon (ex: 2010-2011, 2011-2012 ...)

    I have lots of things to learn about backtrader and python while doing my UG degree and I would really appreciate you guys help!

    Thank you :D

  • administrators

    There is no support for plotting each data on a different figure. The problem is that scrolling is not implemented by matplotlib, which would be the ideal solution.

  • @backtrader Thanks! I will try reformatting by using matplotlib then :)