Skip to main content

Python library for live streaming option chain using Kiteconnect Websocket

Project description

Option Chain Stream

Live streaming option chain for equity derivatives using Kite connect Websocket.

This package uses Redis as storage backend. Here Redis is used to store real time streaming websocket data and instruments detail i.e all option strike details for contracts. Combination of these data structure are used to create real-time option chain stream for any given instrument.

Installation

pip install optionchain_stream

Request parameters

Field Type Detail
api_key string Kite connect API key
secret_key string Kite connect API secret
request_token string Kite connect one-time token obtained after the login flow
option_symbol string Symbol of the instrument(eg: NIFTY, SBIN, ONGC, etc)
option_expiry_date string Option expiry date in yyyy-mm-dd format(eg: '2021-02-25', '2021-04-29')

Usage

from optionchain_stream import OptionChain
OptionStream = OptionChain("api_key", "secret_key", "request_token",
                    "option_symbol", "option_expiry_date in yyyy-mm-dd format")
# Eg: OptionChain('XXXXXX', 'XXXXXXX', 'XXXXXX', 
                    'ONGC', '2021-02-25')

# Sync master instrument data to DB(redis)     
# This sync is required only once daily at initial run             
OptionStream.sync_instruments()

# Stream option chain data in real-time
StreamData = OptionStream.create_option_chain()
for data in StreamData:
    print(data)

Response

Responses are JSON messages.

...., 'change': 54.09090909090908, 'oi': 7700},{'token': 24268034, 'symbol': 'ONGC21FEB87PE', 'last_price': 1.5, 'volume': 61600, 'change': 0.0, 'oi': 400400}, 
{'token': 24268290, 'symbol': 'ONGC21FEB88CE', 'last_price': 10.6, 'volume': 0, 'change': -12.033195020746897, 'oi': 15400}, {'token': 24268546, 'symbol': 
'ONGC21FEB88PE', 'last_price': 1.75, 'volume': 53900, 'change': 25.000000000000007, 'oi': 261800}, {'token': 24268802, 'symbol': 'ONGC21FEB89CE', 
'last_price':10.6, 'volume': 15400, 'change': -5.77777777777778, 'oi': 107800}, 
{'token': 24269058, 'symbol': 'ONGC21FEB89PE', 'last_price': 1.85, 'volume': 184800, 'change': -11.904761904761905, 'oi': 338800}, {'token': 24269314, 'symbol': 
'ONGC21FEB90CE', 'last_price': 10.0, 'volume': 654500, 'change': 2.5641025641025643, 'oi': 1632400}, {'token': 24269570, 'symbol': 'ONGC21FEB90PE', 'last_price': 
2.2, 'volume': 1925000, 'change': -2.2222222222222143, 'oi': 3326400}, {'token': 24269826, 'symbol': 'ONGC21FEB91CE', 'last_price': 9.3, 'volume': 15400, 
'change': -6.999999999999993, 'oi': 308000}, {'token': 24270082, 'symbol': 'ONGC21FEB91PE', 'last_price': 2.55, 'volume': 61600, 'change': -5.555555555555569, 
'oi': 323400}, {'token': 24270338, 'symbol': 'ONGC21FEB92CE', 'last_price': 8.7, 'volume': 30800,....

Response attributes

Field Type Detail
token string instrument_token for requested tradingsymbol
symbol string tradingsymbol of the instrument
last_price float Current market price
volume int Volume traded for the day
change float Price change % w.r.t previous day close/LTP
oi float Open Interest for a options contract

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optionchain_stream-0.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

optionchain_stream-0.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file optionchain_stream-0.4.tar.gz.

File metadata

  • Download URL: optionchain_stream-0.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for optionchain_stream-0.4.tar.gz
Algorithm Hash digest
SHA256 02143adce12a32496564a3a02b996a8e31b6dd9d79032189f8c5f57c7b1e2af4
MD5 b335f4c9129000f82aa4e91c99779f6d
BLAKE2b-256 229ccad5d3ce070bde2228d850a9120f8cfebfeb3bf2bbd15efdc7421b455269

See more details on using hashes here.

File details

Details for the file optionchain_stream-0.4-py3-none-any.whl.

File metadata

  • Download URL: optionchain_stream-0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for optionchain_stream-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14faf10bffbfbb9247c10364e49f300179629056de4b8b8014a2a5d07c3b8343
MD5 345e340b197c3c22225b642b1ee0f4dc
BLAKE2b-256 9875078644c7b7d88ef6fc9a5d93b8e581f8b9778cfdaf0bcd28482e4203d91a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page