pyfolio icon indicating copy to clipboard operation
pyfolio copied to clipboard

How to use with minute frequency data?

Open emin63 opened this issue 7 years ago • 4 comments

Hello. Is it possible to use pyfolio with minute frequency data?

When I try, I get the error

AttributeError: 'DataFrame' object has no attribute 'amount'

from pyfolio.utils.extract_rets_pos_txn_from_zipline.

emin63 avatar Oct 14 '17 01:10 emin63

Hi @emin63, there are some quirks of using pyfolio with minutely data — I would resample to daily before passing to pyfolio.

That error seems unrelated, though. What are the columns of your transactions DataFrame?

gusgordon avatar Oct 16 '17 14:10 gusgordon

Hi, I am also interested in this due to 24/7 trading assets (i.e forex/cryptocurrencies).

Could you please point us into the right direction on how to do this resampling to make the data compatible with pyfolio @gusgordon? I think it is worth of consider including this feature in pyfolio IHMO.

I am new to zipline. Actually I am using enigma which is based in zipline and supports minute frequencies. If I am not mistaken zipline does not.

Thanks.

vonpupp avatar Nov 17 '17 18:11 vonpupp

@vonpupp I agree that it could be a useful feature to have a conversion function.

For your purposes, pyfolio assumes returns and positions are end-of-day. So, for example, when we pass returns into pyfolio for US equities, those are basically the daily returns at 4:00 each day. You could cumulate your minutely returns each day by doing something like:

returns_daily = returns_minutely.add(1).groupby(pd.TimeGrouper('24H')).prod().add(-1)

For the positions, you would just grab the positions at a certain time each day, probably midnight. You can throw out the other minutes' data for positions.

Hope that helps!

gusgordon avatar Nov 17 '17 20:11 gusgordon

Hi, I am also interested in this due to 24/7 trading assets (i.e forex/cryptocurrencies).

Could you please point us into the right direction on how to do this resampling to make the data compatible with pyfolio @gusgordon? I think it is worth of consider including this feature in pyfolio IHMO.

I am new to zipline. Actually I am using enigma which is based in zipline and supports minute frequencies. If I am not mistaken zipline does not.

Thanks.

Did you get pyfolio to work with forex for crypo?

868jjm avatar Jun 09 '21 15:06 868jjm