Files
edf/test_setup.py

69 lines
2.1 KiB
Python

"""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:
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}")
print("\n=== All tests complete ===")