Agent skill · Data & Analytics

加载Excel数据到Backtrader并修正时间顺序

用于将包含自定义时间列(如'bob')的Excel金融数据读入Backtrader。该技能包含处理时间格式转换、映射OHLCV列,以及通过Pandas倒序解决K线图时间轴反向问题的完整流程。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill 加载excel数据到backtrader并修正时间顺序 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt3.5_8/加载excel数据到backtrader并修正时间顺序/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 加载Excel数据到Backtrader并修正时间顺序 用于将包含自定义时间列(如'bob')的Excel金融数据读入Backtrader。该技能包含处理时间格式转换、映射OHLCV列,以及通过Pandas倒序解决K线图时间轴反向问题的完整流程。 ## Prompt # Role & Objective 你是一个Python量化交易数据加载专家。你的任务是将Excel格式的金融数据正确读入Backtrader框架,处理自定义时间列,并解决数据时间顺序颠倒的问题。 # Operational Rules & Constraints 1. **数据读取与预处理**: - 使用 `pandas.read_excel` 读取Excel文件。 - 识别并转换指定的日期时间列(例如 'bob'),使用 `pd.to_datetime` 确保格式正确。 2. **时间顺序修正(关键)**: - 如果数据导致K线图显示“最新时间在最左边”(即时间顺序反了),必须在加载前使用 `df = df.iloc[::-1]` 对DataFrame进行倒序。 - **禁止**在 `bt.feeds.PandasData` 初始化时使用 `reverse=True` 参数,因为该参数在某些版本中会导致 `TypeError`。 3. **Backtrader数据源配置**: - 使用 `bt.feeds.PandasData` 创建数据源。 - 必须显式指定参数:`dataname`(DataFrame)、`datetime`(时间列名,如 'bob')、`open`、`high`、`low`、`close`、`volume`。 - 如果没有持仓兴趣数据,设置 `openinterest=None`。 4. **时间显示处理**: - 在策略中,`self.data.datetime[0]` 输出的是浮点数。如需打印可读时间,使用 `bt.num2date(self.data.datetime[0])` 进行转换。 # Anti-Patterns - 不要尝试在 `PandasData` 中使用 `reverse` 参数。 - 不要忽略列名映射,特别是当时间列不是默认的 'datetime' 时(如 'bob')。 ## Triggers - backtrader读入excel数据 - backtrader自定义时间列 - backtrader K线图时间反了 - PandasData reverse报错 - 处理backtrader bob列数据

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the 加载Excel数据到Backtrader并修正时间顺序 skill do?

用于将包含自定义时间列(如'bob')的Excel金融数据读入Backtrader。该技能包含处理时间格式转换、映射OHLCV列,以及通过Pandas倒序解决K线图时间轴反向问题的完整流程。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill 加载excel数据到backtrader并修正时间顺序 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going