mmyjh86

[YouTube] 벡테스팅 - 지수수익률 - 데이터 다운로드

Sep 19th, 2020 (edited)
1,568
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2.  
  3. # 티커 조회
  4. tickers_kospi = stock.get_index_ticker_list()
  5. tickers_kosdaq = stock.get_index_ticker_list(market="kosdaq")
  6. tickers = tickers_kospi + tickers_kosdaq
  7.  
  8. # OHLCV 다운로드
  9. for ticker in tickers :
  10.     df = stock.get_index_ohlcv_by_date("19800101", "20200831", ticker)
  11.     df.to_excel(f'kospi_{ticker}.xlsx')
  12.    
  13.     time.sleep(1)   # 1초 대기
RAW Paste Data