Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PerformanceStats ".monthly_returns" fails to work if a whole month is missing data #64

Closed
Stuj79 opened this issue Sep 11, 2018 · 5 comments

Comments

@Stuj79
Copy link

Stuj79 commented Sep 11, 2018

Hi,

Firstly, LOVE this package - it has been a god send to me so many thanks for your hard work and choosing to share it with us all.

I have noticed what I believe to be a "bug" with the ".monthly_returns" when used on certain input data and with a PerformanceStats object.

When using daily periodicity data (or intra-day) as a base input to the PerformanceStats object, if there is a whole calendar month period without a corresponding entry in the series (or more than one month in a row), the resulting data returned seems to be incorrect/incomplete.

I have provided two csv input files and a Jupyter notebook that replicates the 2 issues I have found, with further explanation within.

I may be missing something my end which is causing this, but I do believe it to be a legitimate "bug".
ffn_bug_examples.zip

@ViktorMalesevic
Copy link
Contributor

Hi,

I believe this might be due to the fact that .dropna() is not being done on monthly resampled data. @JordanPlatts what are your thoughts on that?

@JordanPlatts
Copy link
Collaborator

Bug 1

The .pct_change() method uses fill forward to replace missing prices where ffn currently uses shift as you can see below.

image

This is apparent when you run .pct_change() on monthly_prices.
image

I don't view this as a bug because I don't like the library making the assumption that prices should filled forward. With that said, if everyone feels different I can change it.

image

The question is do you think the price in the beginning of May was 118 and should the ffn library assume that.

Onto bug 2

@JordanPlatts
Copy link
Collaborator

It was the same issue for bug 2.

image

The price 4416.56 was used as the beginning of September.

image

@Stuj79
Copy link
Author

Stuj79 commented Oct 13, 2018

Thanks for your time in looking into this, and apologies for the late reply.

I guess it all come down to this question, as you put it:

"The question is do you think the price in the beginning of May was 118 and should the ffn library assume that."

I use this package almost exclusively to analyse results of systematic trading strategies, and missing data for a month implies nothing more than the fact that there were just no trades that month, and hence the "price" of my series didn't change (as it is just the index of performance), therefore the ending "price" of the last month with a non zero return can indeed be seen as the starting "price" for the next month with a non zero return.

Whether "missing data" should be treated as truly "missing" rather than just "non existent" is a subjective call I guess - partly depends on what you are actually analysing.

I would have thought (perhaps naively) that a decent proportion of users would be using the ffn package to analyse "user created" price series such as results of trading strategies/portfolios, along with those who use it to analyse pure stock exchange price data.

Once again, I do appreciate you taking the time to look into my request - much appreciated!

@JoeOD
Copy link

JoeOD commented Feb 9, 2019

I'm having the same issue. Is there a suggestion for dealing with series of returns which contain 0s or missing values, due to the fact that the trading algo was "out of the market" for that period (position size was 0)?

@Stuj79 Stuj79 closed this as completed Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants