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

Python ffn package - bug in calc_stats() #23

Closed
cyrpy opened this issue Mar 30, 2017 · 0 comments
Closed

Python ffn package - bug in calc_stats() #23

cyrpy opened this issue Mar 30, 2017 · 0 comments

Comments

@cyrpy
Copy link

cyrpy commented Mar 30, 2017

Hello,
There seem to be a case where calc_stats() breaks.
There is a division by zero which is occuring when the the computation of twelve_month_win_perc occurs.

Here is the example:
import ffn
data = ffn.get('agg,hyg,spy,eem,efa', start='2010-01-01', end='2014-01-01')
data.ix['2012-07':'2013-03'].calc_stats()

If I may I'll tend to amend that this way:
tot = 0
win = 0
if len(mr) >11:
for i in range(11, len(mr)):
tot = tot + 1
if mp[i] / mp[i - 11] > 1:
win = win + 1
self.twelve_month_win_perc = float(win) / max(tot,1)

Thank you in advance for your help!

This issue was closed.
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

2 participants