Hi everyone,
I keep running into this weird symbol issue, I am not sure where it comes from. I am using optionSymbol for sell order function which is a static value but somehow this error still occurs.
self.Sell(OptionStrategies.BullPutSpread(self.optionSymbol,
shortContractInfo.strike, longContractInfo.strike, shortContractInfo.expiry), np.floor(qty))
BACKTEST:
https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_d617cccff6c4e3c77a928e68fe3b7257.html
Rajats179
the error is:
Runtime Error: Exception has been thrown by the target of an invocation. symbol must not contain the characters '|' or ' '.
Parameter name: symbol
Stack trace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: symbol must not contain the characters '|' or ' '. Parameter name: symbol at QuantConnect.SecurityIdentifier..ctor (System.String symbol, System.UInt64 properties) [0x00027] in <fdfef00e0abc4694a6687d8e7fb478ba>:0 at QuantConnect.Symbol.op_Implicit (System.String ticker) [0x00023] in <fdfef00e0abc4694a6687d8e7fb478ba>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 at Python.Runtime.Converter.ToManagedValue (System.IntPtr value, System.Type obType, System.Object& result, System.Boolean setError) [0x00360] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.Converter.ToManaged (System.IntPtr value, System.Type type, System.Object& result, System.Boolean setError) [0x00010] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.MethodBinder.Bind (System.IntPtr inst, System.IntPtr args, System.IntPtr kw, System.Reflection.MethodBase info, System.Reflection.MethodInfo[] methodinfo) [0x002aa] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.MethodBinder.Invoke (System.IntPtr inst, System.IntPtr args, System.IntPtr kw, System.Reflection.MethodBase info, System.Reflection.MethodInfo[] methodinfo) [0x00000] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.MethodObject.Invoke (System.IntPtr target, System.IntPtr args, System.IntPtr kw, System.Reflection.MethodBase info) [0x00000] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.MethodBinding.tp_call (System.IntPtr ob, System.IntPtr args, System.IntPtr kw) [0x0019c] in <c56ab175820d412caf052e079c2ab9ef>:0 at (wrapper managed-to-native) Python.Runtime.Runtime.PyObject_Call(intptr,intptr,intptr) at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00000] in <c56ab175820d412caf052e079c2ab9ef>:0 at Python.Runtime.PyObject.TryInvoke (System.Dynamic.InvokeBinder binder, System.Object[] args, System.Object& result) [0x0001d] in <c56ab175820d412caf052e079c2ab9ef>:0 at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,QuantConnect.Python.PythonSlice) at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnData (QuantConnect.Data.Slice slice) [0x0010c] in <7fb64349bf044476b990831e144fd34a>:0 at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.ISynchronizer synchronizer, QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler transactions, QuantConnect.Lean.Engine.Results.IResultHandler results, QuantConnect.Lean.Engine.RealTime.IRealTimeHandler realtime, QuantConnect.Lean.Engine.Server.ILeanManager leanManager, QuantConnect.Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x01137] in <ecfbe1cad8f349bbb0a91d2ce1bf1646>:0
Derek Melchin
Hi Rajats179,
There is an underlying bug in the contract selection logic. Specifically, the algorithm is selecting the same contract to long and short. Consider adjusting how the contracts are selected.
See the attached backtest for reference.
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.
Rajats179
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!