nsepython 2.6__py3-none-any.whl → 2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nsepython/rahu.py +52 -19
- {nsepython-2.6.dist-info → nsepython-2.8.dist-info}/METADATA +3 -3
- nsepython-2.8.dist-info/RECORD +7 -0
- {nsepython-2.6.dist-info → nsepython-2.8.dist-info}/WHEEL +1 -1
- nsepython-2.6.dist-info/RECORD +0 -7
- {nsepython-2.6.dist-info → nsepython-2.8.dist-info}/LICENSE +0 -0
- {nsepython-2.6.dist-info → nsepython-2.8.dist-info}/top_level.txt +0 -0
nsepython/rahu.py
CHANGED
|
@@ -32,19 +32,13 @@ if(mode=='vpn'):
|
|
|
32
32
|
return output
|
|
33
33
|
if(mode=='local'):
|
|
34
34
|
def nsefetch(payload):
|
|
35
|
-
try:
|
|
35
|
+
try:
|
|
36
36
|
output = requests.get(payload,headers=headers).json()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
s=requests.session()
|
|
43
|
-
|
|
44
|
-
payload2 = "https://www.nseindia.com"
|
|
45
|
-
output2 = s.get(payload2,headers=headers).json()
|
|
46
|
-
|
|
47
|
-
output = s.get(payload,headers=headers).json()
|
|
37
|
+
print(output)
|
|
38
|
+
except ValueError:
|
|
39
|
+
s =requests.Session()
|
|
40
|
+
output = s.get("http://nseindia.com",headers=headers)
|
|
41
|
+
output = s.get(payload,headers=headers).json()
|
|
48
42
|
return output
|
|
49
43
|
|
|
50
44
|
|
|
@@ -616,13 +610,16 @@ def derivative_history_virgin(symbol,start_date,end_date,instrumentType,expiry_d
|
|
|
616
610
|
instrumentType = instrumentType.lower()
|
|
617
611
|
|
|
618
612
|
if(instrumentType=="options"):
|
|
619
|
-
if("NIFTY" in symbol): instrumentType="FUTSTK"
|
|
620
613
|
instrumentType="OPTSTK"
|
|
621
|
-
if(instrumentType=="futures"):
|
|
622
614
|
if("NIFTY" in symbol): instrumentType="OPTIDX"
|
|
623
|
-
|
|
615
|
+
|
|
616
|
+
if(instrumentType=="futures"):
|
|
617
|
+
instrumentType="FUTSTK"
|
|
618
|
+
if("NIFTY" in symbol): instrumentType="FUTIDX"
|
|
619
|
+
|
|
624
620
|
|
|
625
|
-
if(((instrumentType=="OPTIDX")or (instrumentType=="OPTSTK")) and (expiry_date!="")):
|
|
621
|
+
#if(((instrumentType=="OPTIDX")or (instrumentType=="OPTSTK")) and (expiry_date!="")):
|
|
622
|
+
if(strikePrice!=""):
|
|
626
623
|
strikePrice = "%.2f" % strikePrice
|
|
627
624
|
strikePrice = str(strikePrice)
|
|
628
625
|
|
|
@@ -690,11 +687,41 @@ def derivative_history(symbol,start_date,end_date,instrumentType,expiry_date,str
|
|
|
690
687
|
return payload
|
|
691
688
|
|
|
692
689
|
|
|
693
|
-
def expiry_history(symbol,start_date="",end_date=""):
|
|
690
|
+
def expiry_history(symbol,start_date="",end_date="",type="options"):
|
|
694
691
|
if(end_date==""):end_date=end_date
|
|
695
692
|
nsefetch_url = "https://www.nseindia.com/api/historical/fo/derivatives/meta?&from="+start_date+"&to="+end_date+"&symbol="+symbol+""
|
|
696
693
|
payload = nsefetch(nsefetch_url)
|
|
697
|
-
|
|
694
|
+
|
|
695
|
+
print(payload)
|
|
696
|
+
|
|
697
|
+
for key, value in payload['expiryDatesByInstrument'].items():
|
|
698
|
+
if type.lower() == "options" and "OPT" in key:
|
|
699
|
+
payload_data = payload['expiryDatesByInstrument'][key]
|
|
700
|
+
break
|
|
701
|
+
elif type.lower() == "futures" and "FUT" in key:
|
|
702
|
+
payload_data = payload['expiryDatesByInstrument'][key]
|
|
703
|
+
break
|
|
704
|
+
|
|
705
|
+
# Convert start_date and end_date to datetime objects
|
|
706
|
+
start_date = datetime.datetime.strptime(start_date, "%d-%m-%Y")
|
|
707
|
+
end_date = datetime.datetime.strptime(end_date, "%d-%m-%Y")
|
|
708
|
+
|
|
709
|
+
# Initialize an empty list to store filtered dates
|
|
710
|
+
filtered_date_payload = []
|
|
711
|
+
|
|
712
|
+
# Initialize a flag to check if the first date after end_date has been added
|
|
713
|
+
added_after_end_date = False
|
|
714
|
+
|
|
715
|
+
# Iterate through date_payload and filter dates within the range
|
|
716
|
+
for date_str in payload_data:
|
|
717
|
+
date_obj = datetime.datetime.strptime(date_str, "%d-%b-%Y")
|
|
718
|
+
if start_date <= date_obj <= end_date:
|
|
719
|
+
filtered_date_payload.append(date_str)
|
|
720
|
+
elif date_obj > end_date and not added_after_end_date:
|
|
721
|
+
filtered_date_payload.append(date_str)
|
|
722
|
+
added_after_end_date = True
|
|
723
|
+
|
|
724
|
+
return filtered_date_payload
|
|
698
725
|
|
|
699
726
|
# # Nifty Indicies Site
|
|
700
727
|
|
|
@@ -899,4 +926,10 @@ def nse_expirydetails_by_symbol(symbol,meta ="Futures",i=0):
|
|
|
899
926
|
currentExpiry=expiry_dates[i]
|
|
900
927
|
currentExpiry = datetime.datetime.strptime(currentExpiry,'%d-%b-%Y').date()
|
|
901
928
|
dte = (currentExpiry - datetime.datetime.now().date()).days
|
|
902
|
-
return currentExpiry,dte
|
|
929
|
+
return currentExpiry,dte
|
|
930
|
+
|
|
931
|
+
def security_wise_archive(from_date, to_date, symbol, series="ALL"):
|
|
932
|
+
base_url = "https://www.nseindia.com/api/historical/securityArchives"
|
|
933
|
+
url = f"{base_url}?from={from_date}&to={to_date}&symbol={symbol.upper()}&dataType=priceVolumeDeliverable&series={series.upper()}"
|
|
934
|
+
payload = nsefetch(url)
|
|
935
|
+
return pd.DataFrame(payload['data'])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nsepython
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8
|
|
4
4
|
Summary: Python library for NSE India APIs
|
|
5
5
|
Home-page: https://github.com/aeron7/nsepython
|
|
6
6
|
Author: Aeron7
|
|
@@ -21,7 +21,7 @@ Requires-Dist: scipy
|
|
|
21
21
|
|
|
22
22
|
<p align="left">
|
|
23
23
|
<a href="https://aeron7.github.io/nsepython/" target="_blank">
|
|
24
|
-
<img width="300" src="https://
|
|
24
|
+
<img width="300" src="https://forum.unofficed.com/uploads/default/original/2X/1/146aad29b92adf82059eacba2feca24741c9f859.png" alt="logo">
|
|
25
25
|
</a>
|
|
26
26
|
</p>
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ Requires-Dist: scipy
|
|
|
29
29
|
|
|
30
30
|
<p align="left">
|
|
31
31
|
<a href="https://unofficed.com/nse-python/documentation/" target="_blank">
|
|
32
|
-
<img width="200" src="https://
|
|
32
|
+
<img width="200" src="https://forum.unofficed.com/uploads/default/original/2X/6/6b62554e8dc05701dab74b41e681e8b361e0f37f.png" alt="logo">
|
|
33
33
|
</a>
|
|
34
34
|
</p>
|
|
35
35
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
nsepython/__init__.py,sha256=smfUB46cZCC2tmcFMU6ry12PpWjKB4enB4Y5nNk_xBo,44
|
|
2
|
+
nsepython/rahu.py,sha256=5ex88ZVi00IzvYJsAroIytWHNK4RXsjDL7xsSY8oXR4,42111
|
|
3
|
+
nsepython-2.8.dist-info/LICENSE,sha256=7GKIR95QHGxZUfY_N5Or2XXBVRkLkyTRnZ_cLFyFw8s,35176
|
|
4
|
+
nsepython-2.8.dist-info/METADATA,sha256=IJMHgIttIYkT6ckdUpjzGKuC637BzlU72cBbNo-YkR8,7419
|
|
5
|
+
nsepython-2.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
6
|
+
nsepython-2.8.dist-info/top_level.txt,sha256=-hTS08c-pS4rPpiuzLkamRsgHTq7t6BG0M5wnU-iPy4,10
|
|
7
|
+
nsepython-2.8.dist-info/RECORD,,
|
nsepython-2.6.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
nsepython/__init__.py,sha256=smfUB46cZCC2tmcFMU6ry12PpWjKB4enB4Y5nNk_xBo,44
|
|
2
|
-
nsepython/rahu.py,sha256=Aw_2qk6aE2tI-hM7oReG8eDjhUergbxaC-EhX1xMXXk,40790
|
|
3
|
-
nsepython-2.6.dist-info/LICENSE,sha256=7GKIR95QHGxZUfY_N5Or2XXBVRkLkyTRnZ_cLFyFw8s,35176
|
|
4
|
-
nsepython-2.6.dist-info/METADATA,sha256=LN9SeH9RFFB__jdWn0jnobhlN_DYiqDy49LiUkL53F0,7377
|
|
5
|
-
nsepython-2.6.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
|
6
|
-
nsepython-2.6.dist-info/top_level.txt,sha256=-hTS08c-pS4rPpiuzLkamRsgHTq7t6BG0M5wnU-iPy4,10
|
|
7
|
-
nsepython-2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|