Optimization analysis fails on parameter points revisited by Euler search
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in Optimizer/Analysis/OptimizationModes.cs at the ToDictionary call in OptimizationModes.Find, then read the analysis flow through OptimizationAnalyzer.Run and LeanOptimizer.TriggerOnEndEvent. Add coverage for duplicate coordinates and overlapping Euler passes, including repeated coordinates with different metrics; done means successful final analysis with the chosen representation policy explicit in tests.
由索引模型根据 Issue 内容生成。
描述
Problem
The final optimization analysis throws when multiple backtests have the same parameter coordinates. Euler search legitimately revisits points from its coarse pass during refinement, so a completed Euler optimization can lose its aggregate analysis even when every backtest succeeds.
OptimizationModes.Find builds a dictionary of grid coordinates using indexed.ToDictionary(...) in Optimizer/Analysis/OptimizationModes.cs:66. Repeated coordinates cause ArgumentException. LeanOptimizer.TriggerOnEndEvent catches the exception and completes the optimization, but the final analysis is not assigned.
This is existing behavior on master; it does not require automatically calculated steps.
Minimal reproduction
using System.Collections.Generic;
using QuantConnect.Optimizer;
using QuantConnect.Optimizer.Analysis;
using QuantConnect.Optimizer.Parameters;
using QuantConnect.Statistics;
var backtests = new List<OptimizationBacktestMetrics>
{
new()
{
BacktestId = "coarse",
Parameters = new Dictionary<string, decimal> { ["x"] = 1m },
SharpeRatio = 1m,
TotalPerformance = new AlgorithmPerformance()
},
new()
{
BacktestId = "refined",
Parameters = new Dictionary<string, decimal> { ["x"] = 1m },
SharpeRatio = 1m,
TotalPerformance = new AlgorithmPerformance()
}
};
var parameters = new HashSet<OptimizationParameter>
{
new OptimizationStepParameter("x", 1m, 2m, 1m)
};
new OptimizationAnalyzer().Run(
new OptimizationAnalysisRunParameters(backtests, parameters));
Observed:
System.ArgumentException: An item with the same key has already been added. Key: 0
at QuantConnect.Optimizer.Analysis.OptimizationModes.Find(...)
at QuantConnect.Optimizer.Analysis.OptimizationAnalyzer.Run(...)
Also reproduced end to end with ParameterizedAlgorithm: Euler search with ema-fast 10..30, step 10, minimum step 5, and ema-slow fixed at 50 produces a three-backtest coarse pass followed by five refined backtests. All eight backtests complete successfully. The repeated points (10,50), (20,50), and (30,50) then trigger the duplicate-key error during final analysis.
Expected behavior
Repeated parameter coordinates must not prevent analysis of an otherwise successful optimization. Define how repeated observations are represented when finding modes, and add coverage for duplicate coordinates and overlapping Euler passes. Any aggregation or representative-selection policy should be explicit and tested, including repeated coordinates with different metrics.
- 主要语言
- C#
- 星标
- 22.6k
- 派生
- 5.4k
- 平均合并
- 11 小时 39 分钟
- 30 天内合并 PR
- 104
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
QuantConnect/Lean 的其他 Issue
-
priority:p2
难度 2/5 1-3 小时 新手友好度 72/100
QuantConnect/Lean#10216 ·
维护者通常 1 天内回复
-
priority:p2
难度 2/5 1-3 小时 新手友好度 78/100
QuantConnect/Lean#10206 ·
维护者通常 1 天内回复
-
priority:p2
难度 2/5 1-3 小时 新手友好度 85/100
QuantConnect/Lean#10199 ·
维护者通常 1 天内回复
-
priority:p2
难度 2/5 1-3 小时 新手友好度 76/100
QuantConnect/Lean#10198 ·
维护者通常 1 天内回复
-
priority:p2
难度 2/5 1-3 小时 新手友好度 78/100
QuantConnect/Lean#10197 ·
维护者通常 1 天内回复
查看 QuantConnect/Lean 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
dotnet-outdated/dotnet-outdated#871 ·
维护者通常 1 天内回复
-
triage/untriaged
难度 2/5 1-3 小时 新手友好度 78/100
unoplatform/uno#26676 ·
维护者通常 1 天内回复
-
.NET bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
jhaizhou-ops/S2Arm#2177 · 3 条评论 ·
维护者通常 1 天内回复
-
area-CodeGen-coreclr untriaged
难度 2/5 1-3 小时 新手友好度 65/100
dotnet/runtime#138181 · 1 条评论 ·
维护者通常 1 天内回复