eshan6704 commited on
Commit
680c92d
·
verified ·
1 Parent(s): a563891

Update nsepython.py

Browse files
Files changed (1) hide show
  1. nsepython.py +22 -3
nsepython.py CHANGED
@@ -1,6 +1,23 @@
1
- import os, sys, requests, pandas as pd, json, random, datetime, time, logging, re, urllib.parse
 
 
 
 
 
 
 
 
 
 
 
2
  from collections import Counter
3
 
 
 
 
 
 
 
4
  mode = 'local'
5
 
6
  # ------------------------- NSE FETCH -------------------------
@@ -238,15 +255,17 @@ def nse_csv_fetch(url):
238
 
239
  # ------------------------- INDEX HIGH-LOW CSV -------------------------
240
  def nse_highlow(date_str):
 
241
  url="https://archives.nseindia.com/content/indices/" f"ind_close_all_{date_str}.csv"
242
 
243
  return pd.read_csv(url, header=0)
244
 
245
  # ------------------------- STOCK 52-WEEK HIGH-LOW CSV -------------------------
246
  def stock_highlow(date_str):
247
- url="https://archives.nseindia.com/content/"f"CM_52_wk_High_low_{date_str}.csv"
 
248
 
249
- return pd.read_csv(url, header=2)
250
  # ------------------------- ZIP CSV FETCH -------------------------
251
  def nse_zip_csv_fetch(url):
252
  """
 
1
+ # ==============================
2
+ # Standard library imports
3
+ # ==============================
4
+ import os
5
+ import sys
6
+ import json
7
+ import random
8
+ import datetime
9
+ import time
10
+ import logging
11
+ import re
12
+ import urllib.parse
13
  from collections import Counter
14
 
15
+ # ==============================
16
+ # Third-party imports
17
+ # ==============================
18
+ import requests
19
+ import pandas as pd
20
+
21
  mode = 'local'
22
 
23
  # ------------------------- NSE FETCH -------------------------
 
255
 
256
  # ------------------------- INDEX HIGH-LOW CSV -------------------------
257
  def nse_highlow(date_str):
258
+ date_str = date_str.replace("-", "")
259
  url="https://archives.nseindia.com/content/indices/" f"ind_close_all_{date_str}.csv"
260
 
261
  return pd.read_csv(url, header=0)
262
 
263
  # ------------------------- STOCK 52-WEEK HIGH-LOW CSV -------------------------
264
  def stock_highlow(date_str):
265
+ date_str = date_str.replace("-", "")
266
+ url="https://archives.nseindia.com/content/"f"CM_52_wk_High_low_{date_str}.csv"
267
 
268
+ return pd.read_csv(url, header=2)
269
  # ------------------------- ZIP CSV FETCH -------------------------
270
  def nse_zip_csv_fetch(url):
271
  """