Hi Team,
I've tried running an intraday arbitrage strategy based on the mispricing & price deviations vs the price correlation between corn and soybean futures.
The issue once I run the backtesting for the strategy - processing a total of 19,325 data points; there is no output or error.
Could you please advice?
Best regards,
Marcello
230 | 23:34:39:
Building Project ID: 8065675 Content Signature: 291cd6c135f883d495d9653c1b5fb1a0
231 | 23:34:43:
Build Request Successful for Project ID: 8065675 CompileID: b6e5cc64710e26e32c5b1fbe5e5ecb52-5f8e374d84a0586a0af678c5720aa3ec Lean Version: 2.5.0.0.11516
232 | 23:34:43:
Backtesting Project ID: 8065675
233 | 23:34:44:
Build Request Successful for Project ID: 8065675 CompileID: de37a057f5e3ca0dd52c904f908a634c-5f8e374d84a0586a0af678c5720aa3ec Lean Version: 2.5.0.0.11516
234 | 23:34:45:
Successfully sent backtest request for 'Formal Magenta Elephant', (Compile Id: b6e5cc64710e26e32c5b1fbe5e5ecb52-5f8e374d84a0586a0af678c5720aa3ec)
235 | 23:34:50:
Initializing algorithm...
236 | 23:34:51:
Backtest deployed in 5.55 seconds
237 | 23:34:51:
Launching analysis for 5abcb9af07f4e1e4dad30c2ca38f2728 with LEAN Engine v2.5.0.0.11516
238 | 23:34:52:
Algorithm (5abcb9af07f4e1e4dad30c2ca38f2728) Completed.
239 | 23:34:52:
Algorithm Id:(5abcb9af07f4e1e4dad30c2ca38f2728) completed in 0.87 seconds at 22k data points per second. Processing total of 19,325 data points.
240 | 23:34:52:
Your log was successfully created and can be retrieved from: https://www.quantconnect.com/backtest/103379/8065675/5abcb9af07f4e1e4dad30c2ca38f2728-log.txt
MARCELLO CULTRERA
I've made some minor changes but the error now appears as:
During the algorithm initialization, the following exception has occurred: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'int'>) method. Please checkout the API documentation. at Initialize data = self.AddData(self.symbols in main.py:line 80 TypeError : No method matches given arguments for AddData: (, )MARCELLO CULTRERA
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
#from QuantConnect.Python import PythonQuandl
from datetime import timedelta
from math import floor
from decimal import Decimal
import numpy as np
import decimal as d
from sklearn import linear_model
import pandas as pd
from scipy import stats
from math import floor
from ArbAlphaModel import ArbAlphaModel
class CommoditiesIntradayArbitrageAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 1, 1)
self.SetEndDate(2021, 1, 1)
self.SetCash(1000000)
self.numdays = 1000 # set the length of training period
tickers = ["Futures.Grains.Corn", "Futures.Grains.Soybeans"]
self.symbols = [ Symbol.Create(t, SecurityType.Future, Market.Globex) for t in tickers ]
self.Data = {}
for ticker in tickers:
data = self.AddData(self.symbols, Resolution.Minute)
future = self.AddFuture(ticker)
future.SetFilter(timedelta(0), timedelta(days = 90))
self.threshold = 1.
for i in tickers:
self.symbols.append(self.AddSecurity(SecurityType.Future, i, Resolution.Minute).Symbol)
for i in self.symbols:
i.hist_window = RollingWindow[QuoteBar](self.numdays)
self.SetUniverseSelection(ManualUniverseSelectionModel(self.symbols) )
self.UniverseSettings.Resolution = Resolution.Minute
self.AddAlpha(ArbAlphaModel())
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(lambda time: None))
self.SetExecution(ImmediateExecutionModel())
self.Settings.RebalancePortfolioOnSecurityChanges = False
Derek Melchin
Hi Marcello,
The intraday arbitrage strategy in the Strategy Library is only currently functional with equities. It can be adjusted to work with futures contracts by only trading the front month contracts. However, the strategy requires that only 2 securities are subscribed to at any given time. We currently have an open GitHub Issues for futures where expired contracts aren't unsubscribed to immediately. Therefore, the algorithm breaks when there are more than 2 active futures subscriptions. Once we've resolved this GitHub Issue, the strategy can be adjusted further to work with futures contracts. Subscribe to our progress on fixing the issue here.
See the attached backtest for a demonstration of the issue with unsubscribing from futures contracts.
Best,
Derek Melchin
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.
MARCELLO CULTRERA
I'll do more work on this.
Regards,
Marcello
MARCELLO CULTRERA
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!