Prune profile payload for options thesis
This commit is contained in:
@@ -8,24 +8,18 @@ import urllib.request
|
||||
DEFAULT_SYMBOLS = ["AAPL", "AMZN", "MSFT", "TSLA"]
|
||||
|
||||
REQUIRED_SECTIONS = [
|
||||
"company_profile",
|
||||
"summary_detail",
|
||||
"default_key_statistics",
|
||||
"financial_data",
|
||||
"price",
|
||||
"key_metrics",
|
||||
"recommendation_trend",
|
||||
"upgrade_downgrade_history",
|
||||
"valuation",
|
||||
"profitability",
|
||||
"growth",
|
||||
"financial_strength",
|
||||
"cashflow",
|
||||
"ownership",
|
||||
"analyst",
|
||||
"earnings",
|
||||
"calendar_events",
|
||||
"equity_performance",
|
||||
"performance_overview",
|
||||
"quote",
|
||||
"quote_type",
|
||||
"recent_news",
|
||||
"performance",
|
||||
]
|
||||
|
||||
REQUIRED_COMPANY_FIELDS = ["longBusinessSummary", "industry", "sector"]
|
||||
REQUIRED_KEY_METRICS = [
|
||||
"previous_close",
|
||||
"open",
|
||||
@@ -53,15 +47,16 @@ def parse_list(value, default):
|
||||
|
||||
def build_signature(data):
|
||||
return {
|
||||
"company_profile_keys": sorted(data.get("company_profile", {}).keys()),
|
||||
"summary_detail_keys": sorted(data.get("summary_detail", {}).keys()),
|
||||
"default_key_statistics_keys": sorted(
|
||||
data.get("default_key_statistics", {}).keys()
|
||||
),
|
||||
"financial_data_keys": sorted(data.get("financial_data", {}).keys()),
|
||||
"price_keys": sorted(data.get("price", {}).keys()),
|
||||
"key_metrics_keys": sorted(data.get("key_metrics", {}).keys()),
|
||||
"data_sources_keys": sorted(data.get("data_sources", {}).keys()),
|
||||
"valuation_keys": sorted(data.get("valuation", {}).keys()),
|
||||
"profitability_keys": sorted(data.get("profitability", {}).keys()),
|
||||
"growth_keys": sorted(data.get("growth", {}).keys()),
|
||||
"financial_strength_keys": sorted(data.get("financial_strength", {}).keys()),
|
||||
"cashflow_keys": sorted(data.get("cashflow", {}).keys()),
|
||||
"ownership_keys": sorted(data.get("ownership", {}).keys()),
|
||||
"analyst_keys": sorted(data.get("analyst", {}).keys()),
|
||||
"earnings_keys": sorted(data.get("earnings", {}).keys()),
|
||||
"performance_keys": sorted(data.get("performance", {}).keys()),
|
||||
}
|
||||
|
||||
|
||||
@@ -80,19 +75,11 @@ def validate_payload(symbol, data):
|
||||
if section not in data:
|
||||
return f"Missing section {section} for {symbol}"
|
||||
|
||||
company_profile = data.get("company_profile", {})
|
||||
for field in REQUIRED_COMPANY_FIELDS:
|
||||
if field not in company_profile:
|
||||
return f"Missing company field {field} for {symbol}"
|
||||
|
||||
key_metrics = data.get("key_metrics", {})
|
||||
for field in REQUIRED_KEY_METRICS:
|
||||
if field not in key_metrics:
|
||||
return f"Missing key metric {field} for {symbol}"
|
||||
|
||||
if not data.get("news_summary") and not data.get("recent_news"):
|
||||
return f"Missing news summary and recent news for {symbol}"
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user