图表生成
图表生成 API
生成专业的 K 线图图片,支持多种技术指标叠加。
端点
| 方法 | 端点 |
|---|---|
| POST | /v1/market/chart/storage |
请求参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
symbol | string | ✅ | - | 股票代码 (如 SZSE:000001, 000001.SZ) |
interval | string | - | 1d | 时间周期: 1m, 5m, 15m, 1h, 4h, 1d, 1w |
studies | array | - | [] | 技术指标列表 |
width | int | - | 800 | 图片宽度 (px) |
height | int | - | 600 | 图片高度 (px) |
format | string | - | png | 格式: png / jpeg |
theme | string | - | light | 主题: light / dark |
from_date | string | - | - | 开始日期 (YYYY-MM-DD) |
to_date | string | - | - | 结束日期 (YYYY-MM-DD) |
在线试用
POST
/v1/market/chart/storage支持的技术指标 (studies)
[
{"name": "Bollinger Bands"},
{"name": "Relative Strength Index"},
{"name": "Volume"},
{"name": "MACD"}
]
代码示例
Python
import requests
API_KEY = "your_api_key"
response = requests.post(
"https://tickerlab.org/v1/market/chart/storage",
headers={"X-API-Key": API_KEY},
json={
"symbol": "SZSE:000001",
"interval": "1d",
"width": 1200,
"height": 800,
"theme": "dark",
"studies": [
{"name": "Bollinger Bands"},
{"name": "Volume"}
]
}
)
result = response.json()
print(f"图片 URL: {result['url']}")
print(f"过期时间: {result['expireAt']}")
# 下载图片
import urllib.request
urllib.request.urlretrieve(result['url'], 'chart.png')
JavaScript
const response = await fetch(
'https://tickerlab.org/v1/market/chart/storage',
{
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
symbol: 'SZSE:000001',
interval: '1d',
width: 1200,
height: 800,
theme: 'dark',
studies: [{ name: 'Bollinger Bands' }]
})
}
);
const result = await response.json();
console.log('图片 URL:', result.url);
cURL
curl -X POST "https://tickerlab.org/v1/market/chart/storage" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"symbol": "SZSE:000001",
"interval": "1d",
"width": 1200,
"height": 800,
"theme": "dark",
"studies": [{"name": "Bollinger Bands"}]
}'
响应示例
{
"url": "https://tickerlab.org/static/charts/abc123.png",
"size": 45678,
"etag": "abc123def456",
"createdAt": "2024-01-15T10:30:00Z",
"expireAt": "2024-01-15T11:30:00Z"
}
注意事项
- 生成的图片会在 1 小时后过期
- 图片尺寸建议不超过 2000x2000
- 支持的股票代码格式:
000001.SZ,SZSE:000001,600000.SH,SSE:600000