Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitkub Websocket wallet info access #87

Open
NeoSephiroth opened this issue Aug 20, 2022 · 1 comment
Open

Bitkub Websocket wallet info access #87

NeoSephiroth opened this issue Aug 20, 2022 · 1 comment

Comments

@NeoSephiroth
Copy link

NeoSephiroth commented Aug 20, 2022

Hi!
I can access wallet info through the normal HTTP/REST code.

I'm using code like this to access these informations:
bitkub_wallet_amount_USDT = bitkub.wallet()['result']['USDT']

I'm wondering if it's possible to access this also through WebSocket...can anyone help me?

@NeoSephiroth
Copy link
Author

NeoSephiroth commented Aug 20, 2022

This is a fragment of code that I'm working on that uses WebSocket, it works!
I would like to know what I should change in order to get infos about current holdings in my wallet....

from settrade.openapi import Investor
from bitkub import Bitkub
import time as sleep_time
from datetime import datetime
from datetime import time
from pytz import timezone # for timezone

#########################Login Part###########################
investor = Investor(
app_id="", # Your app ID
app_secret="", # Your app Secret
broker_id="",
app_code="",
is_auto_queue=False)

API_KEY = ''
API_SECRET = ''
bitkub = Bitkub(api_key=API_KEY, api_secret=API_SECRET)

deri = investor.Derivatives(account_no="") # Your account number
account_info = deri.get_account_info()
realtime = investor.RealtimeDataConnection()

import websocket
import _thread
import time
import rel

def on_message(ws, message):
print(message)

def on_error(ws, error):
print(error)

def on_close(ws, close_status_code, close_msg):
print("### closed ###")

def on_open(ws):
print("Opened connection")

if name == "main":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://api.bitkub.com/websocket-api/market.trade.thb_btc",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close)

ws.run_forever(dispatcher=rel)  # Set dispatcher to automatic reconnection
rel.signal(2, rel.abort)  # Keyboard Interrupt
rel.dispatch()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@NeoSephiroth and others