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"""
import sys
sys.path.insert(0, ".")
# Test 1: Merton model
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조
sigma_E = 0.30
D = 5_000_000_000_000 # 5조
r = 0.035
sol = solve_merton(E, sigma_E, D, r)
DD = calculate_dd(sol['V'], sol['sigma_V'], D, r=r)
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:
import urllib.request
import json
headers = {
"Authorization": "Bearer tk_070f8e0b715e818bb7178c3815ed5389040eddca",
"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:
print(f" Vikunja error: {e}")
# Test 3: pykrx
print("\n=== Test 3: pykrx ===")
try:
from pykrx import stock
tickers = stock.get_market_ticker_list("20260310", market="KOSPI")
print(f" pykrx connected! KOSPI tickers: {len(tickers)}")
except Exception as e:
print(f" pykrx error: {e}")
# Test 4: DART
print("\n=== Test 4: DART API ===")
try:
"""DART finstate test — stock code vs corp_code"""
import OpenDartReader
dart = OpenDartReader("ef6deb100be436aed88051fd4914dbdb58ff2e94")
corp_list = dart.corp_codes
listed = corp_list[corp_list["stock_code"].notna() & (corp_list["stock_code"] != " ")]
print(f" DART connected! Listed companies: {len(listed)}")
except Exception as e:
print(f" DART error: {e}")
import time
print("\n=== All tests complete ===")
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")