DhelmGfeedClient package

Submodules

DhelmGfeedClient.constants module

constants.py

  • Copyright (c) 2018, KNC Solutions Private Limited.
  • License: ‘Apache License, Version 2.0’.
  • version: 1.0.0
class DhelmGfeedClient.constants.Constants

Bases: object

AUTHENTICATE = 'Authenticate'
DAY = 'DAY'
GET_EXCHANGES = 'GetExchanges'
GET_EXCHANGE_MESSAGE = 'GetExchangeMessages'
GET_EXPIRY_DATES = 'GetExpiryDates'
GET_HISTORY = 'GetHistory'
GET_INSTRUMENTS = 'GetInstruments'
GET_INSTRUMENT_TYPES = 'GetInstrumentTypes'
GET_LAST_QUOTE = 'GetLastQuote'
GET_LAST_QUOTE_ARRAY = 'GetLastQuoteArray'
GET_LIMITATIONS = 'GetLimitation'
GET_MARKET_MESSAGE = 'GetMarketMessages'
GET_OPTION_TYPES = 'GetOptionTypes'
GET_PRODUCTS = 'GetProducts'
GET_SERVER_INFO = 'GetServerInfo'
GET_SNAPSHOT = 'GetSnapshot'
GET_STRIKE_PRICES = 'GetStrikePrices'
HOUR = 'HOUR'
MAXDELAY = 5000
MAX_RETRIES = 30
MESSAGE_EXCHANGE_MESSAGE_RESULT = 'ExchangeMessagesResult'
MESSAGE_EXCHANGE_RESULT = 'ExchangesResult'
MESSAGE_EXPIRY_DATE_RESULT = 'ExpiryDatesResult'
MESSAGE_HISTORY_OHLC_RESULT = 'HistoryOHLCResult'
MESSAGE_HISTORY_TICK_RESULT = 'HistoryTickResult'
MESSAGE_INSTRUMENTS_ON_SEARCH_RESULT = 'InstrumentsOnSearchResult'
MESSAGE_INSTRUMENTS_RESULT = 'InstrumentsResult'
MESSAGE_INSTRUMENT_TYPES_RESULT = 'InstrumentTypesResult'
MESSAGE_LAST_QUOTE_ARRAY_RESULT = 'LastQuoteArrayResult'
MESSAGE_LAST_QUOTE_RESULT = 'LastQuoteResult'
MESSAGE_LIMITATION_RESULT = 'LimitationResult'
MESSAGE_MARKET_MESSAGE_RESULT = 'MarketMessagesResult'
MESSAGE_OPTION_TYPES_RESULT = 'OptionTypesResult'
MESSAGE_PRODUCTS_RESULT = 'ProductsResult'
MESSAGE_REAL_TIME_RESULT = 'RealtimeResult'
MESSAGE_REAL_TIME_SNAPSHOT_RESULT = 'RealtimeSnapshotResult'
MESSAGE_SERVER_INFO_RESULT = 'ServerInfoResult'
MESSAGE_SNAPSHOT_RESULT = 'SnapshotResult'
MESSAGE_STRIKE_PRICES_RESULT = 'StrikePricesResult'
MINUTE = 'MINUTE'
MONTH = 'MONTH'
RESULT_NOT_PREPARED = '{"Message:ResponseNotAvailable"}'
SUBSCRIBE_REAL_TIME = 'SubscribeRealtime'
SUBSCRIBE_SNAPSHOT = 'SubscribeSnapshot'
TICK = 'TICK'
TIMEOUT = 30
WEEK = 'WEEK'

DhelmGfeedClient.gfeedclient module

gfeedclient.py

  • Copyright (c) 2018, KNC Solutions Private Limited.
  • License: ‘Apache License, Version 2.0’.
  • version: 1.0.0
class DhelmGfeedClient.gfeedclient.GfeedClient(ws_url, api_key, debug=False, max_retries=30, max_delay=5000, connect_timeout=30)

Bases: object

The client to connect to Global datafeed websocket data.

  • ws_url: The web socket url.(required)
  • param api_key: Your api key.(required)
  • param debug: By default false. Set true to run in debug mode.(optional)
  • param reconnect: By default true. Set false to off auto reconnection.(optional)
  • param reconnect_max_tries: Maximum no of retries.(optional)
  • param reconnect_max_delay: Maximum delay.(optional)
  • param connect_timeout: Connection delay.(optional)
connect()

Establishes a web socket connection. On successful authentication on_authenticated(base_client) callback is fired. The base_client is the currently initialised WebSocket object.

disconnect()

Call this method to disconnect the client.

On disconnection on_close(base_client, code, reason) callback is fired.

get_exchange_message(exchange)

Call this method to get the exchange message for the given exchange.

On successful execution on_message_exchange_message(e_m) callback is fired.

e_m : The exchange message.

Parameters:exchange – The exchange(required)
get_exchanges()

Call this method to get the list of subscribed exchanges.

On successful execution on_message_get_exchanges(list_exchanges) callback is fired.

list_exchanges : The list of subscribed exchanges.

get_expiry_dates(exchange, instrument_type=None, product=None)

Call this method to get the list of expiry dates of different contracts for an exchange.

On successful execution on_message_expiry_dates(e_dates) callback is fired.

e_dates : The list of expiry dates.

Parameters:
  • exchange – The exchange(required)
  • instrument_type – The type of the instrument, e.g. FUTIDX, OPTIDX etc(optional)
  • product – The product, e.g. NIFTY,BANKNIFTY etc(optional).
get_historical_ohlc_data(exchange, instrument_identifier, periodicity, from_timestamp, to_timestamp, max_no=0)

Call this method to get historical ohlc data of the given instruments.

On successful execution on_message_historical_ohlc_data(h_ohlc_d) callback is fired.

h_ohlc_d : The historical tick data of the given instrument.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifier – The instrument identifier(required).
  • periodicity – “HOUR”.”MINUTE”.”DAY”,”WEEK”, or “MONTH”(required).
  • from_timestamp – The from time in unix timestamp(required).
  • to_timestamp – The to time in unix timestamp(required).
  • max_no – Numerical value of maximum records that should be returned(optional).
get_historical_tick_data(exchange, instrument_identifier, max_no=0, from_timestamp=None, to_timestamp=None)

Call this method to get historical tick data of the given instruments.

On successful execution on_message_historical_tick_data(h_t_d) callback is fired.

h_t_d : The historical tick data of the given instrument.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifier – The instrument identifier(required).
  • max_no – Numerical value of maximum records that should be returned(optional).
  • from_timestamp – The from time in unix timestamp(optional).
  • to_timestamp – The to time in unix timestamp(optional).
get_instrument_types(exchange)

Call this method to get the list of instrument types available for an exchange.

On successful execution on_message_instrument_types(i_types) callback is fired.

i_types : The list of instrument types.

Parameters:exchange – The exchange(required)
get_instruments(exchange, instrument_type=None, product=None, expiry=None, option_type=None, strike_price=None)

Call this method to get the list of instruments from an exchange.

On successful execution on_message_instruments(list_instruments) callback is fired.

list_instruments : The list of instruments.

Parameters:
  • exchange – The exchange(required)
  • instrument_type – The type of the instrument, e.g. FUTIDX, OPTIDX etc(optional)
  • product – The product, e.g. NIFTY, BANKNIFTY etc(optional).
  • expiry – The expiry date, e.g. 25OCT2018(optional).
  • option_type – The option type, e.g. PE,CE(optional).
  • strike_price – The strike price(optional).

Call this method to get the list of instruments using search key word.

On successful execution on_message_instruments_on_search(list_instruments) callback is fired.

list_instruments : The list of instruments matching the search word.

Parameters:
  • exchange – The exchange(required)
  • key_word – The search word(required).
get_last_quote(exchange, instrument_identifier)

Call this method to get the last quote of an instrument.

On successful execution on_message_last_quote(l_quote) callback is fired.

l_quote : The last quote of the given instrument.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifier – The instrument identifier(required)
get_last_quotes_array(exchange, instrument_identifiers)

Call this method to get the last quotes of given instruments.

On successful execution on_message_last_quote_array(l_quote_array) callback is fired.

l_quote_array : The last quotes of the given instruments.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifiers – The instrument identifiers(required)
Returns:

get_limitations()

Call this method to get your account details and limitations.

On successful execution on_message_account_limitations(a_limit) callback is fired.

a_limit : Account details and limitations.

get_market_message(exchange)

Call this method to get the market message for the given exchange.

On successful execution on_message_market_message(m_m) callback is fired.

m_m : The market message.

Parameters:exchange – The exchange(required)
get_option_types(exchange, instrument_type=None, product=None, expiry=None)

Call this method to get the list of option types available for different contracts for an exchange.

On successful execution on_message_option_types(o_types) callback is fired.

o_types : The list of option types.

Parameters:
  • exchange – The exchange(required)
  • instrument_type – The type of the instrument, e.g. FUTIDX, OPTIDX etc(optional)
  • product – The product, e.g. NIFTY, BANKNIFTY etc(optional).
  • expiry – The expiry date, e.g. 25OCT2018(optional).
get_products(exchange, instrument_type=None)

Call this method to get the list of products available for an exchange.

On successful execution on_message_product(p) callback is fired.

p : The list of products.

Parameters:
  • exchange – The exchange(required)
  • instrument_type – The type of the instrument, e.g. FUTIDX, OPTIDX etc(optional)
get_snapshot(exchange, instrument_identifiers, periodicity='MINUTE', period=1)

Call this method to get the snapshot quotes of given instruments.

On successful execution on_message_snapshot_data(s_data) callback is fired.

l_data : The snapshot quotes of the given instruments.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifiers – The instrument identifiers(required)
  • periodicity – The periodicity/”HOUR” or “MINUTE”(optional).
  • period – The period.E.g. 1,2,3 etc.(optional).
get_strike_prices(exchange, instrument_type=None, product=None, expiry=None, option_type=None)

Call this method to get the list of strike prices for different contracts for an exchange.

On successful execution on_message_strike_prices(s_prices) callback is fired.

s_prices : The list of strike prices.

Parameters:
  • exchange – The exchange(required)
  • instrument_type – The type of the instrument, e.g. FUTIDX, OPTIDX etc(optional)
  • product – The product, e.g. NIFTY, BANKNIFTY etc(optional).
  • expiry – The expiry date, e.g. 25OCT2018(optional).
  • option_type – The option type, e.g. PE,CE(optional).
is_connected()

Check if WebSocket connection is established.

subscribe_realtime(exchange, instrument_identifier, unsubscribe=False)

Call this method to subscribe to real time data for the given exchange and given instrument.

On successful execution on_message_realtime_data(r_r) callback is fired.

r_r : The real time data.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifier – The instrument identifier(required)
  • unsubscribe – Pass True to unsubscribe(optional)
subscribe_realtime_snapshot(exchange, instrument_identifier, periodicity, unsubscribe=False)

Call this method to subscribe to real time snapshot data for the given exchange, given instrument and given periodicity.

On successful execution on_message_realtime_snapshot_data(r_r) callback is fired.

r_r : The real time snapshot data.

Parameters:
  • exchange – The exchange(required)
  • instrument_identifier – The instrument identifier(required)
  • periodicity – The periodicity.Valid value is either “MINUTE” or “HOUR”(required).
  • unsubscribe – Pass True to unsubscribe(optional)

Module contents

__init__.py

  • Copyright (c) 2018, KNC Solutions Private Limited.
  • License: ‘Apache License, Version 2.0’.
  • version: 1.0.0