I wish to use the IndicatorExtensions.Minus() composite indicator function in the Update function of a custom indicator (Py) but received this error:

Runtime Error: RuntimeBinderException : The best overloaded method match for 'QuantConnect.Indicators.IndicatorExtensions.Minus(Python.Runtime.PyObject, decimal)' has some invalid arguments
at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,System.Type,object,object)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1, T2 arg2) [0x0011a] in <92922d9bda2f4e1cba9242d052be6d43>:0
at QuantConnect.Indicators.IndicatorExtensions.Minus (Python.Runtime.PyObject left, Python.Runtime.PyObject right, System.String name) [0x00096] in <31d71f9023394fa885170f3eadc85c43>: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
at Update in main.py:line 286

The indicator Update function contains the statement:

self.chngCloseInd.Update(IndicatorExtensions.Minus(self.inputRWin[0], self.inputRWin[1]))

Where self.inputRWin is defined in the init function of the custom indicator class as:

self.inputRWin = RollingWindow[TradeBar](period)

My expectation from the lean engine code:

namespace QuantConnect.Indicators
public static class IndicatorExtensions

Is that the binder would select the highlighted Minus overload, or py equivalent:

CompositeIndicator<T> Minus<T>(this IndicatorBase<T> left, IndicatorBase<T> right) where T : IBaseData
object Minus(PyObject left, decimal constant)
object Minus(PyObject left, PyObject right, string name = "")

However the implementation selected the first py overload above.

I attempted to force a different overload by:

self.chngCloseInd.Update(IndicatorExtensions.Minus(self.inputRWin[0], self.inputRWin[1], ""))

And to simplify the argument terms, as here: 

# vmapChng = IndicatorExtensions.Minus(self.inputRWin[0], self.inputRWin[1])
# vmapChng = IndicatorExtensions.Minus(self.inputRWin[0], self.inputRWin[1], "")
t0 = self.inputRWin[0]
t1 = self.inputRWin[1]
vmapChng = IndicatorExtensions.Minus(t0, t1)

However the same runtime error, as above, was generated.

The inheritance hierarchies, leaf to root, are rooted at IBaseData.

IndicatorBase is:

IndicatorBase<T> : IIndicator<T> where T : IBaseData

TradeBar is:

TradeBar : BaseData, IBaseDataBar

BaseData : IBaseData

And this code passes the Runtime Binder:


I have a workaround that does not use IndicatorExtensions.Minus() but would appreciate suggestions that enable the ‘Minus’ function to be used.

Thanks for your time, Chris.