网淘吧来吧,欢迎您!

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

支持的交易所:

Crypto Market

  • 币安- 币安 (默认)
  • 欧易- 欧易
  • Bybit- Bybit
  • Gate.io- Gate.io
  • KuCoin- KuCoin
  • 火币- 火币
  • Coinbase- Coinbase
  • Kraken- Kraken
  • Bitfinex- 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
ohlcvK线数据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-tK线时间周期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/USDTETH/USDT

警报未触发→ 确认警报条件设置正确。运行alert-check命令以手动检查。

API 限制→ 某些交易所有严格的速率限制。使用--interval参数来调整刷新频率。

配置文件

警报配置存储在:~/.config/crypto/alerts.json

您可以手动编辑此文件以批量管理您的警报。

参考文档

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第362536名访客 今日有33篇新文章/评论