Futures are now available in backtesting. You can now access futures data and trade contracts. You can implement algorithms that trade futures alone, or algorithms that trade both futures and equities. New data and new tradable assets means new opportunities to find alpha. If you have your eye on an allocation, this is the first opportunity for futures algos to be evaluated on Quantopian, so correlation to other algos is as low as it will get.
We didn't just expand the API, we launched a new curriculum to help you learn about futures. We added a tutorial to help get you started with the new Futures API, and a handful of lectures including an introduction to how futures work and some advanced lessons on trading futures quantitatively.
There's a lot of new stuff, so here are some more details on what we've added.
Futures Data in Research
Futures data for 72 different US futures is available in Research for you to analyze and formulate ideas. The data includes 24 hour as-traded pricing and volume data, 5 days a week. Similar to what we have for equities, futures data is available at a daily or minutely frequency and includes open, high, low, close, and volume data (OHLCV)
The Futures API includes continuous futures. You can use continuous futures to request for windows of pricing/volume data for a particular underlying commodity/asset without having to worry about all the different contracts trading simultaneously for that same underlying.
In case you missed it, we posted an example notebook that walks through the new API.
Futures Available in Backtesting
Futures data is now available in backtests so you can now develop algorithms that trade futures contracts. Similar to research, your algorithms can now access 24 hour futures pricing/volume data at a daily or minutely level. In order to get futures data in an algorithm, you will need to run your backtests on the US Futures trading calendar. There is a new dropdown menu where you can pick between the US Equities or US Futures calendar. Equities data is available on either calendar but futures data is only available on the US Futures calendar. The US Futures calendar runs from 6:30am-5pm ET. The US Equities calendar is the 9:30am-4:00pm ET calendar that you are used to on Quantopian.
Continuous futures are available in backtests. The same function that allows you to build continuous futures in research is available in the backtester. You can get the history of a continuous future via
You can trade futures contracts in your algorithms. A very common technique to ordering futures contracts is to use the continuous future to get a reference to the current active or front contract for a particular underlying commodity/asset. To do this, you can pass a
data.current(), and ask for the
'contract' field. For example, if you want the contract to which a crude oil
ContinuousFuture is current pointing, you can do something like this:
context.cl = continuous_future('CL') ... current_contract = data.current(context.cl, 'contract')
Once you have the current contract, you can place an order for futures contracts using
We added 4 new lectures to the Quantopian Lecture Series to teach you about futures, and how to think of them in the context of quantitative finance:
- Introduction to Futures (walks through what futures are and how they work)
- Futures Trading Considerations
- Introduction to Volume, Slippage, and Liquidity
- Mean Reversion on Futures
The lectures are a great way to learn about some of the theory behind trading futures. We are expecting to add more lectures in the near future.
We launched a Getting Started With Futures Tutorial that teaches you how to use futures data in research and how to include futures in your algorithms. The tutorial walks through the new Futures API in Research and Backtesting and builds up to a simplified version of the Pair Trading Example in the Mean Reversion on Futures lecture.
Help Documentation Updated
We added the new Futures API to the help documentation so you can learn about the new functions that we added and how to use them. The existing documentation was updated to explain how certain functions work on the US Futures calendar (e.g. schedule_function()).
We also added 2 sample algorithms that trade futures.
Slippage & Commission
We made new slippage and commission models for algorithms that trade futures. When you run backtests on algorithms that trade futures, they will use per-future models with parameters that depend on the particular underlying commodity/asset being traded.
The default commission model used for futures on Quantopian is Interactive Broker's fixed commission model and includes per-trade exchange fees.
The default slippage model used for futures is a special volatility volume share model that was fit to empirical data.
Note that if you run a backtest on an algorithm that trades equities and futures, the equity slippage + commission models will be applied to your equity trades, while the futures models will be placed to any contracts that you order.
We look forward to working with the community as you develop strategies that trade futures. Over the next few months, we will start to evaluate these strategies. We look forward to making our first allocation to a futures algo!