Fix APPL ticker typo and improve pre-run trade-date validation

This commit is contained in:
nornen0202 2026-04-08 04:45:07 +09:00
parent b9546ba123
commit d9cc210cb5
2 changed files with 34 additions and 2 deletions

View File

@ -1,5 +1,5 @@
[run]
tickers = ["GOOGL", "NVDA", "TSM", "APPL", "ETN", "LLY", "GLDM", "VRT", "TSLA", "GEV", "VXUS", "RSP", "FANG", "ETHU", "ORCL", "MU"]
tickers = ["GOOGL", "NVDA", "TSM", "AAPL", "ETN", "LLY", "GLDM", "VRT", "TSLA", "GEV", "VXUS", "RSP", "FANG", "ETHU", "ORCL", "MU"]
analysts = ["market", "social", "news", "fundamentals"]
output_language = "Korean"
trade_date_mode = "latest_available"

View File

@ -131,14 +131,22 @@ def resolve_trade_date(
if mode == "previous_business_day":
return _previous_business_day(now.date()).isoformat()
if not _looks_like_yahoo_ticker_format(normalized_symbol):
raise RuntimeError(
f"Could not resolve the latest available trade date for {ticker} ({normalized_symbol}); "
f"symbol format looks invalid for Yahoo Finance. Expected examples: AAPL, BRK.B, 005930.KS."
)
history = yf.Ticker(normalized_symbol).history(
period=f"{config.run.latest_market_data_lookback_days}d",
interval="1d",
auto_adjust=False,
)
if history.empty:
symbol_hint = _ticker_hint(normalized_symbol)
raise RuntimeError(
f"Could not resolve the latest available trade date for {ticker} ({normalized_symbol}); yfinance returned no rows."
f"Could not resolve the latest available trade date for {ticker} ({normalized_symbol}); "
f"yfinance returned no rows.{symbol_hint}"
)
last_index = history.index[-1]
@ -149,6 +157,30 @@ def resolve_trade_date(
return last_date.isoformat()
def _looks_like_yahoo_ticker_format(symbol: str) -> bool:
if not symbol:
return False
if symbol.count(".") > 1:
return False
if symbol[0] == "." or symbol[-1] == ".":
return False
for ch in symbol:
if not (ch.isalnum() or ch in ".-"):
return False
return True
def _ticker_hint(symbol: str) -> str:
normalized = symbol.upper()
common_typos = {
"APPL": " APPL is likely an invalid ticker; if you intended Apple, use 'AAPL'.",
}
return common_typos.get(
normalized,
" The symbol may be wrong (typo or delisted) or currently unavailable on Yahoo Finance.",
)
def _run_single_ticker(
*,
config: ScheduledAnalysisConfig,