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

Update percent_return.py enforce fill method on pandas pct_change #803

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

bossdown123
Copy link

adjust the pct change

@twopirllc
Copy link
Owner

@bossdown123

Curious.

Does the following not calculate percent change correctly with the exception of filling some nan ?

pr = (np_close / roll(np_close, length)) - 1
pr[:length] = nan
# Why not handle nans here?
pct_return = Series(pr, index=close.index)
# Or here?

Thanks,
KJ

@twopirllc
Copy link
Owner

@bossdown123

Upon further review, there does not appear to be any difference between either calculation or speed on the development branch. Thus I am keeping the original code unless you have further evidence to the contrary.

Here is the core code tests I ran in Jupyter:
Screenshot 2024-07-09 at 6 04 23 PM

  • pd.testing.assert_series_equal(tapr, pdpr, check_names=False) never threw False either.

Thanks for helping to making the library better!

Kind Regards,
KJ

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

Successfully merging this pull request may close these issues.

None yet

2 participants