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

With a strategy with multiple instruments, anyway to make one plot per?



  • I have multiple instruments with corresponding data feeds. The resultant plot() is way too busy, and would like to have a plot() for each instrument, even if that meant that the top portfolio section is the same between plots. Can this be done?

    Thanks.


  • administrators

    No and yes. Plots are strategy-based and not data-based.

    But you could selectively disable which data feeds have to be shown and then replot. This is completely untested, but it should be something like this:

    st = cerebro.run(....)[0]  # assume only interest in 1st strategy (probably the only one)
    
    for i in range(len(st.datas)):
        for j, d in enumerate(st.datas):
            d.plotinfo.plot = i == j
            
        cerebro.plot()
    


  • Thanks,
    That does work. Alternatively is there a way to get access to this raw data so I can plot myself?


  • administrators

    Each line in a data feed has:

    • An attribute array which holds the data
    • Method getzero(idx, size) to return the data from the beginning
    • Method plot(idx=0, size=None) which if called as plot() will simply give you the entire array