QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.52k stars 3.22k forks source link

Extend LeastSquaresMovingAverage to Accept a Benchmark #6984

Open AlexCatarino opened 1 year ago

AlexCatarino commented 1 year ago

Expected Behavior

Lean supports LeastSquaresMovingAverage as a Lean Indicator which takes a Symbol object, a benchmark Symbol, and a look-back period.

Actual Behavior

The current implementation assumes a constant slope: LeastSquaresMovingAverage.cs#L59. See #83.

Potential Solution

Implement this indicator.

Checklist

pranavathreya commented 4 months ago

Sorry if this is a redundant question, but how can I reproduce this issue? I do not see the information here in spite of the fourth box on the checklist being ticked.

AlexCatarino commented 4 months ago

Hi @pranavathreya , It's not a bug; it's a feature.

The goal is to implement this method:

public LeastSquaresMovingAverage LSMA(Symbol symbol, Symbol reference, int period,
     Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
    // ...
}

see the new Symbol reference parameter which will be used by the LeastSquaresMovingAverage constructor:

var leastSquaresMovingAverage = new LeastSquaresMovingAverage(name, reference, period);

You can look for the A indicator for reference.

pranavathreya commented 4 months ago

Hi @AlexCatarino, thank you so much for this context. Let me do some reading and get back to you.

pranavathreya commented 4 months ago

I can implement this method. Could you please assign it to me?

AlexCatarino commented 4 months ago

Hi @pranavathreya, please follow the Docs on how to add indicators to LEAN.