Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Anyone else willing to share their longer term backtests?

Hello,

I'm a little bit curious on how other peoples longer term backtest curves look like so I'll start a small thread. It's too bad Quantopian doesn't allow embedding non-source code backtests so this needs to be done with screenshot/embed method.

Here is my 1x leverage contest algo (currently at the 6th position at contest 18) since 2007 (that's the earliest date some securities it trades are available) as you might notice the leverage peaks higher at some points (this is intended).

Here is how to embed a backtest image if someone wants to participate:
1) Take a screenshot of the backtest
2) Use image sharing service (I use imgur.com because it's so simple)
3) Embed the image via this command:

![](<insert link to image>)  
46 responses

Hi Mikko,

Nice curve! Getting that straight line up in a backtest (while getting all the contest badges) is quite an acheivement in itself.

However, it needs to keep performing out-of-sample. Usually, with that kind of high sharp and low volatility numbers, we have a case of strong overfitting. I certainly don't hope so for you, but that screams "too good to be true". Let us know how it looks like in 6 months!

I understand that someone might see this as an overfitted example but believe me, I understand quite well what overfitting means - probably better than most (here is my older thread about building genetic trading algos in another forum) and I very firmly believe that this is not overfitted. Can it win the competition? I have no idea as IMHO 6 months is still too little time to estimate how well an algo really works and there are survivorship bias issues but of course the real test will be "live" trading (I will put some of my own money behind this very soon).

Anyway what I really would like to see what I'm against so if anyone else wants to share their longer term backtests then please do.

This is one of my contest entries...not as straight line as yours, but easy to manage, 2x leverage, naturally hedged so there is no badge...backtesting is for period between 1/1/05 through present

Total Returns
443.49%
Benchmark Returns
117.3%
Alpha
0.33
Beta
0.45
Sharpe
2.00
Sortino
2.79
Information Ratio
1.55
Volatility
0.19
Max Drawdown
37.5%

My first long term trading algorithm

Impressive looking curve. If you don't mind, perhaps you can give a little bit of insight to your method? Fundamentals? Technical analysis? Frequency of trade?

Technical analysis, used a simple moving average algo with custom trailing stops for both short and long positions. It is levered long and not levered short since the average trend of the stock market is long over the long run. The frequency of trades is minimal and you can see that by the transaction data.

"It is levered long and not levered short since the average trend of the stock market is long over the long run"

Daniel, what if you did not use any leverage on the long side? Are you beating the benchmark?


This is without using any leverage, and decreased order percent target value when shorting. This was how i originally created the algo then I added the leverage and increased my short buying power after I saw how beneficial the results were. Not bad for a first algo.

I think the current "share result" attachment method is very misleading, and makes it too easy to accidentally share an algo. If Quantopian is not going to make it easy to share just results, they should at least change the term to "share algorithm."

One of a few factor models I have developed in the past few months at 1x leverage. Still requires a lot of work though...

still lacking in OOS data...

One of my algos is below. The graph shows the algo at 1.0 leverage.

The thing is, Q is super risk averse (aren't we all?). That means you get a lot more points for lower volatility and drawdown, than higher returns. As such, when contest backtested, my algo ranks #2... but not at leverage 1.

No, no - at leverage 0.3

Yes, really.

Ah, the games we play :)

@Mikko - try setting your leverage to 0.5, you may find that you climb up the ranks in the contest.

Note: I can only backtest starting near end of 2011

Yup, a humorous consequence of their contest metrics. :)

Mikko - have you considered sharing the Pyfolio tear sheet of your algo, instead of the backtest screenshot? Pyfolio lets you share the performance curve without the source code.

EDIT: Also, you can hide positions from your tearsheets like this:

bt.create_full_tear_sheet(hide_positions=True)  
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Regarding gross leverage and contest/fund candidate algos, this is a point of confusion for me. Perhaps someone can set me straight. It would seem that in comparing one algo to another, the overall gross leverage should be set to ~1.0. Otherwise, you have a convolution with slippage and commissions. And in the Q fund, presumably it won't be up to the algo writer; the fund overlord will decide how much capital and gross leverage is applied to each algo. Also, I saw that Q intends to go up to as much as 6X leverage (see Financial Times article, copied on https://www.quantopian.com/posts/quantopians-first-discretionary-capital-allocations). So, would a "manager" get the benefit of 6X gross leverage, or only up to 3X (the contest limit)?

Having a gross leverage less than 1.0 would seem to be silliness. That would say that the strategy is sitting on a pile of cash, which Q wouldn't do in the fund, presumably. They'd deploy it to another algo. I'd figure that any as-written algo that has a gross leverage of <1.0 would be deployed with effectively a gross leverage of at least 1.0, but probably significantly higher (presumably, since Q is aiming for very low volatility algos, they'll need the leverage to get the return).

I got this one running. It won't win a contest unless very lucky, but seems to be doing a good job out of sample.

One of my favorite and simplest.
Is this worth investing?

Vlad, Looks solid. I don't really know how to interpret all the plots but, in the first plot, is the red oos?

Vladimir, looks great. If I may speculate, this trades up to 5 tickers, maybe SPY, TLT and GLD mainly?

I think an excess of Kurtosis risk is causing these results...

Behavioral Trader,

You are almost right, it trades up to 5 tickers, but guessed only one and no more attempts allowed.

With respect what a totally and utterly useless thread. For all the reader knows you could be hand painting the numbers. I don't want to be a spoilsport but what on earth do you guys imagine you are going to learn from any of this?

Without the code and the instruments you may as well invest randomly and expect stellar results. Actually, I would rather invest randomly with known instruments that trade a black box algo.

Takes all sorts though. Who am I to complain.

i think it's a good chance to brag and maybe get some attention without actually sharing. =)

Without the code and the instruments you may as well invest randomly and expect stellar results. Actually, I would rather invest randomly with known instruments that trade a black box algo.

My prediction is that this whole black box approach will morph as Q gets real. It'd be interesting to hear from the new guys just hired (pictures on https://www.quantopian.com/about and bios on https://next.ft.com/content/a31f1f2a-29d3-11e6-8b18-91555f2f4fde). Are they actually gonna go to big money investors with a pitch that the algos from which the fund is constructed are complete black boxes? We already have a weak form to transparency, on https://www.quantopian.com/fund :

Strategic Intent
We are are looking for algorithms that are driven by underlying economic reasoning. Examples of economic reasoning could be a supply and demand imbalance, a mixture of technical and fundamental drivers of stock price or a structural mispricing between an index ETF and its constituent stocks.

In other words, the more you are willing to divulge, the better your chances will be of getting funding. My sense is that this may be the first step toward "For your algo to be eligible for institutional funds, the code will need to be reviewed by Quantopian." But this is pure speculation on my part.

The "Strategic Intent" requirement is potentially a risk, diluting the central idea of crowd-sourcing a large number of strategies, and treating them as truly black-box synthesized instruments. The risk is that Q will meddle and influence the crowd, which is more along the lines of a traditional fund. When Q runs a tear sheet, with access to instruments traded, and then asks the author to describe their algo's "Strategic Intent" there is the risk that Q managers (and eventually institutional investors) will inject their biases into the process. I'm not sure they can have their cake (innovative crowd-sourced black-box fund) and eat it too (operate like traditional funds, with internal transparency of strategy details). They may be making a fatal mistake with this "Strategic Intent" requirement, but then perhaps they are anticipating the day of reckoning when they set up to take on institutional funds at a $10B AUM level.

@Grant - I suspect many of the people here don't care for participating in the Q fund, but we do still want to win the contest for other reasons - such as patting our ego :)

Keep in mind that Q is really pioneering something new here. This model of investing has not been done before, so it is possible that they may meet resistance; or they may take off with enough early adopters to launch a rocket ship. Time will tell.

Vladimir, I guess I did pretty well, given the circumstances and information available ;)

what on earth do you guys imagine you are going to learn from any of this?

The main thought was to see how other peoples algos are doing longer term than the extremely short 2 year "backtest" on competition page and see what kind of volatility/drawdown "better" algos that people are not willing to share are having on ~10 year timescale.

I do understand from your comment that this is not your cup of tea (I totally understand that not everyone is so interested in backtest curves as I am) so feel free to ignore the whole thread - for me the results have been as interesting as I hoped, keep posting more! :-)

This is a tearsheet of my contest 19 algo, currently at 10th position.

edit: How is it possible to get the profit curve to the top of the notebook preview? Vladimir managed to do that somehow.

Behavioral Trader,

You are the winner!!!
And the prize isssss ... Full algo code with only some spicy souse wight out .

import numpy as np

def initialize(context):  
    context.assets = symbols('XLP','TLT',)  
    schedule_function(trade, date_rules.every_day(), time_rules.market_close(minutes = 30))  
def trade(context,data):  
    period = xxx  
    stk = context.assets[0]  
    bnd = context.assets[1]  
    lev = 1.0  
    hedge = xxx

    C = data.history(context.assets, 'price', period, '1d')  
    xxxxxxxxxxxxxxxxxxxxxxx  
    xxxxxxxxxxxxxxxxxxxxxxx  
    xxxxxxxxxxxxxxxxxxxxxxx  
    xxxxxxxxxxxxxxxxxxxxxxx  
    wt_stk = xxxxxxxxxxxxxx  
    wt_bnd = xxxxxxxxxxxxxx  
    order_target_percent(stk, wt_stk)  
    order_target_percent(bnd, wt_bnd)   

    record(leverage = context.account.leverage, exposure = context.account.net_leverage)

'''

Total Returns
406.3%
Benchmark Returns
78.8%
Alpha
0.40
Beta
0.23
Sharpe
3.11
Sortino
4.40
Information Ratio
2.62
Volatility
0.13
Max Drawdown
15.7%

START
1/2/2007
END
6/30/2016

'''

Mikko M

I totally understand that not everyone is so interested in backtest curves as I am so feel free to ignore the whole thread.

I completely agree with that.

There should be some code for this thread:

def initialize(context):  
    context.thread topic = Anyone else willing to share their longer term backtests?

def respond(context):  
    if context.thread topic:  
        publish_backtests  
    else:  
        pass 

Vladimir managed to do that somehow.

When publishing notebook you should activate the cell which will be the front one.
You probably have different version of pyfolio.
Clone my notebook and try from there.

Vladimir, I knew it! All you need to do is to sell the secret sauce now, good luck!

Vladimir's simple code really has me rethinking about all this complex stuff with Kalmin filters and cointegration taught by Q. Maybe simpler is better.

Sure, just pick two assets which have complemented each other for the last 15 years, and you too can produce wonderful 15-year backtests. Forget the complex stuff!

"Vladimir's simple code really has me rethinking about all this complex stuff with Kalmin filters and cointegration taught by Q. Maybe simpler is better. "

Hallelujah!

"Sure, just pick two assets which have complemented each other for the last 15 years, and you too can produce wonderful 15-year backtests. Forget the complex stuff! "

Actually, "picking" assets implies bias. There is no bias in trading a portfolio comprising of 2 ETFs, one representing stocks and the other representing bonds, like Vladimir has done here (I propose SPY for stocks, since it is more general but ok...). Until they invent new assets which are as popular as stocks and bonds, these are pretty much the most basic and general alternatives, in addition to cash. Nothing to pick, just to rotate to and from. Everything else needs to be justified, on a risk adjusted basis. "Everything else" here means trading more often, trading individual issues of stocks and bonds, adding technical or fundamental mumbo jumbo, pseudo science, and so on.

This was the main reason for my first adn original post "The Simplest Algorithm"

https://www.quantopian.com/posts/the-simplest-algorithm-1

Behavioral Trader,

All you need to do is to sell the secret sauce now, good luck!

I have couple dozens from hot to mild and have published several .
https://www.quantopian.com/posts/stock-bond-balance
https://www.quantopian.com/posts/stock-bond-balance#577aaeadbca7908192000410
But not too many people clap eyes on them.
Out of sample results pretty good :

From 2015-12-30 to 2016-07-01

Total Returns
13.2%
Benchmark Returns
2.2%
Alpha
0.24
Beta
0.05
Sharpe
3.27
Sortino
4.94
Information Ratio
2.88
Volatility
0.07
Max Drawdown
3.1%

Vladimir, these look good as well...To be honest, for a long time I was a proponent of the thought that the market is inefficient and some issues are undervalued and others are overvalued, but then I realized that while that is temporarily true, it all evens out in the end, and in the longer term it all depends on the aggregate flow of funds into broad asset classes. The focus on the short term is what is killing all traders who attempt to exploit market inefficiencies. As I sad earlier, the Warren Buffet investment window (forever) and the HFT investment window (millisecond, while already knowing you can offload at a profit) are the only time frames where risk is justified. Anything in between (minute, day, week, month, etc.) carries unjustified risk, especially in dealing with individual securities.

2 factor model...still under construction, but "big picture" has always been the focus. This algo invests 100 Million.

Some notes...
-Still a lot of engineering to be done to get it to fully operate in accordance with its underlying economic thesis.
-It is just a raw factor model, no alpha factors added yet, and no cost efficiency created from ML techniques yet.
-It only trades 10 stocks (which screams Survivor Season 3 bias...i know), but the concept expands to the universe.
-I really hope its OOS results don't lead to another "Bayesian Conehead".

Vladimir Yevtushenko
3 minutes ago Edit Delete

Magic pair XLP-TLT Leverage 1.5 fixed ratio 0.55: 0.45

START
08/01/2002
END
07/08/2016

Total Returns
420.5%
Benchmark Returns
202.1%
Alpha
0.25
Beta
0.27
Sharpe
2.38
Sortino
3.43
Information Ratio
1.30
Volatility
0.12
Max Drawdown
23%

Vlad,

Have you stress tested this strategy against a run on Treasuries? Crazy to think about.....

Vladimir, and Frank,

Not sure if Frank this is what you are talking about.....but I am wondering if there is a way to eliminate the "Fed effect" where all assets but cash increased in value. For such a basic stocks/bonds portfolio, I think we need more data points to "stress test" it, since we know what happened on and after 2009.

BT,

Yes I am alluding specifically to the run up in the Fed balance sheet that started during the great recession. A combination of defensive stocks (XLP) and long term bonds (TLT) has done very well as the Fed has increased the Monetary Base. Unlike prior eras of accommodation, we continue to see banks steadily increase reserves held with the Fed in excess of the reserve requirements. In addition we are seeing a continued decline in the velocity of money. The risk inherent to Vlad's portfolio would be a pullout of investors from Treasuries, which for most is unthinkable, and would essentially be a pullout from the greenback. When we were on the precipice of the housing bust in 2007, it was unthinkable that the american housing market would deflate in value. Now it seems as if we are in a period in which Treasury bills are rock solid in the same manner as was the housing market 9 years ago. Its a little crazy to think about, but the biggest risk to our economy today would be a steep decrease in the tax base, which would increase the credit risk of the Treasuries. This would cause massive deflation.....It is actually logical though, as the low interest rates we are seeing across western economies amount to the market essentially pricing in a deflationary environment.

Folks,
Nice thread, but any help in understanding the basic themes here would help!

Would the type of research that is indicated in
http://news.morningstar.com/articlenet/article.aspx?id=758563
lead one to believe that XLP/TLT is a co-integrated pairing, or is it a dose of some kind of bias to choose that pair?

I'm having a hard time coming up with an analytic definition of bias, but my spidy-senses tell me that XLP/TLT, with a start-point back a number of years and an end-point of now is a biased choice...are my spidy-senses wrong? How do I measure if some selection or process is biased ?

@Frank, so is what you are saying is that current results of the XLP/TLT pairing do not predict future returns, under the certain conditions you are outlining ?

alan

@ Alan,

In short yes, I agree with your "spidy sense" in that the period in which the Q back tester runs does not allow any algos to participate in a rising rate environment so a bias is implicit. Predicting future returns for XLP/TLT really comes down two fundamental questions:

1) Will the monetary base continue to expand (via monetary policy, increased money multiplier...etc)?
2) Will the world continue to place such faith in the dollar? (one case for a loss of faith would be a decrease in tax revenue)

If either of these bedrocks of our current economic regime were to fail, our quant models would be in for a wild ride. I am actually working on a model/algo using a lot of data from the FRED API. I hope to share some insights when I have completed)

EDIT: So what I am saying is that the current results of XLP/TLT are likely rooted in the declining rate environment, so predicting its future returns is a function of your faith in the dollar. (Also, I have mentioned in the past that measuring the dollar against western economies is probably a fools errand. My comparison is more or less to use Purchasing Power Parity against China, but open to other suggestions)

@Frank - I don't believe there is any bias beyond the standard SEC mandated disclaimer that past performance is not a guarantee of future results.

2003 to 2006 was a rising rate environment, and the backtest shows this model was profitable during that period.

The questions you have posed are good ones - but they are not really predictable. I guess these are shifts in the economy, although plausible and potentially the Achilles heal of this algo, they are not something that can be modeled.

If we try to model prior to 2002 (so we are talking over 14 years ago), it will put us in a position where we are modelling times when the finance markets were very much different. HFT barely existed, most of the derivative ETFs you see these days didn't exist - things were totally different. Will that be a realistic environment to try to model? I'm not sure.

@ Mohammad,

Haha yes I agree...I probably should not be casually using the term "bias" in that manner. I am just trying to point out that since the dollar was taken off the gold standard, there has never been a time comparable to 2009-Today in terms of the expansion of the monetary base. As a result, the run up in TLT can not really be compared against history, so the "bias" I describe is one of a lack of comparable economic regimes. Or maybe better to describe the "bias" as the only time in history in which 20% of the demand for Treasuries came (effectively) from the supplier.

Regarding the rising rate environment from 2003-2006, I would point out that the TLT/XLP was profitable, but did not outperform the S&P500, which is to be expected of a stock/bond mix. The Fed's balance sheet expansion is what I believe drives the out performance of TLT/XLP, as well as my rationale for stating that "bias" is implicit to this algo.

Hey,
Would have liked to have posted a more current backtest and droped the beta down a bit just for this post (currently set at my comfort level) but it doesn't work ever since they upgraded to Q2. Still haven't figured out to get it working.
![]http://imgur.com/a/Ri1Sl