charting by starchild-ai-agent/official-skills
npx skills add https://github.com/starchild-ai-agent/official-skills --skill charting在创建图表时,切勿调用 price_chart、get_coin_ohlc_range_by_id、twelvedata_time_series 或任何市场数据工具。图表脚本会在内部获取数据。调用这些工具会给你的上下文带来超过 78KB 的不必要数据。
工作流程(4个步骤):
skills/charting/scripts/ 读取模板scripts/bash 运行脚本read_file,然后使用 Markdown 图片语法显示:广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
你生成的是 TradingView 品质的 K 线图。深色主题,简洁布局,专业配色。每个图表都是一个独立的 Python 脚本——无需内部导入。
附加规则:
core 导入。请直接使用 requests 库,不要使用 proxied_get()。PROXY_HOST 环境变量,脚本会自动配置 HTTP_PROXY/HTTPS_PROXY。工具:write_file, bash, read_file
简单的价格走势 → 无指标的 K 线图。适用于“给我看看 BTC 这个月的走势”。趋势分析 → 添加 EMA/SMA 叠加线。适用于“ETH 处于上升趋势吗?”。动量检查 → 添加 RSI 或 MACD 作为子图。适用于“SOL 是否超买?”。完整技术视图 → K 线 + 布林带 + RSI + MACD。适用于“给我 BTC 的完整图景”。成交量分析 → 需要从 market_chart 端点单独获取(OHLC 端点没有成交量)。资产比较 → 比较两种资产的折线图(BTC 与黄金,ETH 与 S&P500 等)。使用比较模板进行标准化或基于百分比的比较。
阅读并自定义 skills/charting/scripts/ 中的模板脚本:
chart_template.py — 具有 TradingView 风格的基准 K 线图(通过 CoinGecko 获取加密货币数据)chart_with_indicators.py — RSI、MACD、布林带、EMA/SMA 示例(通过 CoinGecko 获取加密货币数据)chart_stock_template.py — 使用 Twelve Data API 的股票/外汇图表chart_comparison_template.py — 比较两种资产(加密货币 vs 商品,股票 vs 加密货币等)将相关模板复制到 scripts/,自定义配置部分(币种、天数、指标),然后运行它。
模板内部处理所有数据获取,包含重试逻辑和错误处理。
注意: 这些模板用于市场数据可视化(价格图表、指标)。对于回测结果图表(权益曲线、回撤、性能仪表板),请直接在回测脚本中添加 matplotlib 图表——数据已经存在,无需重新获取或创建单独的文件。
| 元素 | 颜色 | 十六进制 |
|---|---|---|
| 上涨 K 线 | 青色 | #26a69a |
| 下跌 K 线 | 红色 | #ef5350 |
| 背景 | 深色 | #131722 |
| 网格 | 微妙的点状 | #1e222d |
| 文本 / 坐标轴 | 浅灰色 | #d1d4dc |
| 均线 | 蓝色 / 橙色 | #2196f3 / #ff9800 |
| RSI 线 | 紫色 | #b39ddb |
| MACD 线 | 蓝色 | #2196f3 |
| 信号线 | 橙色 | #ff9800 |
除非用户要求,否则不要偏离此配色方案。
端点: https://pro-api.coingecko.com/api/v3/coins/{coin_id}/ohlc/range 认证: 请求头 x-cg-pro-api-key: {COINGECKO_API_KEY} 用于: BTC、ETH、SOL 及所有加密货币
示例:
url = f"https://pro-api.coingecko.com/api/v3/coins/{COIN_ID}/ohlc/range"
params = {"vs_currency": "usd", "from": from_ts, "to": now, "interval": "daily"}
headers = {"x-cg-pro-api-key": os.getenv("COINGECKO_API_KEY")}
resp = requests.get(url, params=params, headers=headers)
raw = resp.json() # [[timestamp_ms, open, high, low, close], ...]
端点: https://api.twelvedata.com/time_series 认证: 查询参数 apikey={TWELVEDATA_API_KEY} 用于: 股票(AAPL, MSFT)、外汇(EUR/USD)、商品(黄金的 XAU/USD)
常用符号:
AAPL, MSFT, GOOGL, TSLA, SPYEUR/USD, GBP/JPY, USD/CHFXAU/USD(黄金), XAG/USD(白银), CL/USD(原油)时间间隔: 1min, 5min, 15min, 30min, 1h, 4h, 1day, 1week, 1month
示例:
url = "https://api.twelvedata.com/time_series"
params = {
"symbol": "XAU/USD", # 黄金现货价格
"interval": "1day",
"outputsize": 90, # K 线数量
"apikey": os.getenv("TWELVEDATA_API_KEY")
}
resp = requests.get(url, params=params)
data = resp.json()
# data["values"] = [{"datetime": "2024-01-01", "open": "2050.00", "high": "2060.00", ...}, ...]
重要: Twelve Data 返回的数据是逆序的(最新的在前)。在创建 DataFrame 之前,请始终反转列表:
values = data["values"][::-1] # 反转为最旧的在先
模板现在会自动选择最佳时间间隔,以在保持视觉质量的同时最小化数据量:
| 时间范围 | 自动选择的时间间隔 | 原理 |
|---|---|---|
| ≤31 天 | 小时 | 短期分析的高粒度 |
| 32-365 天 | 日 | 足够的细节,较低的数据量 |
365 天 | 日 | 日线对于长期趋势是最优的
覆盖: 在配置中设置 INTERVAL = "daily" 或 INTERVAL = "hourly" 以覆盖自动选择。
savefig 的 facecolor:你必须在 savefig 中设置 facecolor='#131722' 和 edgecolor='#131722',否则保存的 PNG 会恢复为白色背景。\n 以增加与顶边的间距。returnfig=True:当你需要进行绘图后自定义(价格格式化、注释)时使用。使用它时,手动调用 fig.savefig()——不要将 savefig 传递给 mpf.plot()。[timestamp_ms, open, high, low, close]。使用 volume=False 或从 coin_chart 端点单独获取成交量。panel_ratios。例如,(4, 1, 2) 用于 K 线 + 成交量 + 一个指标,(5, 1, 2, 2) 用于两个指标。(14, 8)。添加子图时增加到 (14, 10) 或 (14, 12)。scripts/foo.py,而不是 workspace/scripts/foo.py。bash 的当前工作目录已经是工作空间。output/ 目录。 使用 os.makedirs("output", exist_ok=True)。bash("python3 scripts/<name>.py") 运行脚本 以验证其工作。read_file,然后使用 Markdown 图片语法显示它: requests + os.getenv()。没有内部导入,没有 dotenv。core.http_client 导入。始终直接使用 requests.get() 和 requests.post()。这是对 PLATFORM.md 代理规则的例外,因为这些脚本在主 Star Child 进程之外执行。模板展示了正确的模式。os.getenv("COINGECKO_API_KEY") 直接有效。btc_30d_candles.png, eth_7d_rsi_macd.png。模板会根据 PROXY_HOST/PROXY_PORT 环境变量自动配置代理。如果出现 401 错误:
检查环境:
bash("env | grep -E 'PROXY|REQUESTS_CA'")
预期的变量:
PROXY_HOST / PROXY_PORT - 代理地址(模板使用这些来设置 HTTP_PROXY/HTTPS_PROXY)REQUESTS_CA_BUNDLE - 用于 SSL 的代理 CA 证书COINGECKO_API_KEY / TWELVEDATA_API_KEY - 在代理环境中可以是假的如果缺少变量,这是环境配置问题,而不是脚本问题。
每周安装量
3.5K
代码仓库
GitHub 星标数
1
首次出现
13 天前
安全审计
安装于
openclaw3.5K
codex102
kimi-cli101
github-copilot101
amp101
cline101
NEVER call price_chart, get_coin_ohlc_range_by_id, twelvedata_time_series, or ANY market data tools when creating charts. Chart scripts fetch data internally. Calling these tools floods your context with 78KB+ of unnecessary data.
Workflow (4 steps):
skills/charting/scripts/scripts/bashread_file on the output PNG, then display it using markdown image syntax: You generate TradingView-quality candlestick charts. Dark theme, clean layout, professional colors. Every chart is a standalone Python script — no internal imports.
Additional Rules:
core. Use requests library directly, NOT proxied_get().PROXY_HOST env var exists, scripts automatically configure HTTP_PROXY/HTTPS_PROXY.Tools: write_file, bash, read_file
Simple price action → Candlestick with no indicators. Good for "show me BTC this month." Trend analysis → Add EMA/SMA overlays. Good for "is ETH in an uptrend?" Momentum check → Add RSI or MACD as subplots. Good for "is SOL overbought?" Full technical view → Candles + Bollinger Bands + RSI + MACD. Good for "give me the full picture on BTC." Volume analysis → Requires separate fetch from market_chart endpoint (OHLC endpoint has no volume). Asset comparison → Line chart comparing two assets (BTC vs Gold, ETH vs S&P500, etc.). Use comparison template for normalized or percentage-based comparisons.
Read and customize the template scripts in skills/charting/scripts/:
chart_template.py — Baseline candlestick chart with TradingView styling (crypto via CoinGecko)chart_with_indicators.py — RSI, MACD, Bollinger Bands, EMA/SMA examples (crypto via CoinGecko)chart_stock_template.py — Stock/forex chart using Twelve Data APIchart_comparison_template.py — Compare two assets (crypto vs commodity, stock vs crypto, etc.)Copy the relevant template to scripts/, customize the config section (coin, days, indicators), and run it.
The templates handle all data fetching internally with retry logic and error handling.
Note: These templates are for market data visualization (price charts, indicators). For backtest result charts (equity curves, drawdowns, performance dashboards), add matplotlib charting directly to your backtest script — the data is already there, no need to re-fetch or create a separate file.
| Element | Color | Hex |
|---|---|---|
| Up candles | Teal | #26a69a |
| Down candles | Red | #ef5350 |
| Background | Dark | #131722 |
| Grid | Subtle dotted | #1e222d |
| Text / axes | Light gray | #d1d4dc |
| MA lines |
Do not deviate from this palette unless the user asks.
Endpoint: https://pro-api.coingecko.com/api/v3/coins/{coin_id}/ohlc/range Auth: Header x-cg-pro-api-key: {COINGECKO_API_KEY} Use for: BTC, ETH, SOL, and all cryptocurrencies
Example:
url = f"https://pro-api.coingecko.com/api/v3/coins/{COIN_ID}/ohlc/range"
params = {"vs_currency": "usd", "from": from_ts, "to": now, "interval": "daily"}
headers = {"x-cg-pro-api-key": os.getenv("COINGECKO_API_KEY")}
resp = requests.get(url, params=params, headers=headers)
raw = resp.json() # [[timestamp_ms, open, high, low, close], ...]
Endpoint: https://api.twelvedata.com/time_series Auth: Query param apikey={TWELVEDATA_API_KEY} Use for: Stocks (AAPL, MSFT), Forex (EUR/USD), Commodities (XAU/USD for gold)
Common Symbols:
AAPL, MSFT, GOOGL, TSLA, SPYEUR/USD, GBP/JPY, USD/CHFXAU/USD (gold), XAG/USD (silver), CL/USD (crude oil)Intervals: 1min, 5min, 15min, 30min, 1h, 4h, 1day, 1week, 1month
Example:
url = "https://api.twelvedata.com/time_series"
params = {
"symbol": "XAU/USD", # Gold spot price
"interval": "1day",
"outputsize": 90, # Number of candles
"apikey": os.getenv("TWELVEDATA_API_KEY")
}
resp = requests.get(url, params=params)
data = resp.json()
# data["values"] = [{"datetime": "2024-01-01", "open": "2050.00", "high": "2060.00", ...}, ...]
IMPORTANT: Twelve Data returns data in reverse chronological order (newest first). Always reverse the list before creating a DataFrame:
values = data["values"][::-1] # Reverse to oldest-first
The templates now auto-select optimal intervals to minimize data volume while maintaining visual quality:
| Time Range | Auto-Selected Interval | Rationale |
|---|---|---|
| ≤31 days | Hourly | High granularity for short-term analysis |
| 32-365 days | Daily | Sufficient detail, lower data volume |
365 days | Daily | Daily is optimal for long-term trends
Override: Set INTERVAL = "daily" or INTERVAL = "hourly" in the config to override auto-selection.
savefig facecolor: You MUST set facecolor='#131722' and edgecolor='#131722' in savefig, or the saved PNG reverts to white background.\n to add spacing from the top edge.returnfig=True : Use when you need post-plot customization (price formatting, annotations). When using it, call fig.savefig() manually — don't pass savefig to mpf.plot().scripts/foo.py, not workspace/scripts/foo.py. The bash CWD is already workspace.output/ directory. Use os.makedirs("output", exist_ok=True).bash("python3 scripts/<name>.py") to verify it works.read_file on the generated PNG, then use markdown image syntax to display it: requests + os.getenv(). No internal imports, no dotenv.Templates auto-configure proxy from PROXY_HOST/PROXY_PORT env vars. If 401 errors occur:
Check environment:
bash("env | grep -E 'PROXY|REQUESTS_CA'")
Expected vars:
PROXY_HOST / PROXY_PORT - Proxy address (templates use these to set HTTP_PROXY/HTTPS_PROXY)REQUESTS_CA_BUNDLE - Proxy CA cert for SSLCOINGECKO_API_KEY / TWELVEDATA_API_KEY - Can be fake in proxied environmentsIf vars are missing, this is an environment configuration issue, not a script issue.
Weekly Installs
3.5K
Repository
GitHub Stars
1
First Seen
13 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
openclaw3.5K
codex102
kimi-cli101
github-copilot101
amp101
cline101
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
| Blue / Orange |
#2196f3 / #ff9800 |
| RSI line | Purple | #b39ddb |
| MACD line | Blue | #2196f3 |
| Signal line | Orange | #ff9800 |
[timestamp_ms, open, high, low, close]volume=Falsecoin_chartpanel_ratios when adding indicator subplots. E.g., (4, 1, 2) for candles + volume + one indicator, (5, 1, 2, 2) for two indicators.(14, 8). Increase to (14, 10) or (14, 12) when adding subplots.core.http_client. Always use requests.get() and requests.post() directly. This is an exception to the PLATFORM.md proxy rules because these scripts execute outside the main Star Child process. The templates demonstrate the correct pattern.os.getenv("COINGECKO_API_KEY") works directly.btc_30d_candles.png, eth_7d_rsi_macd.png.