返回顶部
C

Crypto Price Alerts加密货币价格提醒

Monitor cryptocurrency prices and trigger alerts when thresholds are hit. Supports BTC, ETH, SOL, and 100+ other coins via CoinGecko API. Configure price ceilings, floors, or percentage moves. Alerts delivered to console, files, or Telegram.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
128
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

Crypto Price Alerts

加密货币价格提醒

监控加密货币价格,并在达到目标时获取提醒。无需API密钥——使用CoinGecko的免费API。

功能说明

  • - 检查BTC、ETH、SOL及100多种币种的当前价格
  • 与您设定的阈值进行比较
  • 价格突破目标上下限时发出提醒
  • 支持百分比变动(例如:如果BTC在1小时内下跌5%则提醒)
  • 可单次运行或按计划运行(cron)

快速开始

查询单个价格

bash

直接调用API(无需认证)


curl https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vscurrencies=usd&include24hr_change=true

查询更详细信息

bash
curl https://api.coingecko.com/api/v3/coins/bitcoin?localization=false&tickers=false&communitydata=false&developerdata=false&sparkline=false

提醒配置

创建crypto-alerts.json文件:

json
{
alerts: [
{
coin: bitcoin,
symbol: btc,
condition: below,
price: 85000,
message: BTC跌破$85K!
},
{
coin: bitcoin,
symbol: btc,
condition: above,
price: 100000,
message: BTC突破$100K!🚀
},
{
coin: ethereum,
symbol: eth,
condition: below,
price: 3000,
message: ETH低于$3K
},
{
coin: solana,
symbol: sol,
condition: above,
price: 200,
message: SOL突破$200!
}
],
telegrambottoken: YOURBOTTOKEN,
telegramchatid: YOURCHATID
}

Python提醒脚本

保存为crypto_alert.py:

python
#!/usr/bin/env python3
import requests
import json
import sys
import os
from datetime import datetime

COINGECKO_API = https://api.coingecko.com/api/v3

def getprice(coinid):
url = f{COINGECKO_API}/simple/price
params = {
ids: coin_id,
vs_currencies: usd,
include24hrchange: true,
includelastupdated_at: true
}
r = requests.get(url, params=params, timeout=10)
r.raiseforstatus()
data = r.json()
return data[coinid][usd], data[coinid].get(usd24hchange, 0)

def checkalerts(alertsconfig):
triggered = []
for alert in alerts_config.get(alerts, []):
coin = alert[coin]
condition = alert[condition]
target = alert[price]
message = alert[message]

try:
price, change24h = getprice(coin)
except Exception as e:
print(f获取{coin}数据出错:{e})
continue

should_fire = False
if condition == above and price >= target:
should_fire = True
elif condition == below and price <= target:
should_fire = True

if should_fire:
triggered.append({
coin: coin,
price: price,
target: target,
condition: condition,
message: message,
change24h: change24h,
time: datetime.now().isoformat()
})
print(f🚨 提醒:{message}(当前价:${price:,.2f}))
else:
print(f {coin.upper()}:${price:,.2f}(24小时:{change24h:+.2f}%)— {condition} ${target:,.2f}:{✓ if shouldfire else 未触发})

return triggered

def sendtelegram(message, bottoken, chat_id):
if not bottoken or not chatid:
return
url = fhttps://api.telegram.org/bot{bot_token}/sendMessage
payload = {chatid: chatid, text: message, parse_mode: HTML}
requests.post(url, json=payload, timeout=10)

if name == main:
config_path = os.path.join(os.path.dirname(file), crypto-alerts.json)

if len(sys.argv) > 1:
config_path = sys.argv[1]

if os.path.exists(config_path):
with open(config_path) as f:
config = json.load(f)
else:
print(未找到crypto-alerts.json。使用默认BTC/ETH/SOL检查。)
config = {
alerts: [
{coin: bitcoin, symbol: btc, condition: above, price: 0},
{coin: ethereum, symbol: eth, condition: above, price: 0},
{coin: solana, symbol: sol, condition: above, price: 0}
]
}

triggered = check_alerts(config)

if triggered:
summary = 🚨 加密货币提醒已触发\n\n
for t in triggered:
summary += f{t[message]}\n
summary += f价格:${t[price]:,.2f} | 24小时:{t[change_24h]:+.2f}%\n\n

bottoken = config.get(telegrambot_token)
chatid = config.get(telegramchat_id)
if bottoken and chatid:
sendtelegram(summary, bottoken, chat_id)

with open(/tmp/cryptoalertstriggered.json, a) as f:
f.write(json.dumps({triggered: triggered, time: datetime.now().isoformat()}) + \n)

使用示例

单次运行

bash python3 crypto_alert.py

按计划运行(Cron)

bash

每15分钟

/15 * cd /path/to/skill && python3 cryptoalert.py >> /tmp/cryptoalerts.log 2>&1

每小时整点

0 cd /path/to/skill && python3 cryptoalert.py >> /tmp/cryptoalerts.log 2>&1

查询特定币种

bash

比特币

curl https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vscurrencies=usd&include24hr_change=true

多个币种

curl https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana,cardano,polkadot,avalanche-2,chainlink&vscurrencies=usd&include24hr_change=true

支持的币种(常用ID)

符号CoinGecko ID
BTCbitcoin
ETH
ethereum | | SOL | solana | | ADA | cardano | | DOT | polkadot | | AVAX | avalanche-2 | | LINK | chainlink | | XRP | ripple | | DOGE | dogecoin | | MATIC | polygon | | ARB | arbitrum | | OP | optimism |

完整列表:curl https://api.coingecko.com/api/v3/coins/list?per_page=250

提醒条件

  • - above — 价格 >= 目标时触发
  • below — 价格 <= 目标时触发
  • percentup — 24小时涨幅 > X%时触发(需添加percentthreshold字段)
  • percentdown — 24小时跌幅 < -X%时触发(需添加percentthreshold字段)

速率限制

CoinGecko免费API:

  • - 约10-30次/分钟
  • 10,000-50,000次/月
  • 频繁检查时建议使用缓存
  • 调用间添加sleep(1.2)以确保安全

依赖要求

  • - requests Python库(pip install requests)
  • CoinGecko API(免费,无需密钥)
  • 可选:用于推送通知的Telegram机器人
  • 可选:用于定时监控的cron

使用技巧

  1. 1. 避免频繁检查 — 15分钟间隔适用于大多数场景
  2. 缓存价格 — 存储上次检查结果,避免重复API调用
  3. 多重条件 — 同一币种可设置多个提醒(同时设置上限

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 crypto-price-monitor-1775974561 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 crypto-price-monitor-1775974561 技能

通过命令行安装

skillhub install crypto-price-monitor-1775974561

下载

⬇ 下载 Crypto Price Alerts v1.0.0(免费)

文件大小: 4.88 KB | 发布时间: 2026-4-13 09:56

v1.0.0 最新 2026-4-13 09:56
Initial release - Monitor crypto prices via CoinGecko API, trigger alerts with Telegram support

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部