This is a simple example which uses Python Kite connect client to receive ticks and save it to Postgresql database. Celery is used as a Task queue manager to insert to database without blocking main Kite connect WebSocket thread.
Kite ticker subscribes to tokens in specified in stream.py
with 5 second delay. Ticks received are sent to
celery taske queue where it will be inserted to db.
pip install celery
pip install psycopg2
pip install kiteconnect
Create a database called ticks
CREATE DATABASE ticks;
Create a table called ticks
in ticks
table
CREATE TABLE ticks (
token integer NOT NULL,
date timestamp without time zone,
price double precision
);
broker
URL in db.py
with redis or any other AMQP client.user
, password
and host
details for Postgresql in db.py
celery -A db worker --loglevel=info
python stream.py