☰
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
14.1K
All Categories
0
Incidents
157
Node JS client
41
Go client
795
.Net API client
385
Kite Publisher
537
.Net / VBA / Excel (3rd party)
463
Algorithms and Strategies
1K
Java client
1.1K
API clients
407
PHP client
4.1K
Python client
349
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.4K
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.