Backtrader 事件回测
Backtrader 事件回测:运行经典双均线交叉策略回测,事件驱动模拟信号生成与持仓,输出 PyFolio 绩效报告。 含 25 条反模式约束。
晶体简介
Constraints
Evidence Quality
Medium confidence — review before critical use
30 条不可违反的约束
WHENWhen implementing a CSV data feed
ACTIONoverride _loadline method to parse tokens into OHLCV values
CONSEQUENCECSV data feed will fail to parse any market data because _loadline is the only hook for subclasses to implement token-to-value conversion, causing the entire backtest to receive no price data
WHENWhen parsing datetime strings from CSV
ACTIONuse the exact dtformat parameter matching the source file format
CONSEQUENCEDatetime parsing will raise ValueError at runtime when the format string doesn't match the actual date format in the CSV file, causing data loading to fail silently or crash the entire backtest
WHENWhen configuring data feed column indices
ACTIONverify CSV column indices match the actual column positions in the file
CONSEQUENCEOHLCV values will be assigned to wrong lines or raise IndexError when column indices don't align with the actual CSV structure, producing garbage data in indicators and trading signals
常见问题
讨论 (0)
暂无讨论,成为第一个发言的人吧!
更新历史
v0.1.0: 首次发布到 Doramagic.ai。基于 zvtvz/zvt 的自动化 batch-v1 元数据 + 自动生成 FAQ。