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

Capacity tear sheet #284

Merged
merged 1 commit into from
Apr 12, 2016
Merged

Capacity tear sheet #284

merged 1 commit into from
Apr 12, 2016

Conversation

a-campbell
Copy link
Contributor

There are two main analyses here: constraining ticker and a capacity sweep.

The constraining ticker analysis asks "What is the maximum capital base I could have deployed this strategy on without ever consuming more than X% of the {average, 10th_percentile, 90th_percentile} daily volume for each traded name.

The capacity sweep asks "How does my strategy's Sharpe ratio decay as I increase capital base and incur greater slippage on my trades?"

Another change of note is the inclusion of market data in this tear sheet. Since we will likely want to use market data for future tear sheets, we should be sure that we like the Panel data format we are asking for in this API change.

screenshot 2016-04-01 17 19 56
screenshot 2016-04-01 17 22 48
screenshot 2016-04-01 17 22 58

Wondering if it is useful to display the most liquid names in the constraining ticker analysis?

@a-campbell
Copy link
Contributor Author

I'm not sure how to make Travis accept get_ipython() as an unbound function in utils.py

@twiecki
Copy link
Contributor

twiecki commented Mar 9, 2016

pyfolio/plotting.py:1269:21: F821 undefined name 'xrange'
pyfolio/tears.py:683:65: W291 trailing whitespace
pyfolio/utils.py:484:9: F821 undefined name 'get_ipython'

The first is easy to fix either with six or just using range.
Third can be fixed with by ending the line with # noqa to disable flake.

def get_assets_dollar_volume(positions, market_data,
only_held_days=True, last_n_days=None):
"""
Computes descriptive statsitics for the daily dollar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statsitics

@twiecki
Copy link
Contributor

twiecki commented Mar 13, 2016

I haven't really followed the development of the capacity analysis so coming to this with fresh eyes. It's possible that this is the best to display the information we want to extract but overall I find it a bit hard to extract actionable insights. The below points are thus mostly naive questions rather than fully baked feedback on what would be better.

  • I find the tables a bit hard to read but not quite sure how to improve that, especially if many values are 0.00. Perhaps a box plot?
  • The alloc plot of the illiquid tickers also feels a bit uninformative unless I'm missing what should jump out here, and the 1mm$ threshold seems a bit arbitrary. I'd also drop the most liquid tickers analysis as you suggest.
  • The capacity sweep plot is really nice. However, putting things together, the max capacity at 20% volume at the 90th percentile (which seems pretty aggressive) suggests a max capital base of $50,000. However, the capacity sweep suggests I can trade this strategy at $20MM easily.
  • Have you considered a plot that shows for each ticker (or the N least liquid ones), over time, how much % of the vol was I taking up? That would tell me if there perhaps was just one squeeze or whether I was constantly using up most of the stocks liquidity.

vol_analysis.loc[:, 'avg_daily_dv_$mm'] = np.round(
DV.mean() / DISPLAY_UNIT, 2)
vol_analysis['10th_%_daily_dv_$mm'] = np.round(DV.apply(
lambda x: np.nanpercentile(x, 10)) / DISPLAY_UNIT, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DV.quantile(q=0.1)

pv = timeseries.cum_returns(
returns, starting_value=backtest_starting_capital) * mult

adj_returns = returns - (daily_penalty / pv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

daily_penalty is in dollars, no?

@twiecki
Copy link
Contributor

twiecki commented Mar 13, 2016

OK, done with this round.

@a-campbell
Copy link
Contributor Author

@twiecki I think this should be good for another look. I updated the screenshots in the original PR post.

@twiecki
Copy link
Contributor

twiecki commented Apr 12, 2016

I think this looks great. You'll need to rebase as we have print_table in master now.

@a-campbell
Copy link
Contributor Author

All squashed and rebased now.

@twiecki
Copy link
Contributor

twiecki commented Apr 12, 2016

👍

@twiecki twiecki merged commit 62aaaad into master Apr 12, 2016
@twiecki twiecki deleted the capacity_tear branch April 12, 2016 21:04
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.

2 participants