Back

Strategies implementation pool

Hi there,

I guess everyone has a list of strategies to implement someday… and if your case is like mine, that day never comes.

To overcome the laziness and to make challenging, let’ play a game.

There are, in the following 3 comments, three strategies based in academic papers. I will fully implement in Lean the strategy with most votes at Monday.

I’ll implement the strategy in a new Lean fork to make the whole developing process as transparent as possible. Also there you’ll can comment and suggest improvements and point out errors (maybe I’m too optimistic with the participant commitment :D).

If your strategy isn’t the winner at the end of this week pool, maybe you can implement it and share it with the community.

Also, if you have some paper or academic-based strategies, please submit it! The idea is to make this a periodical thing, so your strategy can participate in the next pool.

Next… the candidates for this week:

Update Backtest






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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.



Term Structure Effect in Commodities

This simple strategy buys each month the 20% of commodities with the highest roll-returns and shorts the 20% of commodities with the lowest roll-returns and holds the long-short positions for one month. The contracts in each quintile are equally-weighted. The investment universe is all commodity futures contracts.

Source.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Time Series Momentum Effect

Every month, the investor considers whether the excess return of each asset over the past 12 months is positive or negative and goes long on the contract if it is positive and short if negative. The position size is set to be inversely proportional to the instrument’s volatility. A univariate GARCH model is used to estimated ex-ante volatility in the source paper. However, other simple models could probably be easily used with good results (for example, the easiest one would be using historical volatility instead of estimated volatility). The portfolio is rebalanced monthly.

Source.

1

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Short Term Reversal with Futures

The investment universe consists of 24 types of US futures contracts (4 currencies, 5 financials, 8 agricultural, 7 commodities). A weekly time frame is used - a Wednesday- Wednesday interval. The contract closest to expiration is used, except within the delivery month, in which the second-nearest contract is used. Rolling into the second nearest contract is done at the beginning of the delivery month.

The contract is defined as the high- (low-) volume contract if the contract's volume changes between period from t-1 to t and period from t-2 to t-1 is above (below) the median volume change of all contracts (weekly trading volume is detrended by dividing the trading volume by its sample mean to make the volume measure comparable across markets).

All contracts are also assigned to either high-open interest (top 50% of changes in open interest) or low-open interest groups (bottom 50% of changes in open interest) based on lagged changes in open interest between period from t-1 to t and period from t-2 to t-1. The investor goes long (short) on futures from the high-volume, low-open interest group with the lowest (greatest) returns in the previous week. The weight of each contract is proportional to the difference between the return of the contract over the past 1 week and the equal-weighted average of returns on the N (number of contracts in group) contracts during that period.

Source.

4

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


And the winner is...

Short Term Reversal with Futures, and the implementation was awesomely done by Alexandre Catarino! There is so much to learn from that alogirthm.

In the meantime, I’m implementing the Time Series Momentum Effect strategy, attached is the first working draft with forex. The next steps are adding the others securities types (CFD, futures, bonds) and incorporate some basic risk management.

 

1

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi JayJay.  Thanks for your excellent community contributions.

I'm confused though, is the Short Term Reversal with Futures implementation posted somewhere?

0

Hi Nate Betz, thank for your kind words!

Alex's implementation can be found in this post:

https://www.quantconnect.com/forum/discussion/1884/term-structure-effect-in-commodities

 

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Attached is my Time Series Momentum Effect strategy implementation.

Isn’t as polish and as complete as I’d like, maybe someone else wants to continue developing it. On the good side, just with the Forex and CFD we have e multi-asset multi-currency backtest!

The algorithm even had the bonds futures implementation thought the Quandl SCC database. But the problem is the brokerage model. If the brokerage isn’t set the bonds aren’t traded but if the brokerage model is not set, then the Forex and CFD behavior is weird.

But you can try running only the bond futures with the default brokerage.

Finally, the strategy behavior is pretty lame and again, very far from the Quantpedia forecast. But, I didn’t implement the commodities futures and I left room for improving how much of the portfolio goes for each kind of asset, through the portfolioShareToAssetType dictionary.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


EDIT

The algorithm even had the bonds futures implementation thought the Quandl SCF database. But the problem is the brokerage model. If the brokerage is set then the bonds aren’t traded but if the brokerage model is not set, then the Forex and CFD behavior is weird. 

 

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed