Coder Social home page Coder Social logo

nsepython's Introduction

Hello there! ✨

Aeron7's github stats Top Langs

nsepython's People

Contributors

aeron7 avatar blmhemu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsepython's Issues

JSONDecodeError for nse_eq('PVR')

Hi Team,
I have installed the library via pip3

while executing the below code , I am getting the below error mentioned

from nsepython import *

print(indices)
# print(nse_optionchain_scrapper('PVR'))
print(nse_eq('PVR'))

Error Code
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Complete Error Code

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/thoughtworks/projects/coursera/pythonPract/stock-details.py", line 5, in <module>
    print(nse_eq('PVR'))
          ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/nsepython/rahu.py", line 289, in nse_eq
    payload = nsefetch('https://www.nseindia.com/api/quote-equity?symbol='+symbol)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/nsepython/rahu.py", line 18, in nsefetch
    output = requests.get(payload,headers=headers).json()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

System Configuration:
Mac
Python 3.11.2
pip 23.1.2

too many redirects

I get the following error for different function calls randomly. How can I resolve this?

image

Error in fetching expiry list

The expiry_list('NIFTY') function doesn't work anymore. It just gets stuck. Is it because of issues in NSE website or with the library? Please help.

requests.exceptions.SSLError caused due to

Hi Team,
I have installed the library via pip3

while executing the below code , I am getting the below error mentioned


from nsepython import *
import ssl

ssl._create_default_https_context = ssl._create_unverified_context
ssl._create_default_https_context = ssl._create_unverified_context
ssl._create_default_https_context = ssl._create_stdlib_context

print(indices)
print(fnolist())
print(nse_optionchain_scrapper('PVR'))

Error Code

MaxRetryError: HTTPSConnectionPool(host='www.nseindia.com', port=443): Max retries exceeded with url: /api/equity-stockIndices?index=SECURITIES%20IN%20F%26O (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)')))

Complete Error Code

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
                ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 517, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 1075, in _create
    self.do_handshake()
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 1346, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

For all python request ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed, I would use verify=False like requests.get('http://api.xxxx.com/v1/sbin',verify=False), but not sure how to pass the SSL verification false for the nsepython library

certificate verify failed: unable to get local issuer certificate

System Configuration:
Mac
Python 3.11.2
pip 23.1.2

Unable to fetch data

Few days back I was able to fetch data using nsepython but I am unable to fetch data now for some reason. Can someone let me know if the library is working fine on their end?

nse data fetch issue

Issue:
can't able to fetch index history using index_history function

ERROR:

"""
KeyError Traceback (most recent call last)
in <cell line: 6>()
4 start_date_r = start_date.strftime("%d-%b-%Y")
5 print(end_date_r, start_date_r)
----> 6 df = index_history(symbol,start_date_r,end_date_r)
7 len(df)

/usr/local/lib/python3.10/dist-packages/nsepython/rahu.py in index_history(symbol, start_date, end_date)
746 data = "{'name':'"+symbol+"','startDate':'"+start_date+"','endDate':'"+end_date+"'}"
747 payload = requests.post('https://niftyindices.com/Backpage.aspx/getHistoricaldatatabletoString', headers=niftyindices_headers, data=data).json()
--> 748 payload = json.loads(payload["d"])
749 payload=pd.DataFrame.from_records(payload)
750 return payload

KeyError: 'd'
"""

note:
payload = requests.post('https://niftyindices.com/Backpage.aspx/getHistoricaldatatabletoString', headers=niftyindices_headers, data=data).json()

payload={'Message': 'There was an error processing the request.',
'StackTrace': '',
'ExceptionType': ''}

nsefetch(payload) for local throws Access Denied

Tried nsefetch(“https://www.nseindia.com/api/equity-stockIndices?index=NIFTY%2050”) in a loop.

Output: b'<HTML><HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD><BODY>\n<H1>Access Denied</H1>\n \nYou don\'t have permission to access "http&#58;&#47;&#47;www&#46;nseindia&#46;com&#47;api&#47;equity&#45;stockIndices&#63;" on this server.<P>\nReference&#32;&#35;18&#46;5c01d517&#46;1715925139&#46;41f263\n<P>https&#58;&#47;&#47;errors&#46;edgesuite&#46;net&#47;18&#46;5c01d517&#46;1715925139&#46;41f263</P>\n</BODY>\n</HTML>\n’

Multi Request: 401

Getting requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
due to Unauthorized 401 error resulting after Mimicking FrontPage visit.

Even after using the commit b0b7d36 was not able to resolve the issue

Have raised PR for tackling below issue 70accbf

The main use case is to iterate over all nse_eq symbols

symbols = nse_eq_symbols()
for symbol in symbols[:3]:
    print("This is my symbol :: ",symbol)
    df = nse_eq(symbol)
    print("Price info :: ",df['priceInfo'])
    open_val,high,low,current = df['priceInfo']['open'],df['priceInfo']['intraDayHighLow']['max'],df['priceInfo']['intraDayHighLow']['min'],df['priceInfo']['lastPrice']
    print("Open value :: ",open_val)
    print("High value :: ",high)
    print("Low value :: ",low)
    print("Current value :: ",current) 

Not working on colab / google cloud / aws

Hi sir
everything works fine on local pc but not working on any of cloud server VM
print(indices)
print(fnolist())
above two function works fine in cloud too..
print(nse_optionchain_scrapper('PVR')) is not woking ...

please resolve it ...
thank you

incorrect json format is returned by APIS

from nsepython import *

print(nsetools_get_quote("reliance"))

This piece of code is returning

{'symbol': 'RELIANCE', 'identifier': '', 'series': 'EQ', 'open': '2590.3', 'dayHigh': '2641.35', 'dayLow': '2582.2', 'lastPrice': '2632', 'previousClose': '2591.1', 'change': 40.9, 'pChange': 1.58, 'totalTradedVolume': 5838244, 'totalTradedValue': 15332513157.68, 'lastUpdateTime': '31-DEC-2999', 'yearHigh': '2856.15', 'yearLow': '2083.4', 'nearWKH': 7.847977172067296, 'nearWKL': -26.33195737736392, 'perChange365d': 20.76, 'date365dAgo': '13-Aug-2021', 'chart365dPath': 'https://static.nseindia.com/sparklines/365d/RELIANCE-EQ.jpg', 'date30dAgo': '15-Jul-2022', 'perChange30d': 7.88, 'chart30dPath': 'https://static.nseindia.com/sparklines/30d/RELIANCE-EQ.jpg', 'chartTodayPath': 'https://static.nseindia.com/sparklines/today/RELIANCEEQN.jpg', 'meta': {'symbol': 'RELIANCE', 'companyName': 'Reliance Industries Limited', 'industry': 'REFINERIES', 'activeSeries': ['EQ'], 'debtSeries': [], 'tempSuspendedSeries': [], 'isFNOSec': True, 'isCASec': False, 'isSLBSec': True, 'isDebtSec': False, 'isSuspended': False, 'isETFSec': False, 'isDelisted': False, 'isin': 'INE002A01018'}}

a valid JSON requires double quotes for its strings.

Connection not working in Ubuntu Digital Ocean VPS

I am running NSEPython from Ubuntu VPS in Digital Ocean. I am running the function to fetch expiry date of the contracts. But it isn't loading anything. But from my local Windows desktop it is working. Is there any special configuration I should do to run in Ubuntu? But through Firefox in Ubuntu, I am able to access the nseindia.com API URL. Kindly help. Thanks.

Unable to fetch derivative quotes for M&M

In [33]: nsepython.nse_quote_ltp('M&M', 'latest', 'Fut')

KeyError Traceback (most recent call last)
in
----> 1 nsepython.nse_quote_ltp('M&M', 'latest', 'Fut')

c:\users<>\appdata\local\programs\python\python38\lib\site-packages\nsepython\rahu.py in nse_quote_ltp(symbol, expiryDate, optionType, strikePrice)
192
193 if(expiryDate=="latest") or (expiryDate=="next"):
--> 194 dates=list(set((payload["expiryDates"])))
195 dates.sort(key = lambda date: datetime.datetime.strptime(date, '%d-%b-%Y'))
196 if(expiryDate=="latest"): expiryDate=dates[0]

KeyError: 'expiryDates'

401 error when we fetch nse data

I am trying to get the last closed price of a stock. And the nsefetch() gets a 401 error response. And when we try to get json from it we get a requests.exceptions.JSONDecodeError

Details/Steps to recreate
I am running everything for a local setup. And for my code I am using this.

from nsepython import *
symbol = 'SWSOLAR'
print(nse_eq(symbol)['priceInfo']['close'])

And it errors out here when we try make the get call to https://www.nseindia.com/api/quote-equity?symbol=SWSOLAR. It returns a 401 and when we try to jsoninfy it we get the error raised up requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0).
This is the details of the 401 response that we get.

{'_content': b'<!DOCTYPE html>\r\n<html lang="en">\r\n<head>\r\n  <meta chars'
             b'et="UTF-8">\r\n  <title>Oops</title>\r\n</head>\r\n<body style'
             b'="background-color: #e8e8e8;">\r\n  <div style="font-size: 14p'
             b'x; padding: 50px 0; text-align: center;">\r\n    <h1>\r\n      N'
             b'o authorization token was found\r\n    </h1>\r\n    <h2>\r\n  '
             b'    401\r\n    </h2>\r\n    <pre style="text-align: left; font-s'
             b'ize: 11px;">UnauthorizedError: No authorization token was fo'
             b'und\n    at middleware (/www/nse-website-node-v2/files/node_m'
             b'odules/express-jwt/lib/index.js:79:21)\n    at Layer.handle ['
             b'as handle_request] (/www/nse-website-node-v2/files/node_modules/'
             b'express/lib/router/layer.js:95:5)\n    at next (/www/nse-webs'
             b'ite-node-v2/files/node_modules/express/lib/router/route.js:137:1'
             b'3)\n    at attachCors (/www/nse-website-node-v2/files/server/'
             b'middleware.js:188:3)\n    at Layer.handle [as handle_request]'
             b' (/www/nse-website-node-v2/files/node_modules/express/lib/router'
             b'/layer.js:95:5)\n    at next (/www/nse-website-node-v2/files/'
             b'node_modules/express/lib/router/route.js:137:13)\n    at Rout'
             b'e.dispatch (/www/nse-website-node-v2/files/node_modules/express/'
             b'lib/router/route.js:112:3)\n    at Layer.handle [as handle_re'
             b'quest] (/www/nse-website-node-v2/files/node_modules/express/lib/'
             b'router/layer.js:95:5)\n    at /www/nse-website-node-v2/files/'
             b'node_modules/express/lib/router/index.js:281:22\n    at Funct'
             b'ion.process_params (/www/nse-website-node-v2/files/node_modules/'
             b'express/lib/router/index.js:335:12)\n    at next (/www/nse-we'
             b'bsite-node-v2/files/node_modules/express/lib/router/index.js:275'
             b':10)\n    at next (/www/nse-website-node-v2/files/node_module'
             b's/express/lib/router/route.js:127:14)\n    at /www/nse-websit'
             b'e-node-v2/files/server/routes.js:388:11</pre>\r\n  </div>\r\n</b'
             b'ody>\r\n</html>\r\n',
 '_content_consumed': True,
 '_next': None,
 'connection': <requests.adapters.HTTPAdapter object at 0x151135cc0>,
 'cookies': <RequestsCookieJar[Cookie(version=0, name='AKA_A2', value='A', port=None, port_specified=False, domain='.nseindia.com', domain_specified=True, domain_initial_dot=False, path='/', path_specified=True, secure=True, expires=1694352722, discard=False, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False), Cookie(version=0, name='ak_bmsc', value='3FF27A5BD0D6CA89B241FE09D6BE37DD~000000000000000000000000000000~YAAQKkw5F3zBT3qKAQAAktwTfxVprxRxAcgBFTxytM1PfqlASuI9TI8joQ2Ye9qvEBer7lG6V75Y+iSYBuOnUAqBvmWyY0hnqnYcK7sgA9zVYAOHWG8/PCGTeqY6hGbYGkm9tELEjEU+PrLsdw8FePPXkRh1mDEqLOLegucczlNt1WBNI6lak4II4Ygd25ZzH40AabtyJpjwMcvYUfLHeYXPJHrnPlseOWqFRRy2wMQPBlEcGo/vU24kqu4lxCThxjcOFccUGIgx3pok3O1VXIwzbc3NDnRRzNdIrKJrov1u2HtH+e9rQbwx6zs6HwmknR9VFkosHJiG31AXheHIwupmiXSvEomrOsDLcSNbp5VG5aMh0WPvh7okBQKzkj60fw==', port=None, port_specified=False, domain='.nseindia.com', domain_specified=True, domain_initial_dot=True, path='/', path_specified=True, secure=False, expires=1694356322, discard=False, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False)]>,
 'elapsed': datetime.timedelta(microseconds=354280),
 'encoding': 'utf-8',
 'headers': {'Server': 'Apache', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Content-Security-Policy': "font-src *; default-src 'self' *; img-src * data: https://www.google.co.in https://www.google-analytics.com www.google-analytics.com https://nse-widget.interface.ai; style-src * 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.youtube.com *.gstatic.com https://www.google.com/ *.cloudflare.com *.googletagmanager.com *.highcharts.com *.go-mpulse.net https://stats.g.doubleclick.net/ https://www.google.com/ *.doubleclick.net https://nse-uat-widget.interface.ai/widget-loader.js www.google-analytics.com *.g.doubleclick.net/ https://analytics.google.com/ https://nse-widget.interface.ai", 'Access-Control-Allow-Origin': 'beta.nseindia.com, nseindia.com', 'Access-Control-Allow-Methods': 'GET,POST', 'Access-Control-Allow-Headers': 'Content-Type', 'Content-Type': 'text/html; charset=utf-8', 'Content-Encoding': 'gzip', 'Date': 'Sun, 10 Sep 2023 12:32:02 GMT', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive, Transfer-Encoding', 'Vary': 'Accept-Encoding', 'Set-Cookie': 'AKA_A2=A; expires=Sun, 10-Sep-2023 13:32:02 GMT; path=/; domain=nseindia.com; secure; HttpOnly, ak_bmsc=3FF27A5BD0D6CA89B241FE09D6BE37DD~000000000000000000000000000000~YAAQKkw5F3zBT3qKAQAAktwTfxVprxRxAcgBFTxytM1PfqlASuI9TI8joQ2Ye9qvEBer7lG6V75Y+iSYBuOnUAqBvmWyY0hnqnYcK7sgA9zVYAOHWG8/PCGTeqY6hGbYGkm9tELEjEU+PrLsdw8FePPXkRh1mDEqLOLegucczlNt1WBNI6lak4II4Ygd25ZzH40AabtyJpjwMcvYUfLHeYXPJHrnPlseOWqFRRy2wMQPBlEcGo/vU24kqu4lxCThxjcOFccUGIgx3pok3O1VXIwzbc3NDnRRzNdIrKJrov1u2HtH+e9rQbwx6zs6HwmknR9VFkosHJiG31AXheHIwupmiXSvEomrOsDLcSNbp5VG5aMh0WPvh7okBQKzkj60fw==; Domain=.nseindia.com; Path=/; Expires=Sun, 10 Sep 2023 14:32:02 GMT; Max-Age=7200; HttpOnly', 'Server-Timing': 'cdn-cache; desc=REVALIDATE, edge; dur=85, origin; dur=35, ak_p; desc="1694349122490_389631018_485543705_11957_9607_71_86_-";dur=1', 'Link': '<https://www.nseindia.com/assets/webfonts/fa-brands-400.woff2>;rel="preload";as="font";type="font/woff2";crossorigin,<https://www.nseindia.com/assets/webfonts/fa-solid-900.woff2>;rel="preload";as="font";type="font/woff2";crossorigin, <https://www.google-analytics.com>;rel="preconnect"', 'Strict-Transport-Security': 'max-age=31536000 ; includeSubDomains ; preload'},
 'history': [],
 'raw': <urllib3.response.HTTPResponse object at 0x151135b40>,
 'reason': 'Unauthorized',
 'request': <PreparedRequest [GET]>,
 'status_code': 401,
 'url': 'https://www.nseindia.com/api/quote-equity?symbol=SWSOLAR'}

Future warning of frame append while using oi_chain_builder()

Hi,
I am using oi_chain_builder(), But getting following warning.

rahu.py:146: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

I tried to modify line no. 146 of rahu.py: oi_data = oi_data.append(oi_row, ignore_index=True) as oi_data = pd.concat([oi_data,oi_row],index=False), but not succeed.

Could anyone please guide me to get rid of this error.

JSONDecodeError

using nsepython
getting below error while invoking nse_eq(symbol)
Error occurred while processing : <class 'requests.exceptions.JSONDecodeError'>

print(nse_quote_ltp("RELIANCE","next","Fut")) doesn't work

DEBUG:urllib3.connectionpool:https://www.nseindia.com:443 "GET /api/quote-derivative?symbol=NIFTY HTTP/1.1" 200 None
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nsepython/rahu.py", line 279, in nse_quote_meta
return metadata
UnboundLocalError: local variable 'metadata' referenced before assignment

How to use cURL command to retrieve data in AWS

Hi so I am using Results Calendar function of this library and also read that I will have to use curl shell command to run code in Cloud

Can u provide me a road map or code of exactly how to run code using cURL command ??

Thanks

index_pe_pb_div results in JSONDecodeError

from nsepython import index_pe_pb_div

def dataset_generator():  
    symbol = "NIFTY 50"
    start_date = "01-Mar-2011"
    end_date = "07-Jun-2021"
    print(index_pe_pb_div(symbol,start_date,end_date))
    
dataset_generator()
Traceback (most recent call last):
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Dev.Juneja\Downloads\Fin-Maestro\Prerequisites\test.py", line 9, in <module>
    dataset_generator()
  File "c:\Users\Dev.Juneja\Downloads\Fin-Maestro\Prerequisites\test.py", line 7, in dataset_generator
    print(index_pe_pb_div(symbol,start_date,end_date))
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nsepython\rahu.py", line 727, in index_pe_pb_div
    payload = requests.post('https://niftyindices.com/Backpage.aspx/getpepbHistoricaldataDBtoString', headers=niftyindices_headers,  data=data).json()
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

OI Chain Builder returns data only for the current expiry

oi_chain_builder is supposed to return the data for any expiry date based on the date but it does not return the same. If we pass any date as an argument it returns a blank dataframe.

Suggestion to rename the default "latest" argument to "current". Equity has only 3 concurrent expiry dates. Hence names suggested "current", "next" and "last"

For Indices there are options for 21 expiry dates running concurrently at a given time. So giving a list of date options or allowing an integer input for no of weeks to expiry can make usage easy.

nsepython prints lot of unnecessary debug information

In local usage of nsepython, it logs all request responses, without giving a way to control this logging.
I understand this may be helpful in debugging nsepython itself, but a client app should have a way to control its library logs.
This causes unpleasant spamming in client logs and makes client logic harder to debug.

NSE Lot Sizes function throws error

File .venv/lib/python3.12/site-packages/nsepython/rahu.py", line 484, in nse_get_fno_lot_sizes (code, name) = [x.strip() for x in line.split(',')[1:3]] ^^^^^^^^^^^^ ValueError: not enough values to unpack (expected 2, got 1)

Seems like the problem is in the url:
url="https://archives.nseindia.com/content/fo/fo_mktlots.csv"

Throws 404. Perhaps need a new URL?

Documentation link doesn't seem to work

I have just downloaded nsepython and wanted to give it try. But it seems that the documentation link https://unofficed.com/nse-python/documentation/ isn't working

is_market_open bug

function is_market_open return true even if is holiday today.
Problem is in the line:

return True

This only checks for first holiday from the nse_holidays() json result and return True by checking only the first. It should be continue here to check for the next holiday date and a final return true at the end of function.

Unable to get derivative history

Unable to get derivative history.
The sample program in documentation also does not work.

symbol = "SBIN"
start_date = "15-05-2021"
end_date ="15-06-2021"
instrumentType = "options"
expiry_date ="24-Jun-2021"
strikePrice = 300
optionType="PE"
print(derivative_history(symbol,start_date,end_date,instrumentType,expiry_date,strikePrice,optionType))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.