Hey All!
I did a non-technical introduction to pairs trading today with Interactive Brokers. I always felt most pairs trading tutorials dived straight into the numbers so I wanted to make this one as simple as possible. You can see the Notebook and Backtest we used attached here. The slides are available in PDF format on Slide Share:
Jared Broad
IB has shared the video for this webinar; you can see it here:
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.
Tim De Lise
Very Nice Jared!
Brandon La Porte
Hi there, I'm new to quantconnect. I really enjoyed the video and wanted to play around with the notebook. I have cloned the notebook and tried to run it but it keeps giving me an error in the cell with the following code.
syls = ["XOM","CVX"] qb.AddEquity(syls[0]) qb.AddEquity(syls[1]) start = datetime(2003,1,1) end = datetime(2009,1,1) x = qb.History(syls[0], start, end, Resolution.Daily).loc[syls[0]]['close'] y = qb.History(syls[1], start, end, Resolution.Daily).loc[syls[1]]['close']
when assigning the history to x I get an attribute error no attribute loc because qb.History is not returning a Pandas Dataframe.
I tried the following to see what type was being returned by History
syls = ["XOM","CVX"] qb.AddEquity(syls[0]) qb.AddEquity(syls[1]) start = datetime(2003,1,1) end = datetime(2009,1,1) x = qb.History(syls[0], 10, Resolution.Daily) type(x)
and the type below is returned
QuantConnect.Util.1, Culture=neutral, PublicKeyToken=null]]I wasnt able to find the api documentation to try and determine what QuantConnect.Util.1 can anyone point me in the correct direction, or let me know if I'm making a complete Noob mistake.
Thanks
Jing Wu
Hi Brandon,
The research notebook is supporting Python3 now. We've modified this file. You just need to add "[ ]" to symbol list when requesting the history price.
Brandon La Porte
Thanks, that did it!
Eric Borgos
I have done automated trading before, and have a lot of pair trading experience, but only on Multicharts, Tradestation, and Quantopian, so I am a little unclear how your live trading code works. I cloned your notebook and upgraded to the $20/month Quantconnect account, and then as a test ran your strategy live in my IB account (it is Sunday so there were no trades) and then turned it off.
Everything looks good, the only thing I don't understand is how it knows how much money to trade. If I have $30,000 in my IB acccount (all cash, no stock holdings) and your notebook has the setting self.SetCash(10000) I assume that means it would do a $10,000 trade. But for pair trading, does that mean it would trade $10,000 of each stock in the pair, or $5,000 of each stock for a total of $10,000?
Eric Borgos
Never mind, I see now from the backtest. It trades 100 shares of each.
Mat mat
Thank you for sharing. Is " max.lag = 1 " in the ADF test a restrictive assumption? Will it be different if we choose another value?
Brian Norris
does anyone else get a blank screen when trying to clone the notebook?
Â
https://www.quantconnect.com/research/notebook/25187/Webinar%20%20Pairs%20Trading%20Strategy%20Based%20on%20Cointegration.ipynbÂ
Jack Simonson
Hi Brian,
This is a known issue and we are working to address it, but the notebook does get cloned and you can access it by opening a new tab and navigating to the Research Environment.
Raul Bartolome
If you get the following error
Do the following change, replace
by
Thanks to Derek Melchin commnets.
BR,Raul
Jared Broad
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!