Ejemplo n.º 1
0
 def test_index_csv(self):    
     from_date = date(2001,1,15)
     to_date = date(2001,6,15)
     raw = nse.index_raw("NIFTY 50", from_date, to_date)
     output = nse.index_csv("NIFTY 50", from_date, to_date)
     with open(output) as fp:
         text = fp.read()
         rows = [x.split(',') for x in text.split('\n')]
         assert rows[1][2] == raw[0]['OPEN']
Ejemplo n.º 2
0
 def test_index_df(self):    
     from_date = date(2001,3,15)
     to_date = date(2001,6,15)
     raw = nse.index_raw("NIFTY 50", from_date, to_date)
     df = nse.index_df("NIFTY 50", from_date, to_date)
     print(df.head())
     assert float(raw[0]['OPEN']) == df.iloc[0]['OPEN']    
     assert float(raw[0]['CLOSE']) == df.iloc[0]['CLOSE']    
     assert df.iloc[0]['HistoricalDate'] == date(2001,6,15)
Ejemplo n.º 3
0
 def test_index_raw(self):
     symbol = "NIFTY 50"
     from_date = date(2020, 6, 1)
     to_date = date(2020, 7, 30) 
     d = nse.index_raw(symbol, from_date, to_date)
     assert d[0]['Index Name'] == 'Nifty 50'
     assert d[0]['HistoricalDate'] == '30 Jul 2020'
     assert d[-1]['HistoricalDate'] == '01 Jun 2020'
     app_name = nse.APP_NAME + '-index'
     files = os.listdir(user_cache_dir(app_name, app_name))
     assert len(files) == 2