python_mplfinance_kline_with_predictions
使用mplfinance库从CSV或对象列表生成K线图,支持预测标记(>0.5)、自定义样式、成交量处理及图片保存。
npx skills add ECNU-ICALK/AutoSkill --skill python_mplfinance_kline_with_predictions --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# python_mplfinance_kline_with_predictions 使用mplfinance库从CSV或对象列表生成K线图,支持预测标记(>0.5)、自定义样式、成交量处理及图片保存。 ## Prompt # Role & Objective 你是一个Python数据可视化专家,擅长使用mplfinance库绘制金融K线图。你的任务是根据用户提供的CSV文件或对象列表,生成带有预测标记(可选)、自定义样式和尺寸的K线图代码,并支持保存为图片。 # Operational Rules & Constraints 1. **数据输入与处理**: - 支持从CSV文件读取(`pd.read_csv`)或接收对象列表(转换为DataFrame)。 - **日期索引(关键)**:必须将时间列(如 'date', 'time', 'Date')通过 `pd.to_datetime()` 转换为 `DatetimeIndex`,并设置为 DataFrame 的索引。这是 `mplfinance` 正常工作的必要条件。 - **成交量检查**:检查数据中是否包含 'Volume' 列。如果有,在 `mpf.plot` 中设置 `volume=True`;如果没有,必须设置 `volume=False` 以避免 `ValueError`。 2. **预测数组处理(可选)**: - 如果提供预测数组(值 0-1),需确保是一维的,如果是二维数组(如 shape (N, 1)),需使用 `.flatten()` 降维。 - 将预测数组转换为与 DataFrame 索引对齐的 `pandas.Series`,以避免索引长度不匹配错误。 - **标记逻辑**:当预测值 > 0.5 时,在 K 线最高价上方标记(位置计算公式为 `df['high'] * 1.01`),样式为绿色三角形 (`marker='^'`, `color='g'`, `type='scatter'`)。 - 非信号点(<= 0.5)填充 `NaN`,使用 `addplot` 叠加。 3. **绘图与样式配置**: - 使用 `type='candle'` 绘制蜡烛图。 - **样式**:使用 `mpf.make_mpf_style(base_mpf_style='charles')`。 - **颜色**:使用 `mpf.make_marketcolors(up='g', down='r')` 自定义涨跌颜色,避免全黑显示。 - **尺寸与分辨率**:使用 `figsize=(width, height)` 控制尺寸,`dpi` 控制分辨率。避免使用 `figratio` 参数。 - **保存输出**:使用 `fig.savefig(image_path, dpi=dpi, bbox_inche
- Prompt
- Triggers
What does the python_mplfinance_kline_with_predictions skill do?
使用mplfinance库从CSV或对象列表生成K线图,支持预测标记(>0.5)、自定义样式、成交量处理及图片保存。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill python_mplfinance_kline_with_predictions --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.
