コード例 #1
0
 def downloadIndexOptionChain(self):
     print(f"{arrow.now().to(self.tz).format('DD-MMM-YYYY HH:mm:ss')} : Downloading Index Option Chain", end='...', flush=True)
     df1 = self.getOptionChain('NIFTY')
     df2 = self.getOptionChain('BANKNIFTY')
     df = pd.concat([df1, df2], ignore_index=True)
     print('Completed')
     SqLite.appendtable(df, self.tbl_optionchain)
コード例 #2
0
ファイル: download.py プロジェクト: ajitisack/nsedata
 def downloadindicesltp(self):
     print(f'Downloading Current Price of All NSE Indices', end='...', flush=True)
     json_str = self.getjsonstr(self.url_symbolsltp)
     df = self.getindicesltp(json_str)
     df = Utility.reducesize(df)
     df['runts'] = arrow.now().format('ddd MMM-DD-YYYY HH:mm:ss')
     print(f'Completed !')
     SqLite.loadtable(df, self.tbl_symbolsltp)
コード例 #3
0
 def download(self, loadtotable):
     tblname = self.tbl_preopen
     print(f'Downloading NSE Pre-open prices', end='...', flush=True)
     data = self.getjsonstr()
     df = self.getnsepreopendf(data)
     df = Utility.reducesize(df)
     df['runts'] = arrow.now().format('ddd MMM-DD-YYYY HH:mm:ss')
     print(f'Completed !')
     if not loadtotable: return df
     SqLite.loadtable(df, tblname)
コード例 #4
0
ファイル: indices_symbols.py プロジェクト: ajitisack/nsedata
 def download(self, loadtotable):
     indices = self.readIndices('NSE')
     print(f'Downloading symbols of {indices.shape[0]} indices from nseindia.com', end='...', flush=True)
     params = zip(indices.exchange, indices.type, indices.name, indices.yfsymbol, indices.url)
     nthreads = min(indices.shape[0], int(self.maxthreads))
     with ThreadPoolExecutor(max_workers=nthreads) as executor:
         results = executor.map(self.getnseindexsymbols, params)
     df = pd.concat(list(results), ignore_index=True)
     df = self.processdf(df)
     print('Completed')
     if not loadtotable: return df
     SqLite.loadtable(df, self.tbl_indices)
コード例 #5
0
ファイル: download.py プロジェクト: ajitisack/nsedata
 def download(self, type, startdt=None, enddt=None):
     df = pd.DataFrame()
     dt = arrow.get(startdt) if startdt else self.getmaxdate(self.tbl[type])
     enddt = arrow.get(enddt) if enddt else arrow.now()
     dates = self.getworkingdays(dt, enddt)
     if not dates:
         print(f'{type} data - All upto date!')
         return None
     print(
         f"Downloading {self.msg[type]} data from {dt.format('YYYY-MMM-DD')} to {enddt.format('YYYY-MMM-DD')}"
     )
     dfs = [self.func[type](date) for date in dates]
     if dfs:
         df = pd.concat(dfs, ignore_index=True)
         df = Utility.adddatefeatures(df)
         df['runts'] = arrow.now().format('ddd MMM-DD-YYYY HH:mm:ss')
     if not df.empty: SqLite.appendtable(df, self.tbl[type])
     return None
コード例 #6
0
ファイル: download.py プロジェクト: ajitisack/nsedata
 def download(self, startdt=None, enddt=None):
     df = pd.DataFrame()
     dt = arrow.get(startdt) if startdt else self.getmaxdate(
         self.tbl_eqbhavcopy)
     enddt = arrow.get(enddt) if enddt else arrow.now()
     dates = self.getworkingdays(dt, enddt)
     if not dates:
         print('Indices Historical Prices - All upto date!')
         return None
     print(
         f"Downloading Equity Bhavcopy data from {dt.format('YYYY-MMM-DD')} to {enddt.format('YYYY-MMM-DD')}"
     )
     dfs = [self.getEquityBhavcopy(date) for date in dates]
     if dfs:
         df = pd.concat(dfs, ignore_index=True)
         df = Utility.adddatefeatures(df)
         df['runts'] = arrow.now().format('ddd MMM-DD-YYYY HH:mm:ss')
     if not df.empty: SqLite.appendtable(df, self.tbl_eqbhavcopy)
コード例 #7
0
    def download(self, n_symbols, loadtotable, startdt):
        symbols = self.getsymbols(n_symbols)
        print(
            f'Downloading historical prices(daily, weekly & monthly) and events from yahoo finance for {len(symbols)} NSE symbols from {startdt}',
            end='...',
            flush=True)
        data = self.downloadhistprice(symbols, startdt)

        dlyhistprice = pd.concat([pd.DataFrame(i[0]) for i in data],
                                 ignore_index=True)
        wlyhistprice = pd.concat([pd.DataFrame(i[1]) for i in data],
                                 ignore_index=True)
        mlyhistprice = pd.concat([pd.DataFrame(i[2]) for i in data],
                                 ignore_index=True)
        dividends = pd.concat([pd.DataFrame(i[3]) for i in data],
                              ignore_index=True)
        splits = pd.concat([pd.DataFrame(i[4]) for i in data],
                           ignore_index=True)
        events = pd.concat([dividends, splits], ignore_index=True)
        events = self.processdf(events).dropna()

        dlyhistprice = self.processdf(dlyhistprice).dropna()
        wlyhistprice = self.processdf(wlyhistprice).dropna()
        mlyhistprice = self.processdf(mlyhistprice).dropna()
        dlyhistprice = dlyhistprice.astype({'volume': int})
        wlyhistprice = wlyhistprice.astype({'volume': int})
        mlyhistprice = mlyhistprice.astype({'volume': int})

        print('Completed !')

        if not loadtotable:
            return dlyhistprice, wlyhistprice, mlyhistprice, events
        SqLite.loadtable(dlyhistprice, self.tbl_hpricedly)
        SqLite.loadtable(wlyhistprice, self.tbl_hpricewly)
        SqLite.loadtable(mlyhistprice, self.tbl_hpricemly)
        # SqLite.createindex(tbl_hprice, 'symbol')
        SqLite.loadtable(events, self.tbl_events)
コード例 #8
0
 def download(self):
     tblname = self.tbl_symbols
     print(f'Fetching list of all NSE Equities', end='...', flush=True)
     df = self.getallsymbols()
     print('Completed')
     SqLite.loadtable(df, tblname)