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
ENH Add beta_fragility_heuristic and gpd_risk_estimates functions #42
ENH Add beta_fragility_heuristic and gpd_risk_estimates functions #42
Conversation
python 2 and 3
Thanks @jeyoor, this looks great. I'll try to take a look next week (traveling). |
Sorry @jeyoor, I completely dropped the ball on this. This looks great, if you solve the merge conflicts we can go ahead and merge this. |
…y_and_gpd_risk_estimates Conflicts: empyrical/__init__.py empyrical/stats.py empyrical/tests/test_stats.py
Hi @twiecki, No worries; schedule pressure can be tough. I solved the merge conflicts, but tests are currently failing. Tests run fine on quantopian:master so it must be something I added or changed, but it isn't clear to me right now exactly what's causing the tests to fail... I'll keep you posted on the status. Thanks! |
- old tests work - new tests still failing
- fixes TypeError: cannot concatenate a non-NDFrame object - also, switch the functions from SIMPLE_STAT_FUNCS to FACTOR_STAT_FUNCS
Hi @twiecki, I think everything passes now. I wasn't sure if the new functions should be in SIMPLE_STAT_FUNCS or FACTOR_STAT_FUNCS, but they seemed to fit best in FACTOR_STAT_FUNCS so I moved them there. I look forward to your feedback. Thanks! |
empyrical/__init__.py.orig
Outdated
@@ -0,0 +1,71 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file shouldn't show up.
empyrical/stats.py.orig
Outdated
@@ -0,0 +1,1616 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file neither
Thanks for picking this back up! Looks like the merge wasn't quite successful yet. If everything fails, you could from a clean master you cherry-pick your commits, or recreate those functions. |
Doh! Looks like I accidentally added some merge backup files. How does it look now? |
Hi @twiecki, How are the diffs looking after the most recent update? Thanks! |
The magnitude of the negative value indicates the size of | ||
the potential loss. | ||
|
||
seealso:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this under Notes
(with ---
underlining) at the bottom.
@@ -993,6 +995,325 @@ def cagr(returns, period=DAILY, annualization=None): | |||
return ending_value ** (1. / no_years) - 1 | |||
|
|||
|
|||
def beta_fragility_heuristic(returns, factor_returns): | |||
""" | |||
Estimate fragility to drops in beta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these line-breaks are a bit odd.
""" | ||
Estimate fragility to drops in beta | ||
|
||
seealso:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
var_estimate - an estimate for the VaR for the given percentile | ||
es_estimate - an estimate for the ES for the given percentile | ||
""" | ||
result = np.array([0.0, 0.0, 0.0, 0.0, 0.0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.ones()
or np.empty()
.
Closing this as it's old. Feel free to reopen if this is still relevant. |
@gusgordon , |
Moved to new pull request here #118 |
Hi,
I thought it'd be interesting to add some risk metrics to empyrical for use in zipline/pyfolio.
Here's the papers I used.
Beta Fragility: https://www.imf.org/external/pubs/ft/wp/2012/wp12216.pdf
GPD Risk Estimates: https://link.springer.com/article/10.1007/s10614-006-9025-7
I wasn't sure about whether or not docstrings and tests are required for subroutines. (I'm missing some docstrings and tests for subroutines of gpd_risk_estimates.)
If the above are required, please feel free to ping me back and I'll work on adding them.
Thanks!
Jeyan