feat(data): collect_all pipeline + 2609 KRX tickers + 2497 DART financials

This commit is contained in:
EDF Agent
2026-03-11 23:14:48 +09:00
parent a20a7207c4
commit e4b2c02ab1

View File

@@ -1,68 +1,44 @@
"""Quick test: Merton model + Vikunja connectivity""" """DART finstate test — stock code vs corp_code"""
import sys import OpenDartReader
sys.path.insert(0, ".") import time
# Test 1: Merton model dart = OpenDartReader("ef6deb100be436aed88051fd4914dbdb58ff2e94")
print("=== Test 1: Merton Model ===")
from src.models.merton import solve_merton, calculate_dd, calculate_edf, dd_to_rating
E = 10_000_000_000_000 # 10조 # Test: finstate with stock code directly
sigma_E = 0.30 print("=== DART finstate with stock code directly ===")
D = 5_000_000_000_000 # 5조 for code, name in [("005930", "삼성전자"), ("000660", "SK하이닉스"), ("036720", "한볼트")]:
r = 0.035 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}")
sol = solve_merton(E, sigma_E, D, r) # Test: finstate_all — bulk download per corp_code
DD = calculate_dd(sol['V'], sol['sigma_V'], D, r=r) print("\n=== DART finstate_all (삼성전자 00126380) ===")
EDF = calculate_edf(DD)
rating = dd_to_rating(DD)
print(f" V = {sol['V']/1e12:.2f}")
print(f" sigma_V = {sol['sigma_V']:.4f}")
print(f" DD = {DD:.4f}")
print(f" EDF = {EDF:.6f} ({EDF*100:.4f}%)")
print(f" Rating = {rating}")
print(f" Converged: {sol['converged']}, Method: {sol['method']}")
# Test 2: Vikunja
print("\n=== Test 2: Vikunja Connectivity ===")
try: try:
import urllib.request fs = dart.finstate_all("00126380", 2024)
import json time.sleep(0.5)
headers = { n = len(fs) if fs is not None else 0
"Authorization": "Bearer tk_070f8e0b715e818bb7178c3815ed5389040eddca", print(f" 삼성전자 finstate_all: {n} rows")
"Content-Type": "application/json",
}
req = urllib.request.Request(
"https://plan.variet.net/api/v1/projects/11/tasks?per_page=5",
headers=headers
)
with urllib.request.urlopen(req) as resp:
tasks = json.loads(resp.read().decode("utf-8"))
print(f" Vikunja connected! {len(tasks)} tasks found")
for t in tasks:
status = "done" if t["done"] else "todo"
print(f" #{t['id']} [{status}] {t['title']}")
except Exception as e: except Exception as e:
print(f" Vikunja error: {e}") print(f" ERROR: {e}")
# Test 3: pykrx # Test: KOSPI major — find their corp_codes and try finstate
print("\n=== Test 3: pykrx ===") print("\n=== DART finstate loop with known-good corp_codes ===")
try: corp_codes = dart.corp_codes
from pykrx import stock for ticker in ["005930", "000660", "005380", "036720", "040130"]:
tickers = stock.get_market_ticker_list("20260310", market="KOSPI") match = corp_codes[corp_codes["stock_code"] == ticker]
print(f" pykrx connected! KOSPI tickers: {len(tickers)}") if len(match) > 0:
except Exception as e: cc = match.iloc[0]["corp_code"]
print(f" pykrx error: {e}") cn = match.iloc[0]["corp_name"]
try:
# Test 4: DART fs = dart.finstate(cc, 2024)
print("\n=== Test 4: DART API ===") time.sleep(0.5)
try: n = len(fs) if fs is not None else 0
import OpenDartReader print(f" {ticker} {cn} (corp={cc}): {n} rows")
dart = OpenDartReader("ef6deb100be436aed88051fd4914dbdb58ff2e94") except Exception as e:
corp_list = dart.corp_codes print(f" {ticker} {cn}: ERROR {e}")
listed = corp_list[corp_list["stock_code"].notna() & (corp_list["stock_code"] != " ")] else:
print(f" DART connected! Listed companies: {len(listed)}") print(f" {ticker}: Not found in corp_codes")
except Exception as e:
print(f" DART error: {e}")
print("\n=== All tests complete ===")