Fetch live stock quote from new NSE website using jugaad-data

Support to fetch live data will be added incrementally to jugaad-data. Here’s the first installment, an example of how to fetch live stock quotes. The documentation will be updated incrementally, meanwhile showing the usage through example.

from jugaad_data.nse import NSELive

NSELive is a container class for functions to interact with NSE’s live data APIs.

n = NSELive()

stock_quote is a function which fetches live quote for a stock along with a lot of other metadata.

q = n.stock_quote("HDFC")
dict_keys(['info', 'metadata', 'securityInfo', 'priceInfo', 'preOpenMarket'])

Let’s look at the metadata and significance of some of the fields.

{'series': 'EQ',
 'symbol': 'HDFC',
 'isin': 'INE001A01036',
 'status': 'Listed',
 'listingDate': '23-Oct-1996',
 'industry': 'HOUSING FINANCE',
 'lastUpdateTime': '15-Jan-2021 16:00:00',
 'pdSectorPe': 31.43,
 'pdSymbolPe': 29.19,
 'pdSectorInd': 'NIFTY FINANCIAL SERVICES                          '}

Details of priceInfo

{'lastPrice': 2635,
 'change': -49.05000000000018,
 'pChange': -1.8274622305843848,
 'previousClose': 2684.05,
 'open': 2661,
 'close': 2632.75,
 'vwap': 2645.57,
 'lowerCP': '2415.65',
 'upperCP': '2952.45',
 'pPriceBand': 'No Band',
 'basePrice': 2684.05,
 'intraDayHighLow': {'min': 2615.6, 'max': 2688.45, 'value': 2635},
 'weekHighLow': {'min': 1473.45,
  'minDate': '24-Mar-2020',
  'max': 2777.15,
  'maxDate': '13-Jan-2021',
  'value': 2635}}

Similarly you can look at other information in info and preOpenMarket

{'symbol': 'HDFC',
 'companyName': 'Housing Development Finance Corporation Limited',
 'industry': 'FINANCE - HOUSING',
 'activeSeries': ['EQ', 'W3'],
 'debtSeries': [],
 'tempSuspendedSeries': ['W1', 'W2'],
 'isFNOSec': True,
 'isCASec': False,
 'isSLBSec': True,
 'isDebtSec': False,
 'isSuspended': False,
 'isETFSec': False,
 'isDelisted': False,
 'isin': 'INE001A13049',
 'isTop10': False,
 'identifier': 'HDFCEQN'}
{'boardStatus': 'Main',
 'tradingStatus': 'Active',
 'tradingSegment': 'Normal Market',
 'sessionNo': '-',
 'slb': 'Yes',
 'classOfShare': 'Equity',
 'derivatives': 'Yes',
 'surveillance': '-',
 'faceValue': 2,
 'issuedCap': 1800191002}
{'preopen': [{'price': 2442.5, 'buyQty': 0, 'sellQty': 1248},
  {'price': 2496.15, 'buyQty': 0, 'sellQty': 253},
  {'price': 2549.85, 'buyQty': 0, 'sellQty': 2526},
  {'price': 2600, 'buyQty': 0, 'sellQty': 1},
  {'price': 2661, 'buyQty': 0, 'sellQty': 0, 'iep': True},
  {'price': 2816.9, 'buyQty': 150, 'sellQty': 0},
  {'price': 2818, 'buyQty': 7, 'sellQty': 0},
  {'price': 2818.25, 'buyQty': 1877, 'sellQty': 0},
  {'price': 2952.45, 'buyQty': 177, 'sellQty': 0}],
 'ato': {'buy': 622, 'sell': 5946},
 'IEP': 2661,
 'totalTradedVolume': 29735,
 'finalPrice': 2661,
 'finalQuantity': 29735,
 'lastUpdateTime': '15-Jan-2021 09:07:19',
 'totalBuyQuantity': 63224,
 'totalSellQuantity': 35437,
 'atoBuyQty': 622,
 'atoSellQty': 5946}