Back to Community
Futures trend reversion algo

This algo uses recently released Futures API to trade various futures contracts on different asset classes. The logic is relatively simple, and please see the comments in code. It trades intermittently and as a result the average leverage is low, and the maximum gross leverage is currently set to 2 through Optimizer API constraint .

Clone Algorithm
843
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 591e3077a4cdd865cab97736
There was a runtime error.
15 responses

Awesome, great example of using futures plus the optimize API.

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.

Cloned. This will save time. Thank you for sharing Naoki!

Why can't this be used in the paper trading on Quantopian? Keep getting the message: There was a problem deploying your algorithm to live trading: Futures not allowed in live trading. The changes I made worked fine throughout the backtests..

Thanks for your help!

Hi Brandon,

Futures trading, while available in research and backtesting, is currently not available for live trading. We're working on enabling a futures based contest and being able to make allocations to futures based strategies. We're also looking into adding futures functionality to Pyfolio.

Thanks for the quick reply!
Do you guys have a timeline on this? Or is it still quite far away?

We currently do not have a timeline for release of live trading for futures. Sorry I can't provide more info at this time. We prefer not to overpromise anything too early, so our next steps will be to complete the features I mentioned earlier and then determine what is the next most important addition.

When running backtest on 2017 data, there is an error:

KeyError: 1074201706  
There was a runtime error on line 69.  

Any tip how to resolve it?

Thank you Naoki for sharing.

I can't really understand what is context.multiplier = 2250. I saw this numer is multiply by the slope to get the weight but why did you choose 2250?

Thanks for your help

Hi Peter, have you had any luck in understanding the error? I get the same but not sure what it refers too

Hello Peter & Matteo,

We identified an issue with ER pricing data that causes the KeyError you mentioned. This is currently in our queue, but unfortunately I cannot offer a timeline for a resolution.

In the meantime, you can avoid this error by removing ER from your universe of tradable futures.

Apologies for any inconvenience.

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.

The Error may have been caused by the fact that the Russell 2000 returned to CME Group July 10th, 2017.
The ticker on many platforms changed from /TF to /RTY

What would it take to get this in plain language "trading rules"?

I can't follow all this complicated code...

The OOS performance of this strategy is flat.

Matt,

I still getting:

There was a runtime error.
KeyError:1074201706

Line: 97 incalc_slopes

    all_prices = data.history(context.futures, 'price', context.window + 1, '1d')  

Any tip how you resolve it?

Vladimir - just drop ER from the futures' list.