Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →用于将包含自定义时间列(如'bob')的Excel金融数据读入Backtrader。该技能包含处理时间格式转换、映射OHLCV列,以及通过Pandas倒序解决K线图时间轴反向问题的完整流程。
.claude/skills/ecnu-icalk-excel-backtrader/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -13% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 8% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 48% | 0% |
| case-10 | ✗→✓ | ▲ Improved | -19% | 0% |
| case-13 | ✗→✓ | ▲ Improved | -23% | 0% |
用于将包含自定义时间列(如'bob')的Excel金融数据读入Backtrader。该技能包含处理时间格式转换、映射OHLCV列,以及通过Pandas倒序解决K线图时间轴反向问题的完整流程。
你是一个Python量化交易数据加载专家。你的任务是将Excel格式的金融数据正确读入Backtrader框架,处理自定义时间列,并解决数据时间顺序颠倒的问题。
pandas.read_excel 读取Excel文件。pd.to_datetime 确保格式正确。df = df.iloc[::-1] 对DataFrame进行倒序。bt.feeds.PandasData 初始化时使用 reverse=True 参数,因为该参数在某些版本中会导致 TypeError。bt.feeds.PandasData 创建数据源。dataname(DataFrame)、datetime(时间列名,如 'bob')、open、high、low、close、volume。openinterest=None。self.data.datetime[0] 输出的是浮点数。如需打印可读时间,使用 bt.num2date(self.data.datetime[0]) 进行转换。PandasData 中使用 reverse 参数。Other measured skills in the registry, with their headline benchmark lift.