Type/to search
0
Follow
1
Followers
긴급 도움말 웹소켓
Help
Created 2023-03-02 15:04:22  
 2
 1304

chatgpt에서 생성된 코드가 k-라인 데이터를 가져옵니다.
import websocket

url = "wss://fstream.binance.com/ws"

def on_open(ws):

1분 K라인 데이터, BTCUSD 상시 계약에 가입하여 가입 메시지를 전송합니다.

sub_msg = {
"method": "SUBSCRIBE",
"params": [
"btcusd_perpetual@kline_1m"
],
"id": 1
}
ws.send(json.dumps(sub_msg))

def on_message(ws, message):

수신된 K선 데이터를 처리합니다.

print(message)

if name == "main":
ws = websocket.WebSocketApp(url, on_open=on_open, on_message=on_message)
ws.run_forever()
실행 오류 Traceback (most recent call last): File "<string>", line 1246, in init_ctx File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'websocket'
chtgpt는 이 오류가 websocket이라는 모듈이 Python 환경에서 누락되어 있기 때문이라고 말합니다. 당신은 pip 또는 conda와 같은 도구를 사용하여 모듈을 설치해야 합니다. 당신은 다음과 같은 명령어를 터미널에서 또는 명령줄에서 실행하여 모듈을 설치할 수 있습니다.

"이것이 바로 질문의 이유인가?

Related Recommendations
Comment
All comments (2)

    谢谢

    3 years ago

    您好,pip安装包可以参考:https://blog.csdn.net/u012693479/article/details/126367014

    在FMZ上创建websocket链接,可以使用:https://www.fmz.com/api#dial...

    3 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)