0
집중하다
1
수행원

긴급 도움말 웹소켓

만든 날짜: 2023-03-02 15:04:22, 업데이트 날짜:
comments   2
hits   997

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 “”, line 1246, in init_ctx File “”, line 1, in ModuleNotFoundError: No module named ‘websocket’
chtgpt는 이 오류가 websocket이라는 모듈이 Python 환경에서 누락되어 있기 때문이라고 말합니다. 당신은 pip 또는 conda와 같은 도구를 사용하여 모듈을 설치해야 합니다. 당신은 다음과 같은 명령어를 터미널에서 또는 명령줄에서 실행하여 모듈을 설치할 수 있습니다.

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