"""DART finstate test — stock code vs corp_code""" import OpenDartReader import time dart = OpenDartReader("ef6deb100be436aed88051fd4914dbdb58ff2e94") # Test: finstate with stock code directly print("=== DART finstate with stock code directly ===") for code, name in [("005930", "삼성전자"), ("000660", "SK하이닉스"), ("036720", "한볼트")]: try: fs = dart.finstate(code, 2024) time.sleep(0.5) n = len(fs) if fs is not None else 0 print(f" {code} {name}: {n} rows") except Exception as e: print(f" {code} {name}: ERROR {e}") # Test: finstate_all — bulk download per corp_code print("\n=== DART finstate_all (삼성전자 00126380) ===") try: fs = dart.finstate_all("00126380", 2024) time.sleep(0.5) n = len(fs) if fs is not None else 0 print(f" 삼성전자 finstate_all: {n} rows") except Exception as e: print(f" ERROR: {e}") # Test: KOSPI major — find their corp_codes and try finstate print("\n=== DART finstate loop with known-good corp_codes ===") corp_codes = dart.corp_codes for ticker in ["005930", "000660", "005380", "036720", "040130"]: match = corp_codes[corp_codes["stock_code"] == ticker] if len(match) > 0: cc = match.iloc[0]["corp_code"] cn = match.iloc[0]["corp_name"] try: fs = dart.finstate(cc, 2024) time.sleep(0.5) n = len(fs) if fs is not None else 0 print(f" {ticker} {cn} (corp={cc}): {n} rows") except Exception as e: print(f" {ticker} {cn}: ERROR {e}") else: print(f" {ticker}: Not found in corp_codes")