Skip to main content

Free Zerodha API python library

Project description

Documentation

https://marketsetup.in/documentation/jugaad-data/

Introduction

jugaad-data is a python library to download historical/live stock, index as well as economic data from NSE and RBI website using.

Build Badge

Features

  • Supports new NSE website, (All libraries based on old NSE website might stop working)
  • Powerful CLI (Command line interface), Even non-coders can use it easily
  • Built-in caching mechanism to play nice with NSE. Avoid making un-necessary requests to NSE's website and getting blocked
  • Optional pandas support

Road map

Website Segment Supported?
NSE Stocks Yes
NSE Stocks F&O Yes
NSE Index Yes
NSE Index F&O Yes
RBI Current Rates Yes

Installation

pip install jugaad-data

Getting started

Python inteface

Historical data

from datetime import date
from jugaad_data.nse import bhavcopy_save, bhavcopy_fo_save

# Download bhavcopy
bhavcopy_save(date(2020,1,1), "/path/to/directory")

# Download bhavcopy for futures and options
bhavcopy_fo_save(date(2020,1,1), "/path/to/directory")

# Download stock data to pandas dataframe
from jugaad_data.nse import stock_df
df = stock_df(symbol="SBIN", from_date=date(2020,1,1),
            to_date=date(2020,1,30), series="EQ")

Live data

from jugaad_data.nse import NSELive
n = NSELive()
q = n.stock_quote("HDFC")
print(q['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}}

Command line interface

$ jdata stock --help

Usage: jdata stock [OPTIONS]

  Download historical stock data

  $jdata stock --symbol STOCK1 -f yyyy-mm-dd -t yyyy-mm-dd --o file_name.csv

Options:
  -s, --symbol TEXT  [required]
  -f, --from TEXT    [required]
  -t, --to TEXT      [required]
  -S, --series TEXT  [default: EQ]
  -o, --output TEXT
  --help             Show this message and exit.
$ jdata stock -s SBIN -f 2020-01-01 -t 2020-01-31 -o SBIN-Jan.csv
SBIN  [####################################]  100%

Saved file to : SBIN-Jan.csv

Download historical derivatives (F&O) data

$ jdata deriviatives --help
Usage: cli.py derivatives [OPTIONS]

  Sample usage-

  Download stock futures-

  jdata derivatives -s SBIN -f 2020-01-01 -t 2020-01-30 -e 2020-01-30 -i FUTSTK -o file_name.csv

  Download index futures-

  jdata derivatives -s NIFTY -f 2020-01-01 -t 2020-01-30 -e 2020-01-30 -i FUTIDX -o file_name.csv

  Download stock options-

  jdata derivatives -s SBIN -f 2020-01-01 -t 2020-01-30 -e 2020-01-30 -i OPTSTK -p 330 --ce -o file_name.csv

  Download index options-

  jdata derivatives -s NIFTY -f 2020-01-01 -t 2020-01-30 -e 2020-01-23 -i OPTIDX -p 11000 --pe -o file_name.csv

Options:
  -s, --symbol TEXT  Stock/Index symbol  [required]
  -f, --from TEXT    From date - yyyy-mm-dd  [required]
  -t, --to TEXT      To date - yyyy-mm-dd  [required]
  -e, --expiry TEXT  Expiry date - yyyy-mm-dd  [required]
  -i, --instru TEXT  FUTSTK - Stock futures, FUTIDX - Index Futures, OPTSTK -
                     Stock Options, OPTIDX - Index Options  [required]

  -p, --price TEXT   Strike price (Only for OPTSTK and OPTIDX)
  --ce / --pe        --ce for call and --pe for put (Only for OPTSTK and
                     OPTIDX)

  -o, --output TEXT  Full path of output file
  --help             Show this message and exit.

Buy me a coffee

If my work has helped you in anyway, you can buy me a coffee

"Buy Me A Coffee"

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

jugaad_data-0.31.2.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jugaad_data-0.31.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file jugaad_data-0.31.2.tar.gz.

File metadata

  • Download URL: jugaad_data-0.31.2.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jugaad_data-0.31.2.tar.gz
Algorithm Hash digest
SHA256 0503f458176bfa0ba2e339334dbb76e3af65d4f891dac32571c47fa80fa7d651
MD5 72cdcbd3b47562671ed6393238533458
BLAKE2b-256 31eeb7e83882ef0b05623aa953a0b4e53d58e0e746f1dccda90223aa04cb7981

See more details on using hashes here.

File details

Details for the file jugaad_data-0.31.2-py3-none-any.whl.

File metadata

  • Download URL: jugaad_data-0.31.2-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jugaad_data-0.31.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f84080b24cc6d427a7879870bd416e1cd6027b7657d47f904420c097b820224
MD5 db857979fe5e71eb4b8572998c430e13
BLAKE2b-256 afe3d54c12a4c0a86a10d0369f023fa0713effe1520e4352182caffefbcd6bd1

See more details on using hashes here.

Supported by

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