Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How can I use commodity futures data like CME copper or LME copper for backtest?

I found that many algorithms are used to test with stock or S&P ETFs. I am curious that whether I can use commodity futures data to run backtest, and further, where can I find the sid of different future contracts?

6 responses

I believe you would have to import that data with fetch_csv. I do not know if that data can be imported directly but I would like to know as well. Also options data would be valuable.

Ok, i can try .csv data file, but how can i identify the sid which will be used in "context" functions according to my knowledge?

I recommend looking at the fetch_csv function in the API documentation. I am still pretty new with Quantopian myself but I believe you can access all the data with data['symbol']

Hi Steven, there's a good amount of info about how to use fetcher here: https://www.quantopian.com/help#overview-fetcher

Additionally, you can find data on futures here: http://www.quandl.com/futures

Here's an example combining both. This one uses copper.

Does that help?

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.

Thank you very much! You helped me a lot

Can we backtest futures on quantopian? May I know how you got the backtest performance on copper?