Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Live Tearsheets Review Webinar - LeoM Tearsheets

After the Live Tearsheets Review webinar (by Jess) I saw many users (Anthony, Joakim, James) create their own posts and saw their attempts at addressing their takeaways from the webinar.

My own takeaway from the webinar was different. Before the webinar it was not clear to me how the risk model fit into the evaluation process. Earlier posts (early 2018) on risk model provided a clouded picture, I was left scratching my head if I need to zero out my common returns as some users were doing in posts on the forum or get into full debug mode and see why some unintentional exposures are getting flagged in my tear sheets. After the webinar it is clear that Quantopian evaluation team prefers not to see consistent exposure to any risk factor.

I also got a holistic perspective of risk. It appears that is the main focus of the webinar. As an afterthought after the webinar I realized risk comes in different forms, not just risk factors. More so in how we approach strategy building and what decisions we take at each point starting from factor creation to alpha combination. I revisited every decision that has risk implications and reworked it so that the central theme is to minimize risk of that decision point.

I am (like James) also in favor of statistical significance (of long period backtests) and incorporating trading costs into account while factor building (a reason why I haven't been able to adopt AlphaLens).

Another feedback I got that I think has a lot of merits is using statistically significant multi year holdout periods (like 50:50 division). I will do that going forward. I haven't done that in this algorithm development, more because I didn't realize that was something that was expected. From the lecture on overfitting I watched a year ago - I walked away thinking that appears to be some kind of fraudulent practice that cheaters do. But my new understanding is that fitting that happens unconsciously in our attempt to meet the requirements are only to be found by installing a process before strategy development starts, and part of that process is having a meaningful multi year holdout data.

I have spent 14 months on this single algorithm. It uses multiple factors. Each equity in my universe derived from QTradableStocksUS is ranked in each factor every day and alpha combination works across all factors. Market regime is not detected or used in the algorithm in any form. I use same processing routine every day. It takes about 25 second a day to go through all computations so I am having to chunk my tearsheets into 3 year periods which is what I can do without hitting long running backtest timeouts that have become common nowadays.
So there are five tear sheets one each for a three year period starting 2014.

I'd appreciate if you find any issues (red flags) that I should address. Constructive feedback/different viewpoints are also welcome. I have submitted this version to the contest. I don't expect to change the logic much further unless a red flag is found, which I am hoping the community members who are good in tear sheet evaluation can help me with. Thanks to Joakim for suggesting I use hide_positions option.

20 responses

@Leo M,

Bravo! I must admit a lot better than mine. What I like most about your algo is the consistency across the board. It also confirms my belief that volatility is both a blessing (where returns can be had) and a curse (where risks are) , but balanced properly, one can achieve a "slow and steady" ride. Congratulations, I think you got a winner here!

Let's see what Guy has to say :)

I also think it looks like a great strategy. Well done!

If it’s not too ‘secret sausey’ I’d be interested in your thought process around the dynamic position holdings? Variable within a range?

I’ve been thinking of doing this too, but I’m not there yet. Basically I would like to find a way of measuring how effective at predicting future returns have been in the recent past. If my model is highly predictive, then take fewer bets (higher position concentration), and when my model is less predictive of future returns, spread my risk and take more bets (lower position concentration).

Anyway great job!

@Leo, interesting. I have the impression, based on the 5 simulations, that the starting capital was the same for all. If this is correct, then your overall performance should be even better.

It would be preferable to use the result of the previous section as the initial capital for the next. This way you would get the real picture of a fully invested test where all the capital would have continued to be used and progress. It is a CAGR game after all. The profits from the first section would be compounding in the next, and so on.

I like the numbers, a steady 14-year low-volatility scenario. No major outliers.

Note that after the initial push, up to test #2, \(n \cdot \bar x\) was rising, from test #3 onward, it is declining. Yet, you maintained a 51% profitable trades throughout. The average round trip was 179 508 trades per 3-year period. This was distorted a bit due to the last test which is only for 29 months while the others were all for 35 (36).

Make a chart of \(n \cdot \bar x\) for the 5 simulations. It is a limited view, but it will still give you clues as to what to do next.

You had, in your first test, a holdings ramping up function which seems to have disappeared in test #2 and beyond. Was it because you had reached your upper limit of stocks you wanted to have in your portfolio?

Guy,

I have a maximum of 1200 positions set but I haven’t reached it yet. I have floor on price and filters for non NA set. The QtradeablestocksUS equities that pass those floors are all ranked. The movement I believe is due to securities falling below floor price during recession that make them ineligible.
CAGR is 3.9% for the fifteen year period. Does it matter what the initial capital is? Geometric progression growth is still dependant on (1+r)^n.
Algo is purely fundamentals based. Does well when markets move up or down. I’m happy with flat returns in flat markets. Somehow fundamental based strategies don’t do well in consolidation period, but do well in recession and upward sections of market.

Guy, forgot to state that starting capital was same for each backtest. 10million.
What does n.x provide. Is it something I can do without overfitting.

Thanks @Leo, I’ll have a look.

@Leo, by using $10M for each test, you miss out on the compounding of the profits in later stages. By doing the procedure mentioned it would raise your overall performance.

Your strategy would be compounding over the 15-year period instead of only 3 at a time. It should generate something near 27% more profit than your tests showed (about $1.6M more). There is no change in the program to do that. So, in your testing method, it does matter what the initial capital is for each period. Moreover, it is a more realistic simulation to start with the initial capital from the result of the previous section. It gives continuity.

There are interesting properties in your strategy. I liked the holdings ramping up in the first test. Liked your scaling down on your holdings during the financial crisis, to ramp it back up afterward.

As mentioned in another tread on this subject, n.x's regression line is declining, meaning that it is generating fewer profits as you add more time after the second test. You might let your holdings continue to ramp up more after the financial crisis using the same logic you currently use. It has little to do with over-fitting, it is more gaming your strategy under the constraints you have set. Giving it more long-term objectives.

Your strategy evolves with time, you enhance the strengths and try to minimize the weaknesses. That's it.

Guy, are you adding the returns from each period to come up with 27% more, addition usually only holds if it is arithmetic progression, right? For CAGR purposes and geometric progressions in general a(1+r)^n one can multiply the final amounts of each period and then calculate the CAGR on the full period and the final amount.

11.7% * 18.9%* 11.3% * 11.8% * 6% = 1.117 * 1.189 * 1.113 * 1.118 * 1.06 = 1.752 for 14.5 periods =~ 3.9% CAGR

If you add the individual period returns 11.7% + 18.9% + 11.3% + 11.8% + 6% = 59.7% =~ 1.597

I assume you are saying the different between 1.597 and 1.752 differential of 0.155 is 26% more than 0.597? Is that where you said I could end up with 27% more? That can be achieved by just multiplying the cumulative returns of all prior periods as I showed above, no?

Keeping initial principal same makes it easier to compare across periods in my opinion on an apples to apples basis.

Regarding the holdings going down and up are all a natural consequence of equity prices going below a constant min-equity price that I have set in the code and then prices rising above that threshold later in 2009. Nothing intentional there. I do rank all equities that pass the filters from the pipeline.

@Leo, yes. And you do not need to redo the test to get the right answer. But, you should note that the sum of the tests as presented in your tearsheets is 27% less than what it would have produced had it been a single test for the duration. It is like understating your strategy's performance.

Another advantage of the partitioning, it gives you a per period comparison. A, on average, over 3 years, my strategy does so and so. Note that by keeping the initial capital the same for each period dampens other areas that could have an impact, one of which is trade volume availability. Saying that with the continuous equity, the strategy would be forced to trade more shares and thereby slightly changing its behavior.

On the “nothing intentional there” thing. I think it is. I have strategies which I do not allow to trade below initial purchase price to do the same thing. They will simply stop putting money in positions that are underwater. I use it as a protective measure and it is intentional as being part of the game I want to play. And what you are doing has the same effect.

@Guy, I used fundamentals exclusively because I noticed some posts indicating preference for alpha that is derived directly from alternate data. I think alpha from data is more sustainable long term, what are your thoughts on that.
I think what you are suggesting is momentum/technicals based approach, which seems an interesting research topic in itself. If I can find long term alpha there at a market level I’d definitely be willing to incorporate it as a stand-alone factor. It is difficult to mix price and fundamentals in the same factor as the impact of each component will be difficult to analyze in the blended factor. Any thoughts on that?
As to my weighting, it is based on order_optimal_portfolio and leverage of 1.0. I do 1200 stocks-weights are going to be very low at individual equity level. It will be difficult to reweight a factor post calculate optimal portfolio as there are constraints to be satisfied. Thoughts? It is easy to follow reweighting if you are long only and aren’t burdened with having to keep risk constraints in check.
I don't consider net portfolio value to vary the approach as you indicated. In fact the opposite of what you described is probably happening in my algorithm . Since weights are calculated independent of price movements of individual equities and equities get rebalanced back to the algorithm calculated weights everyday so overperformance prior day most likely leads to lowered weights while underperformance might actually lead be rewarded, which is strange since I hadn't thought about this till now. You are I suppose suggesting overweighting outperformers and getting rid of underperformers.

Hi Leo,

Couple of questions.

It is difficult to mix price and fundamentals in the same factor as the impact of each component will be difficult to analyze in the blended factor.

So I take it that your definition of fundamentals to be purely financial statement items and exclude mix price and fundamentals such as market cap, price earnings ratio, etc. which relies on daily close price. The reason I ask is because based on your definition of fundamentals, which normally just gets updated quarterly or annually based on 10Q and 10K SEC filings, I often run into the problem of low turnover and hit periods where turnover is less than the threshold of 5%. How do you overcome this without the benefit of incorporating price movements?

As to my weighting, it is based on order_optimal_portfolio and leverage of 1.0. I do 1200 stocks-weights are going to be very low at individual equity level.

Do you use MaximizeAlpha or TargetWeights construct? Or do you run calculate_optimal_portfolio first before passing to either MaximizeAlpha or TargetWeights construct. Just a heads up, if you don't already know, there is a bug in TargetWeights construct.

James, if you or Joakim have a problem with order_optimal_portfolio, you can post here what you are trying to achieve and I will try my best to answer them.

Leo,

Thanks for your insightful answers. I have no problem with order_optimal_portfolio right now but thanks for the offer.

The specific bug I'm referring to in TargetWeights is discussed here If you have not been experiencing that problem of failing the QTU universe test then it's either you found the source of the bug, have naturally incorporated in your code a way to guarantee that positions that drop the QTU universe is closed that next day or you have a neatly coded routine that avoids this problem.

James, it appears to me from that thread that you were expecting TargetWeights to close positions not in current QTU. My understanding is that TargetWeights is not connected to QTU, with TargetWeights the user is responsible for all housekeeping tasks.

Leo,

Yes, I was expecting forTargetWeights to automatically close because if a stock dropped out of QTU and has a current position , order optimize should give a 0 (close order) but there are occasions when it doesn't and it is sutble but accumulates in the long run thus causing it to fail the >= 95% QTU. I didn't know that you were suppose to be responsible for housekeeping. I did a temporary fix which works sometimes, so I abandoned it all together. However, Q tech acknowledged bug but not on priority list ;-(

Have you tried doing one long backtest say 10+ years without encountering this problem?

Leo,

If you close yourself and if this is part of your housekeeping, then you shouldn't have a problem. So I take it that your answer to my question is yes, you did a long backtest and did not encounter the >= 95% QTU structural threshold problem. Right?

James, that is right. I haven't gotten that error in a long backtest.

Leo,

I'm glad that you are not encountering this problem, it must be that your housekeeping routine overcomes / solves it. I initially used TargetWeights with my fix ( or housekeeping as you call it) using Frozen to close dropped out stocks from QTU which seem to solve the problem in short runs but on long runs, it gave another set of errors:

InfeasibleConstraints: The attempted optimization failed because no portfolio could be found that
satisfied all required constraints.

For this reason, I lost confidence in TargetWeights and reverted back to MaximizeAlpha construct although performance degraded a bit.

Another concern of mine, since we both rely heavily on Fundamental data supplied by Morningstar, is its data accuracy, consistency and integrity. There are many threads that discuss these shortcomings and I'm wondering how Q is dealing with these. I have recommended that Q should do data cleansing and integrity tests of Morningstar data before releasing it to users and spell out frequency, availability, as of dates, dates reported, etc.

James,

I would prefer longer period data sets (like 30 years). More data more alpha opportunities more statistical certainty, hopefully factset improves the situation.

Leo,

Yes, I do agree on longer periods of duration for data sets. In my AI based systems ( python or third party apps) which are purely derived from OHLC datasets, I could go as far back as there is available data. Not very familiar with FactSet but hopeful that it has cleaner data.