For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
fix for get_pf_items?
-
The code was giving positions in the form of
Datetime, single_ticker, cash
When pyfolio expects, as per documentation, multiple ticker columns
positions : pd.DataFrame, optional Daily net position values. - Time series of dollar amount invested in each position and cash. - Days where stocks are not held can be represented by 0 or NaN. - Non-working capital is labelled 'cash' - Example: index 'AAPL' 'MSFT' cash 2004-01-09 13939.3800 -14012.9930 711.5585 2004-01-12 14492.6300 -14624.8700 27.1821 2004-01-13 -13853.2800 13653.6400 -43.6375
under get_pf_items it has
ps = [[k] + v[-2:] for k, v in iteritems(pss)]
I think this was trying to generate single positions, and somehow recombine them later?
But variable pss is already a ordered dict in the form of
{'Datetime': ['ABIO', 'ACHV', 'ACY', 'AEMD', 'AEYE', 'cash']} {Datetime : [0.0, 0.0, 0.0, 0.0, 0.0, 100000.0]}
So simply making a list of list is enough to pass it into pandas
ps = [[k] + v for k, v in iteritems(pss)]
This made my Pyfolio tear sheet graphs work properly
-
@crunchypickle do you mean you can use pyfolio now?
-
Not sure how you use it. but i just use tear sheet and its working fine.
I think i might have fixed some other bugs, but there are github issues that have solutions.