Crypto Market
2026-03-31
新闻来源:网淘吧
围观:20
电脑广告
手机广告
加密货币市场与价格提醒工具
一个基于CCXT库的加密货币市场数据获取与价格监控工具。它支持多交易所接入、实时监控及智能提醒功能。
功能特性
- 🏢多交易所支持- 默认支持币安,同时兼容OKX、Bybit、Gate.io、KuCoin等主流交易所。
- 📊实时市场数据- 获取最新价格、价格波动、交易量等实时行情数据。
- 📈K线数据(OHLCV)- 获取历史价格趋势的K线数据。
- 📖订单簿数据- 查看市场深度数据(买卖盘口)。
- 🔔价格提醒- 支持价格阈值与百分比变动提醒功能。
- 👁️实时监控- 持续监控市场价格波动。
先决条件
安装依赖项
pip3 install ccxt --user
使用方法
查看实时价格
# Default (Binance)
python3 scripts/crypto.py ticker BTC/USDT
# Use other exchanges
python3 scripts/crypto.py -e okx ticker ETH/USDT
python3 scripts/crypto.py -e bybit ticker BTC/USDT
支持的交易所:

币安- 币安 (默认)欧易- 欧易Bybit- BybitGate.io- Gate.ioKuCoin- KuCoin火币- 火币Coinbase- CoinbaseKraken- KrakenBitfinex- Bitfinex
获取OHLCV (K线图) 数据
# Get 1-hour candles, last 24 periods
python3 scripts/crypto.py ohlcv BTC/USDT --timeframe 1h --limit 24
# Get daily candles, last 30 periods
python3 scripts/crypto.py ohlcv ETH/USDT --timeframe 1d --limit 30
时间周期:
1m- 1分钟5m- 5分钟15m- 15分钟1h- 1小时4h- 4小时1d- 1天1w- 1周1M- 1个月
查看订单簿
python3 scripts/crypto.py orderbook BTC/USDT --limit 10
实时价格监控
# Refresh every 10 seconds (default)
python3 scripts/crypto.py watch BTC/USDT
# Refresh every 5 seconds
python3 scripts/crypto.py watch ETH/USDT --interval 5
价格提醒
添加提醒
价格阈值提醒:
# Alert when BTC price breaks above 70000 USDT
python3 scripts/crypto.py alert-add BTC/USDT above 70000
# Alert when ETH price drops below 3000 USDT
python3 scripts/crypto.py alert-add ETH/USDT below 3000
百分比变化提醒:
# Alert when BTC rises more than 5%
python3 scripts/crypto.py alert-add BTC/USDT up_percent 5
# Alert when ETH drops more than 3%
python3 scripts/crypto.py alert-add ETH/USDT down_percent 3
查看提醒列表
python3 scripts/crypto.py alert-list
示例输出:
🔔 Price Alerts (3):
ID Pair Exchange Condition Status
------------------------------------------------------------------------------------------
BTC/USDT_1706941200 BTC/USDT binance Price > 70000 ⏳Monitoring
ETH/USDT_1706941300 ETH/USDT okx Price < 3000 ⏳Monitoring
BTC/USDT_1706941400 BTC/USDT binance Rise > 5% ⏳Monitoring
检查提醒
# Manually check all alert conditions
python3 scripts/crypto.py alert-check
当条件触发时,显示:
⚠️ Triggered 1 alert:
🚀 BTC/USDT rose by 5.23%, current price: 71234.56
Alert ID: BTC/USDT_1706941400
移除警报
python3 scripts/crypto.py alert-remove BTC/USDT_1706941200
命令参考
| 命令 | 功能 | 示例 |
|---|---|---|
ticker | 实时价格 | ticker BTC/USDT |
ohlcv | K线数据 | ohlcv BTC/USDT --timeframe 1h |
orderbook | 订单簿 | orderbook BTC/USDT |
watch | 实时监控 | watch BTC/USDT --interval 5 |
alert-add | 添加警报 | alert-add BTC/USDT above 70000 |
alert-remove | 移除警报 | alert-remove ID |
alert-list | 列出警报 | alert-list |
警报检查 | 检查警报 | 警报检查 |
全局参数
| 参数 | 简写 | 描述 | 默认值 |
|---|---|---|---|
--exchange | -e | 交易所名称 | 币安 |
--timeframe | -t | K线时间周期 | 1小时 |
--limit | -l | 数据限制(数量) | 24 |
--interval | -i | 刷新间隔(秒) | 10 |
警报条件
| 条件 | 描述 | 示例 |
|---|---|---|
以上 | 价格超过阈值 | 超过70000 |
以下 | 价格跌破阈值 | 低于3000 |
上涨百分比 | 价格上涨百分比 | 上涨百分比 5 |
下跌百分比 | 价格下跌百分比 | 下跌百分比 3 |
使用场景
场景一:追踪特定价格目标
# Alert when BTC breaks previous high
python3 scripts/crypto.py alert-add BTC/USDT above 69000
# Regularly check
python3 scripts/crypto.py alert-check
场景二:监控支撑/阻力位
# ETH drops below key support
python3 scripts/crypto.py alert-add ETH/USDT below 2800
# BTC breaks resistance
python3 scripts/crypto.py alert-add BTC/USDT above 72000
场景三:波动性监控
# Monitor massive volatility
python3 scripts/crypto.py alert-add BTC/USDT up_percent 8
python3 scripts/crypto.py alert-add BTC/USDT down_percent 8
场景四:跨交易所价格对比
# Check prices across different exchanges
python3 scripts/crypto.py -e binance ticker BTC/USDT
python3 scripts/crypto.py -e okx ticker BTC/USDT
python3 scripts/crypto.py -e bybit ticker BTC/USDT
故障排除
错误:未安装ccxt库→ 运行:pip3 install ccxt --user
错误:不支持的交易所→ 检查交易所拼写。请参考支持的交易所列表。
错误:交易对不存在→ 检查交易对格式,例如:BTC/USDT、ETH/USDT。
警报未触发→ 确认警报条件设置正确。运行alert-check命令以手动检查。
API 限制→ 某些交易所有严格的速率限制。使用--interval参数来调整刷新频率。
配置文件
警报配置存储在:~/.config/crypto/alerts.json
您可以手动编辑此文件以批量管理您的警报。
参考文档
- CCXT 文档:https://docs.ccxt.com/
- 支持的交易所列表:references/exchanges.md
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~