分享个简单的 Python 监控$v2ex 价格

30 天前
 vip5000521

引用 lzxz1234 这个老哥的发的接口: https://api.phantom.app/price/v1/solana:101/address/9raUVuzeWUk53co63M4WXLWPWE4Xc6Lpn7RS9dnkpump

import requests
import time
import json

url = "https://api.phantom.app/price/v1/solana:101/address/9raUVuzeWUk53co63M4WXLWPWE4Xc6Lpn7RS9dnkpump"

while True:
    try:
        response = requests.get(url)
        response.raise_for_status()
        data = response.json()
        if data["price"] <= 0.013: #监控价格
            print('请注意:',data["price"]) #这里可以自己加个通知代码.
            continue
        print(json.dumps(data, indent=2, ensure_ascii=False))
    except requests.RequestException as e:
        print(f"请求出错: {e}")
    except ValueError:
        print("返回内容不是合法的 JSON 格式")

    time.sleep(30)  # 间隔秒

保存成如 test.py 然后执行 python test.py 以下就好了.

815 次点击
所在节点    Solana
3 条回复
stinkytofux
30 天前
再改进一下, 做一个简易的挂单, 触发之后调用 PumpSwap 兑换, 用其他平台的挂单手续费有点高.
JoeJoeJoe
30 天前
浏览器用这个接口会触发跨域, 所以最好是用 cf 的 worker 做一层转发.

之前有在这个帖子中介绍过: /t/1150712

github 地址: https://github.com/HelloWorldImJoe/SolanaProgramTrading

ps: github 中有一个 local 分支, 实现了自动买入卖出功能, 但是比较粗糙, 谨慎使用. @stinkytofux
vip5000521
29 天前
这位老哥又完善一版 @KelleyV9 https://www.v2ex.com/t/1152106

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1152052

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX