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

How are returns computed? #165

Open
mtomic-quant opened this issue Jul 10, 2024 · 1 comment
Open

How are returns computed? #165

mtomic-quant opened this issue Jul 10, 2024 · 1 comment
Labels

Comments

@mtomic-quant
Copy link

In docs you state that the returns are computed as change between the next day and current day, i.e. r_t = p_{t+1} / p_{t} - 1 but in the examples you use Panda's pct_change() which is the difference between current and previous day. I assume just doing pct_change() on prices is the correct way?

Thanks

@enzbus
Copy link
Collaborator

enzbus commented Jul 10, 2024

Which example are you referring to? The old paper examples are not cleaned and might have issues, as it's stated in the docs. In the library, returns at time t are computed as adjusted open price at time t+1 divided by adjusted open price at time t, minus 1, as is described in the paper. Adjusted means that dividends are incorporated in the price changes, it's a technical detail that's also mentioned in the paper (if you dig). The reference implementation is in the cvxportfolio/data module. If you find issues there please report. There's also a ton of logic for cleaning Yahoo Finance historical data there. If you wish to use your own data, just make sure you define returns as they are in the paper.

enzbus added a commit that referenced this issue Jul 13, 2024
clarified that legacy examples
are provided for historical reasons only;
they can cause confusion, see #165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants