EaseOfMovementValue uses a stale midpoint after a flat bar

Đang mở Phù hợp với người mới
#10,197 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Đọc các dòng 74–92 trong Indicators/EaseOfMovementValue.cs và tìm các bài kiểm thử chỉ báo liên quan. Tái hiện vấn đề với chu kỳ 1 bằng thanh giá phẳng theo sau bởi một thanh giá không phẳng như mô tả trong issue. Thêm một bài kiểm thử hồi quy để xác nhận giá trị tiếp theo là 2, đồng thời xác nhận các thanh giá thông thường và kết quả của chính thanh giá phẳng vẫn giữ nguyên hành vi hiện tại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
22.6k
Fork
5.4k
Merge trung bình
11 giờ 39 phút
Pull request đã merge (30 ngày)
104

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QuantConnect/Lean

Tất cả issue của QuantConnect/Lean

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.