tracking-crypto-prices
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTracking Crypto Prices
加密货币价格追踪
Overview
概述
Foundation skill providing real-time and historical cryptocurrency price data. This skill is the data layer for the crypto plugin ecosystem - 10+ other skills depend on it for price information.
Key Capabilities:
- Real-time prices for 10,000+ cryptocurrencies
- Historical OHLCV data (1 day to all-time)
- Multi-currency support (USD, EUR, GBP, 30+ currencies)
- Intelligent caching to minimize API calls
- Predefined and custom watchlists
- Export to CSV/JSON for analysis
Dependent Skills:
This skill provides price data to: market-movers-scanner, crypto-portfolio-tracker, crypto-tax-calculator, defi-yield-optimizer, liquidity-pool-analyzer, staking-rewards-optimizer, crypto-derivatives-tracker, dex-aggregator-router, options-flow-analyzer, arbitrage-opportunity-finder.
作为基础技能,提供实时与历史加密货币价格数据。该技能是加密货币插件生态的数据层——有10余个其他技能依赖其获取价格信息。
核心功能:
- 支持10000+种加密货币的实时价格查询
- 历史OHLCV数据(1天至全时段)
- 多法币支持(USD、EUR、GBP等30余种货币)
- 智能缓存,减少API调用次数
- 预定义与自定义关注列表
- 导出为CSV/JSON格式用于分析
依赖该技能的其他技能:
本技能为以下技能提供价格数据:market-movers-scanner、crypto-portfolio-tracker、crypto-tax-calculator、defi-yield-optimizer、liquidity-pool-analyzer、staking-rewards-optimizer、crypto-derivatives-tracker、dex-aggregator-router、options-flow-analyzer、arbitrage-opportunity-finder。
Prerequisites
前置条件
Install required dependencies:
bash
pip install requests pandas yfinanceOptional for advanced features:
bash
pip install python-dotenv # For API key managementAPI Setup (optional, for higher rate limits):
- Get free API key from https://www.coingecko.com/en/api
- Add to or set environment variable
{baseDir}/config/settings.yamlCOINGECKO_API_KEY
安装所需依赖:
bash
pip install requests pandas yfinance高级功能可选依赖:
bash
pip install python-dotenv # 用于API密钥管理API设置(可选,用于更高调用限额):
- 从https://www.coingecko.com/en/api获取免费API密钥
- 添加至或设置环境变量
{baseDir}/config/settings.yamlCOINGECKO_API_KEY
Instructions
使用说明
Step 1: Quick Price Check
步骤1:快速价格查询
Get current price for any cryptocurrency:
bash
python {baseDir}/scripts/price_tracker.py --symbol BTCCheck multiple assets:
bash
python {baseDir}/scripts/price_tracker.py --symbols BTC,ETH,SOL获取任意加密货币的当前价格:
bash
python {baseDir}/scripts/price_tracker.py --symbol BTC查询多个资产:
bash
python {baseDir}/scripts/price_tracker.py --symbols BTC,ETH,SOLStep 2: Use Watchlists
步骤2:使用关注列表
Scan predefined watchlists:
bash
undefined扫描预定义关注列表:
bash
undefinedTop 10 by market cap
市值前10币种
python {baseDir}/scripts/price_tracker.py --watchlist top10
python {baseDir}/scripts/price_tracker.py --watchlist top10
DeFi tokens
DeFi代币
python {baseDir}/scripts/price_tracker.py --watchlist defi
python {baseDir}/scripts/price_tracker.py --watchlist defi
Layer 2 tokens
Layer2代币
python {baseDir}/scripts/price_tracker.py --watchlist layer2
Available watchlists: `top10`, `defi`, `layer2`, `stablecoins`, `memecoins`python {baseDir}/scripts/price_tracker.py --watchlist layer2
可用关注列表:`top10`、`defi`、`layer2`、`stablecoins`、`memecoins`Step 3: Fetch Historical Data
步骤3:获取历史数据
Get OHLCV (Open, High, Low, Close, Volume) history:
bash
undefined获取OHLCV(开盘、最高、最低、收盘、成交量)历史数据:
bash
undefinedLast 30 days
最近30天数据
python {baseDir}/scripts/price_tracker.py --symbol BTC --period 30d
python {baseDir}/scripts/price_tracker.py --symbol BTC --period 30d
Last 90 days with CSV export
最近90天数据并导出为CSV
python {baseDir}/scripts/price_tracker.py --symbol BTC --period 90d --output csv
python {baseDir}/scripts/price_tracker.py --symbol BTC --period 90d --output csv
Custom date range
自定义日期范围
python {baseDir}/scripts/price_tracker.py --symbol ETH --start 2024-01-01 --end 2024-12-31
undefinedpython {baseDir}/scripts/price_tracker.py --symbol ETH --start 2024-01-01 --end 2024-12-31
undefinedStep 4: Configure Settings
步骤4:配置设置
Edit to customize:
{baseDir}/config/settings.yamlyaml
cache:
spot_ttl: 30 # Seconds to cache spot prices
historical_ttl: 3600 # Seconds to cache historical data
currency:
default: usd # Default fiat currency
watchlists:
custom: # Add your own watchlist
- BTC
- ETH
- SOL编辑进行自定义配置:
{baseDir}/config/settings.yamlyaml
cache:
spot_ttl: 30 # 现货价格缓存有效期(秒)
historical_ttl: 3600 # 历史数据缓存有效期(秒)
currency:
default: usd # 默认法币
watchlists:
custom: # 添加自定义关注列表
- BTC
- ETH
- SOLOutput
输出格式
Price Table (Default)
价格表格(默认)
================================================================================
CRYPTO PRICES Updated: [timestamp]
================================================================================
Symbol Price (USD) 24h Change Volume (24h) Market Cap
--------------------------------------------------------------------------------
BTC $97,234.56 +2.34% $28.5B $1.92T
ETH $3,456.78 +1.87% $12.3B $415.2B
SOL $142.34 +5.12% $2.1B $61.4B
--------------------------------------------------------------------------------
Total 24h Change: +2.44% (weighted)
================================================================================================================================================================
CRYPTO PRICES Updated: [timestamp]
================================================================================
Symbol Price (USD) 24h Change Volume (24h) Market Cap
--------------------------------------------------------------------------------
BTC $97,234.56 +2.34% $28.5B $1.92T
ETH $3,456.78 +1.87% $12.3B $415.2B
SOL $142.34 +5.12% $2.1B $61.4B
--------------------------------------------------------------------------------
Total 24h Change: +2.44% (weighted)
================================================================================JSON Output (--format json)
JSON输出(--format json)
json
{
"prices": [
{
"symbol": "BTC",
"name": "Bitcoin",
"price": 97234.56,
"currency": "USD",
"change_24h": 2.34,
"volume_24h": 28500000000,
"market_cap": 1920000000000,
"timestamp": "[timestamp]",
"source": "coingecko"
}
],
"meta": {
"count": 1,
"currency": "USD",
"cached": false
}
}json
{
"prices": [
{
"symbol": "BTC",
"name": "Bitcoin",
"price": 97234.56,
"currency": "USD",
"change_24h": 2.34,
"volume_24h": 28500000000,
"market_cap": 1920000000000,
"timestamp": "[timestamp]",
"source": "coingecko"
}
],
"meta": {
"count": 1,
"currency": "USD",
"cached": false
}
}Historical CSV Export
历史数据CSV导出
csv
date,open,high,low,close,volume
[date],95000.00,96500.00,94200.00,96100.00,25000000000
[date],96100.00,97800.00,95800.00,97500.00,27000000000csv
date,open,high,low,close,volume
[date],95000.00,96500.00,94200.00,96100.00,25000000000
[date],96100.00,97800.00,95800.00,97500.00,27000000000Configuration
配置详情
Edit :
{baseDir}/config/settings.yamlyaml
undefined编辑:
{baseDir}/config/settings.yamlyaml
undefinedAPI Configuration
API配置
api:
coingecko:
api_key: ${COINGECKO_API_KEY} # Optional, from env
use_pro: false
yfinance:
enabled: true # Fallback source
api:
coingecko:
api_key: ${COINGECKO_API_KEY} # 可选,从环境变量读取
use_pro: false
yfinance:
enabled: true # 备选数据源
Cache Configuration
缓存配置
cache:
enabled: true
spot_ttl: 30 # Spot price TTL (seconds)
historical_ttl: 3600 # Historical data TTL (seconds)
directory: ./data
cache:
enabled: true
spot_ttl: 30 # 现货价格缓存有效期(秒)
historical_ttl: 3600 # 历史数据缓存有效期(秒)
directory: ./data
Display Configuration
显示配置
currency:
default: usd
supported:
- usd
- eur
- gbp
- jpy
- cad
- aud
currency:
default: usd
supported:
- usd
- eur
- gbp
- jpy
- cad
- aud
Predefined Watchlists
预定义关注列表
watchlists:
top10:
- bitcoin
- ethereum
- tether
- binancecoin
- solana
- ripple
- cardano
- avalanche-2
- dogecoin
- polkadot
defi:
- uniswap
- aave
- chainlink
- maker
- compound-governance-token
- curve-dao-token
- sushi
layer2:
- matic-network
- arbitrum
- optimism
- immutable-x
undefinedwatchlists:
top10:
- bitcoin
- ethereum
- tether
- binancecoin
- solana
- ripple
- cardano
- avalanche-2
- dogecoin
- polkadot
defi:
- uniswap
- aave
- chainlink
- maker
- compound-governance-token
- curve-dao-token
- sushi
layer2:
- matic-network
- arbitrum
- optimism
- immutable-x
undefinedError Handling
错误处理
See for comprehensive error handling.
{baseDir}/references/errors.md完整错误处理说明请查看。
{baseDir}/references/errors.mdCommon Errors
常见错误
| Error | Cause | Solution |
|---|---|---|
| Invalid cryptocurrency ticker | Check spelling, use |
| Too many API calls | Wait 60s, or use API key for higher limits |
| No internet connection | Check connection, cached data will be used |
| Cached data older than TTL | Data still shown with warning, will refresh |
| 错误信息 | 原因 | 解决方案 |
|---|---|---|
| 加密货币代码无效 | 检查拼写,使用 |
| API调用次数超限 | 等待60秒,或使用API密钥提升限额 |
| 无网络连接 | 检查网络,将使用缓存数据 |
| 缓存数据超出有效期 | 仍会显示数据并附带提醒,将自动刷新 |
Rate Limit Handling
调用限额处理
The skill automatically:
- Uses cached data when available
- Applies exponential backoff on rate limits
- Falls back to yfinance if CoinGecko fails
- Shows stale cache data with warning as last resort
该技能会自动执行以下操作:
- 优先使用可用缓存数据
- 触发限额时应用指数退避策略
- 若CoinGecko失败,自动切换至yfinance作为备选
- 最后会显示过期缓存数据并附带提醒
Examples
使用示例
See for detailed examples including:
{baseDir}/references/examples.md- Multi-timeframe analysis
- Portfolio value calculation
- Price alert setup
- Integration with other skills
详细示例请查看,包括:
{baseDir}/references/examples.md- 多时间框架分析
- 投资组合价值计算
- 价格提醒设置
- 与其他技能集成
Example 1: Quick Price Check
示例1:快速价格查询
bash
python {baseDir}/scripts/price_tracker.py --symbol BTCOutput:
BTC (Bitcoin)
$97,234.56 USD
+2.34% (24h) | Vol: $28.5B | MCap: $1.92Tbash
python {baseDir}/scripts/price_tracker.py --symbol BTC输出:
BTC (Bitcoin)
$97,234.56 USD
+2.34% (24h) | Vol: $28.5B | MCap: $1.92TExample 2: Watchlist Scan
示例2:关注列表扫描
bash
python {baseDir}/scripts/price_tracker.py --watchlist top10bash
python {baseDir}/scripts/price_tracker.py --watchlist top10Example 3: Historical Export
示例3:历史数据导出
bash
python {baseDir}/scripts/price_tracker.py --symbol ETH --period 90d --output csvCreates:
{baseDir}/data/ETH_90d_[date].csvbash
python {baseDir}/scripts/price_tracker.py --symbol ETH --period 90d --output csv生成文件:
{baseDir}/data/ETH_90d_[date].csvIntegration with Other Skills
与其他技能集成
This skill provides the price data foundation for other crypto skills.
Direct Import (recommended for Python skills):
python
from price_tracker import get_current_prices, get_historical_prices该技能为其他加密货币相关技能提供价格数据基础。
直接导入(推荐Python技能使用):
python
from price_tracker import get_current_prices, get_historical_pricesGet prices for portfolio valuation
获取投资组合估值所需价格
prices = get_current_prices(["BTC", "ETH", "SOL"])
**CLI Subprocess** (for non-Python or isolation):
```bash
PRICES=$(python {baseDir}/scripts/price_tracker.py --symbols BTC,ETH --format json)Shared Cache (efficient for batch):
Multiple skills can read from to avoid redundant API calls.
{baseDir}/data/cache.jsonprices = get_current_prices(["BTC", "ETH", "SOL"])
**CLI子进程调用**(适用于非Python技能或隔离场景):
```bash
PRICES=$(python {baseDir}/scripts/price_tracker.py --symbols BTC,ETH --format json)共享缓存(批量场景高效使用):
多个技能可读取避免重复API调用。
{baseDir}/data/cache.jsonFiles
文件结构
| File | Purpose |
|---|---|
| Main CLI entry point |
| CoinGecko/yfinance abstraction |
| Cache read/write/invalidation |
| Output formatting |
| User configuration |
| Price cache (auto-generated) |
| 文件 | 用途 |
|---|---|
| 主CLI入口 |
| CoinGecko/yfinance抽象层 |
| 缓存读写与失效管理 |
| 输出格式处理 |
| 用户配置文件 |
| 价格缓存文件(自动生成) |
Resources
参考资源
- CoinGecko API - Primary data source
- yfinance - Fallback for historical data
- PRD.md - Product requirements
- ARD.md - Architecture documentation
- CoinGecko API - 主要数据源
- yfinance - 历史数据备选源
- PRD.md - 产品需求文档
- ARD.md - 架构设计文档