EaseOfMovementValue uses a stale midpoint after a flat bar

Aperta Adatta ai principianti
#10,197 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Leggi le righe 74–92 di Indicators/EaseOfMovementValue.cs e trova i test correlati dell’indicatore. Riproduci il problema con periodo 1 usando la barra piatta seguita da una barra non piatta descritta nell’issue. Aggiungi un test di regressione che verifichi che il valore successivo sia 2, confermando al contempo che le barre ordinarie e il risultato della barra piatta stessa mantengano il comportamento attuale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

priority:p2

Problem

EaseOfMovementValue returns before updating its previous high/low when a bar is flat. The next non-flat bar therefore measures its midpoint change against an older bar, producing an incorrect indicator value.

Source: Indicators/EaseOfMovementValue.cs, lines 74–92.

Reproduction

Run these updates with period 1, so smoothing does not obscure the result. All bars have positive volume and distinct, increasing timestamps.

using System;
using QuantConnect;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

var symbol = new Symbol(SecurityIdentifier.GenerateEquity("SPY", Market.USA, false), "SPY");
var time = new DateTime(2024, 1, 2, 9, 30, 0);
var emv = new EaseOfMovementValue(1, 10000);
emv.Update(new TradeBar(time, symbol, 9, 10, 8, 9, 10000, TimeSpan.FromMinutes(1)));
emv.Update(new TradeBar(time.AddMinutes(1), symbol, 20, 20, 20, 20, 10000, TimeSpan.FromMinutes(1)));
emv.Update(new TradeBar(time.AddMinutes(2), symbol, 20, 22, 20, 22, 10000, TimeSpan.FromMinutes(1)));
Console.WriteLine(emv.Current.Value);

Executed result: 24. Expected: 2.

The final midpoint is 21 and the preceding bar's midpoint is 20. The box ratio is (10000 / 10000) / (22 - 20) = 0.5, so EMV should be (21 - 20) / 0.5 = 2. Instead, the flat bar leaves the saved midpoint at 9, yielding (21 - 9) / 0.5 = 24.

Required result

A flat bar must still become the preceding bar for the next midpoint calculation. Cover a positive-volume flat bar followed by a non-flat bar in a regression test, while preserving existing behavior for ordinary bars and the flat bar's own result.

Priority is low because the reproduction is limited to a particular indicator/input sequence; there is no evidence of widespread impact.

Lingua principale
C#
Stelle
22.6k
Fork
5.4k
Merge medio
11h 39m
PR unite (30g)
104

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QuantConnect/Lean

Tutte le issue di QuantConnect/Lean

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.