☰
Login
Signup
Home
›
Market data (WebSockets)
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.8K
All Categories
0
Incidents
151
Node JS client
39
Go client
790
.Net API client
377
Kite Publisher
537
.Net / VBA / Excel (3rd party)
456
Algorithms and Strategies
991
Java client
1.1K
API clients
402
PHP client
4K
Python client
345
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
December 2023
rakeshr
help me get data periodically
Balaganga
December 2023
in
Market data (WebSockets)
from kiteconnect import KiteConnect
import time
from kiteconnect import KiteTicker
from datetime import datetime
api_key="exxxxxxxxxxxxxx5"
access_token="3xxxxxxxxxxxxxxxxxxxxxxxxxxxxx4w3"
kws = KiteTicker(api_key,access_token)
tokens=[66048775,65113863,66717959]
dict={66048775:'CRUDEOIL23DECFUT',65113863:'SILVERM24FEBFUT',66717959:'GOLDM24JANFUT'}
def on_ticks(ws, ticks):
ticks=[dict[ticks[0]['instrument_token']],ticks[0]['timestamp'],ticks[0]['last_price']]
print(ticks)
def on_connect(ws, response):
ws.subscribe(tokens)
ws.set_mode(ws.MODE_FULL,tokens)
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.connect(threaded=True)
count=0
while True:
count+=1
if(count%2==0):
if kws.is_connected():
kws.set_mode(kws.MODE_FULL,tokens)
else:
if kws.is_connected():
kws.set_mode(kws.MODE_FULL,tokens)
time.sleep(0.350)
No output is displaced in any platform
Can anyone help.
rakeshr
December 2023
Can you add
on_error
method and callback, to check for any error?
Go through the python
threaded ticker example here
.
Sign In
or
Register
to comment.
on_error
method and callback, to check for any error?Go through the python threaded ticker example here.