nsepython 2.6__tar.gz → 2.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nsepython
3
- Version: 2.6
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
@@ -15,10 +15,13 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
15
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
+ Requires-Dist: requests
19
+ Requires-Dist: pandas
20
+ Requires-Dist: scipy
18
21
 
19
22
  <p align="left">
20
23
  <a href="https://aeron7.github.io/nsepython/" target="_blank">
21
- <img width="300" src="https://raw.githubusercontent.com/aeron7/nsepython/master/nsepython.png" alt="logo">
24
+ <img width="300" src="https://forum.unofficed.com/uploads/default/original/2X/1/146aad29b92adf82059eacba2feca24741c9f859.png" alt="logo">
22
25
  </a>
23
26
  </p>
24
27
 
@@ -26,7 +29,7 @@ License-File: LICENSE
26
29
 
27
30
  <p align="left">
28
31
  <a href="https://unofficed.com/nse-python/documentation/" target="_blank">
29
- <img width="200" src="https://raw.githubusercontent.com/aeron7/nsepython/master/button_read-the-documentation.png" alt="logo">
32
+ <img width="200" src="https://forum.unofficed.com/uploads/default/original/2X/6/6b62554e8dc05701dab74b41e681e8b361e0f37f.png" alt="logo">
30
33
  </a>
31
34
  </p>
32
35
 
@@ -1,6 +1,6 @@
1
1
  <p align="left">
2
2
  <a href="https://aeron7.github.io/nsepython/" target="_blank">
3
- <img width="300" src="https://raw.githubusercontent.com/aeron7/nsepython/master/nsepython.png" alt="logo">
3
+ <img width="300" src="https://forum.unofficed.com/uploads/default/original/2X/1/146aad29b92adf82059eacba2feca24741c9f859.png" alt="logo">
4
4
  </a>
5
5
  </p>
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  <p align="left">
10
10
  <a href="https://unofficed.com/nse-python/documentation/" target="_blank">
11
- <img width="200" src="https://raw.githubusercontent.com/aeron7/nsepython/master/button_read-the-documentation.png" alt="logo">
11
+ <img width="200" src="https://forum.unofficed.com/uploads/default/original/2X/6/6b62554e8dc05701dab74b41e681e8b361e0f37f.png" alt="logo">
12
12
  </a>
13
13
  </p>
14
14
 
@@ -32,19 +32,13 @@ if(mode=='vpn'):
32
32
  return output
33
33
  if(mode=='local'):
34
34
  def nsefetch(payload):
35
- try: #Try the normal way.
35
+ try:
36
36
  output = requests.get(payload,headers=headers).json()
37
- except:
38
- try: # Follow Praty's hack as mentioned here at https://forum.unofficed.com/t/solution-equity-history-function-doesnt-work/1197
39
- output = requests.session().get(payload,headers=headers).json()
40
-
41
- except: #Mimick FrontPage Visit
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
- instrumentType="FUTIDX"
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
- return payload['data'][2]
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.6
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
@@ -15,10 +15,13 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
15
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
+ Requires-Dist: requests
19
+ Requires-Dist: pandas
20
+ Requires-Dist: scipy
18
21
 
19
22
  <p align="left">
20
23
  <a href="https://aeron7.github.io/nsepython/" target="_blank">
21
- <img width="300" src="https://raw.githubusercontent.com/aeron7/nsepython/master/nsepython.png" alt="logo">
24
+ <img width="300" src="https://forum.unofficed.com/uploads/default/original/2X/1/146aad29b92adf82059eacba2feca24741c9f859.png" alt="logo">
22
25
  </a>
23
26
  </p>
24
27
 
@@ -26,7 +29,7 @@ License-File: LICENSE
26
29
 
27
30
  <p align="left">
28
31
  <a href="https://unofficed.com/nse-python/documentation/" target="_blank">
29
- <img width="200" src="https://raw.githubusercontent.com/aeron7/nsepython/master/button_read-the-documentation.png" alt="logo">
32
+ <img width="200" src="https://forum.unofficed.com/uploads/default/original/2X/6/6b62554e8dc05701dab74b41e681e8b361e0f37f.png" alt="logo">
30
33
  </a>
31
34
  </p>
32
35
 
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
6
6
  setuptools.setup(
7
7
  name = 'nsepython',
8
8
  packages=setuptools.find_packages(),
9
- version = '2.6',
9
+ version = '2.8',
10
10
  include_package_data=True,
11
11
  description = 'Python library for NSE India APIs',
12
12
  long_description=long_description,
File without changes
File without changes
File without changes