def make_index_dict(d: date, market: str = None): if market: tickers = stock.get_index_ticker_list(date_to_str(d), market=market) else: tickers = stock.get_index_ticker_list(date_to_str(d)) return {ticker: stock.get_index_ticker_name(ticker) for ticker in tickers}
async def index_list(qDate: Optional[str] = None): result = [] date = getRecentDay() if qDate: date = qDate for ticker in stock.get_index_ticker_list(date): result.append({ticker: stock.get_index_ticker_name(ticker)}) return {"data": result}
def test_index_list_for_a_specific_day(self): tickers = stock.get_index_ticker_list('20210118') self.assertIsInstance(tickers, list) self.assertGreater(len(tickers), 0) self.assertEqual(tickers[0], '1001')
def test_index_list_in_theme(self): tickers = stock.get_index_ticker_list('20210130', '테마') self.assertIsInstance(tickers, list) self.assertGreater(len(tickers), 0) self.assertEqual(tickers[0], '1163')
def test_index_list_in_kosdaq(self): tickers = stock.get_index_ticker_list('20210130', 'KOSDAQ') self.assertIsInstance(tickers, list) self.assertGreater(len(tickers), 0) self.assertEqual(tickers[0], '2001')
def get_index(): kospi_index = stock.get_index_ticker_list(market='KOSPI') kosdaq_index = stock.get_index_ticker_list(market='KOSDAQ') time.sleep(1) return kospi_index, kosdaq_index
def test_index_list_for_a_holiday(self): tickers = stock.get_index_ticker_list('20210130') self.assertIsInstance(tickers, list) self.assertEqual(len(tickers), 46) self.assertEqual(tickers[0], '1001')
def test_io_with_default_param(self): tickers = stock.get_index_ticker_list() self.assertIsInstance(tickers, list) self.assertNotEqual(len(tickers), 0)