from datetime import date
from pykrx import stock
class Krx():
def __init__(self, parent=None):
super().__init__()
def get_market_trading_volume_by_date(self, from_dt=None, to_dt=None, code=None):
"""
당일 종가 업데이트
:return:
"""
# code = '005930' # 삼성전자
today = date.today()
if from_dt == None:
from_dt = today.strftime("%Y%m%d")
if to_dt == None:
to_dt = today.strftime("%Y%m%d")
try:
df = stock.get_market_trading_volume_by_date(from_dt, to_dt, code)
for ymd, row in df.iterrows():
print(row)
except ValueError as e:
print('I got a ValueError - reason "%s"' % str(e))
finally:
pass
if __name__ == "__main__":
krx = Krx()
krx.get_market_trading_volume_by_date('20230401', '20230407', '005930') # 당일 종가 정보 업데이트
기관합계 -1550689
기타법인 35898
개인 575196
외국인합계 939595
전체 0
Name: 2023-04-03 00:00:00, dtype: int64
기관합계 297976
기타법인 -68698
개인 -2096760
외국인합계 1867482
전체 0
Name: 2023-04-04 00:00:00, dtype: int64