Type/to search

币安websocket订阅永续合约行情信息

Cryptocurrency
Created: 2021-11-02 22:36:28
Last modified: 5 years ago
8
Follow
21
Followers
Source
Python
import json
def main():
    LogStatus("正在连接...")
    # client = Dial("wss://stream.binance.com:9443/stream?streams=btcusdt@aggTrade/ethusdt@aggTrade|reconnect=true")    #多个交易对
    # client = Dial("wss://stream.binance.com:9443/ws/btcusdt@aggTrade|reconnect=true")    #单个交易对
    # client = Dial("wss://dstream.binance.com/ws/btcusd_perp@aggTrade|reconnect=true")    #币本位,ticker
    client = Dial("wss://fstream.binance.com/ws/btcusdt@aggTrade|reconnect=true")
    if not client:    
        Log("连接失败, 程序退出")
        return
    while True:
        buf = client.read(-2)
        Log('tt',buf)
        if buf:
            obj = json.loads(buf)
            # Log(obj)
            # Log('交易对',obj['data']['s'], ' 价格', obj['data']['p'])    #多个交易对 
            Log(obj['p'])    #测试
        Sleep(5000)
    client.close()
Comment
All comments (2)

    老哥,代写?怎么联系

    5 years ago

    本人水平有限,暂不接代写,抱歉

    5 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)