Closed robertmartin8 closed 5 years ago
Hi Robert,
I believe you could create a function called prices_from_returns
(in the same fashion as returns_from_prices
, which is a very useful function that's not mentioned in the docs at all!).
This would allow anyone to use either input with no API change at all.
@schneiderfelipe thank you for the feedback, I’ll do this soon
This was originally what I intended, but a user has notified me that some data sources (e.g the Fama and French 30) only provide returns. If you are having a problem with this, a quick workaround is to construct a new series of "prices" by adding a row of 1s to your dataset then using
df.Series.cumprod()
to get the cumulative product. This works because most methods first take the percentage change to make areturns
series, and this percentage change does not care about the starting value.Would love to hear any opinions on whether this is an issue, and if so, what would be the cleanest way to implement optionally providing returns instead of prices. I guess I could do it by having a boolean parameter
price_data=True
; ifFalse
then the data passed in will be interpreted as returns. However, I don't want to clutter the API without good reason.