-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Perf attrib tearsheets #441
Perf attrib tearsheets #441
Conversation
This looks great. I would drop the histogram alpha plot (probably can delete it alltogether for now), and remove the stackplot from the exposures, as we discussed, and replace it with a line-plot for now. |
+1 to replacing the stackplot with a line plot |
@yankees714 could you take a look when you get a chance? |
I'm fine to merge after engineering review. |
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.
Just had some minor suggestions for you.
""" | ||
Plot each factor's contribution to performance. | ||
|
||
Parameters | ||
---------- | ||
exposures : pd.DataFrame |
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.
So this was just unused?
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.
yup
pyfolio/perf_attrib.py
Outdated
colors=COLORS | ||
) | ||
for s in factors_and_specific: | ||
ax.plot(factors_and_specific[s]) |
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.
For clarity, can we use something like field
or col
here instead of s
?
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.
fixed
pyfolio/perf_attrib.py
Outdated
labels=exposures.columns, | ||
colors=COLORS) | ||
for s in exposures: | ||
ax.plot(exposures[s]) |
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 as above
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.
fixed
pyfolio/utils.py
Outdated
@@ -622,3 +623,9 @@ def set_legend_location(ax): | |||
|
|||
ax.legend(frameon=True, framealpha=0.5, loc='upper left', | |||
bbox_to_anchor=(1.05, 1)) | |||
|
|||
color_cycle = cycler('color', COLORS) | |||
ax.set_prop_cycle(color_cycle) |
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.
Seems like we might be able to do this in one line, without importing cycler? Like:
ax.set_prop_cycle('color', COLORS)
https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.set_prop_cycle.html
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.
fixed
pyfolio/perf_attrib.py
Outdated
positions, | ||
factor_returns, | ||
factor_loadings, | ||
pos_in_dollars=pos_in_dollars |
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.
Trailing comma here will make future diffs cleaner
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.
fixed
@@ -612,7 +613,7 @@ def get_symbol_rets(symbol, start=None, end=None): | |||
end=end) | |||
|
|||
|
|||
def set_legend_location(ax): | |||
def set_legend_location(ax, autofmt_xdate=True): |
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.
Do we ever pass autofmt_xdate=False
?
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.
we don't as of now, I wanted to pass it as an option in case we want to handle formatting elsewhere in future plots
responded to @yankees714's feedback, will squash commits and merge once tests pass |
- pass all perf attrib data to plot_returns - use line plot for factor contrib - format x-axis dates on plots
cd3a1df
to
657be93
Compare
add perf attrib tearsheet