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

Computing pnl for sub-periods



  • I've been working with this framework for a little while trying out some strategy ideas. So far I've found the system to be quite helpful and have been able to get results that I trust. I'm using daily data loaded from CSV files.

    In terms of analysis of performance, so far I've been looking only at the terminal values, i.e.

    strat[0].broker.get_value()
    strat[0].broker.logical_trade_counts.

    I'd like to analyze the daily pnl and trade counts. Is there a standard expected way to get this information ? So far I've tried adding an Observer

    cerebro.addobserver(bt.observers.TimeReturn)

    but I don't know how to extract the required information at the end of the run. I've also been trying to work with various lines objects like stats.broker.lines.cash. Again, I'm not sure exactly what I'm working with. I feel like there should be a way to generate a pandas Series with daily broker value by symbol, trade counts by symbol and free cash.

    Can you please point me in the right direction ?

    Thank you.


  • administrators

    @cremaking said in Computing pnl for sub-periods:

    strat[0].broker.logical_trade_counts.
    

    You may want to enlighten us and let us know where that comes from. There isn't such a thing.

    @cremaking said in Computing pnl for sub-periods:

    I'd like to analyze the daily pnl and trade counts. Is there a standard expected way to get this information

    Analyzers?



  • strat[0].broker.logical_trade_counts.

    You may want to enlighten us and let us know where that comes from. There isn't such a thing.

    Ahh, good point. It is a variable I'm keeping track of in the strategy to count the number of times I put on or take off a hedged position.

    Analyzers?

    Thank you. bt.analyzers.PositionsValue seems to give me what I need when I add cash=True.


Log in to reply
 

});