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

Extending transactions object from Analyzer

  • Hi,

    I'm running my strategy and doing some analysis on it with Pyfolio. One of the things I would like to be able to know is what was the condition that triggered a buy/sell operation. I know I could probably show this in a log, but I'd prefer to store it somewhere in memory that's later available in an Analyzer.

    At the moment I'm accessing the strategy transactions with:

    returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()

    What would be the best way to fill (I guess from the Strategy? extending the Analyzer?) more data into the transactions object? Like a new field called "Condition" or maybe some indicator value? I'm sure there may be a cleaner way to obtains this data, but I would prefer not to over-complicate it for now. In any case, I'm all ears.


  • Trade List created by @ab_trader is an excellent example of custom creating an analyzer.

  • Hi Pablo,

    may I ask how you actually managed to run pyfolio? I was trying to run the sample code from the Documentation and got the error

    TypeError: create_full_tear_sheet() got an unexpected keyword argument 'gross_lev'

    which seems to be known. Did you downgrade you pyfolio version? Would be awesome I could get a version to run :)

Log in to reply