From 567c5fc2cc7db4e560da914fd864557c25ace4fe Mon Sep 17 00:00:00 2001 From: ayuriel Date: Fri, 31 Jan 2025 09:00:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=2010=EC=9E=A5=20=EC=A2=85=ED=95=A9?= =?UTF-8?q?=EC=A3=BC=EA=B0=80=20=EC=A1=B0=ED=9A=8C=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/10-stock-data.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/example/10-stock-data.py b/example/10-stock-data.py index 27c114a..5dcea7f 100644 --- a/example/10-stock-data.py +++ b/example/10-stock-data.py @@ -87,8 +87,8 @@ def get_ind_stock_data(biz_day): def process_for_total_stock(biz_day): # 업종 분류 현황(코스피, 코스닥) - sector_stk = get_stock_data(biz_day, 'stk') - sector_ksq = get_stock_data(biz_day, 'ksq') + sector_stk = get_stock_data(biz_day, 'STK') + sector_ksq = get_stock_data(biz_day, 'KSQ') # 각각 조회 후 합침 krx_sector = pd.concat([sector_stk, sector_ksq]).reset_index(drop=True) krx_sector['종목명'] = krx_sector['종목명'].str.strip() @@ -102,14 +102,18 @@ def process_for_total_stock(biz_day): # 데이터 정리 # 종목, 개별 중 한군데만 있는 데이터 삭제(선박펀드, 광물펀드, 해외종목 등) diff = list(set(krx_sector['종목명']).symmetric_difference(set(krx_ind['종목명']))) - kor_ticker = pd.merge(krx_sector, krx_ind, on=krx_sector.columns.intersection(krx_ind.columns).tolist(), how='outer') + + kor_ticker = pd.merge(krx_sector, + krx_ind, + on=krx_sector.columns.intersection( + krx_ind.columns).tolist(), + how='outer') # 일반적인 종목과 SPAC, 우선주, 리츠, 기타 주식을 구분 kor_ticker['종목구분'] = np.where(kor_ticker['종목명'].str.contains('스팩|제[0-9]+호'), '스팩', - np.where(kor_ticker['종목코드'].str[-1:] != '0', '우선주', - np.where(kor_ticker['종목명'].str.endswith('리츠'), '리츠', - np.where(kor_ticker['종목명'].isin(diff), '기타', - '보통주' - )))) + np.where(kor_ticker['종목코드'].str[-1:] != '0', '우선주', + np.where(kor_ticker['종목명'].str.endswith('리츠'), '리츠', + np.where(kor_ticker['종목명'].isin(diff), '기타', + '보통주')))) kor_ticker = kor_ticker.reset_index(drop=True) kor_ticker.columns = kor_ticker.columns.str.replace(' ', '') kor_ticker = kor_ticker[['종목코드', '종목명', '시장구분', '종가', @@ -197,4 +201,4 @@ def save_sector(sector): if __name__ == '__main__': latest_biz_day = get_latest_biz_day() process_for_total_stock(latest_biz_day) - process_for_wics(latest_biz_day) + # process_for_wics(latest_biz_day)