fix(dataflows): bound insider filings and prediction markets by the trade date

- insider transactions are filtered to filings on or before the run date
- prediction-market odds are withheld from a historical run
This commit is contained in:
Yijia-Xiao
2026-09-15 00:00:26 +00:00
parent 29e331a9af
commit fadc698e20
6 changed files with 123 additions and 6 deletions

View File

@@ -15,6 +15,8 @@ from datetime import datetime, timezone
import requests
from .utils import get_current_date
logger = logging.getLogger(__name__)
GAMMA_BASE = "https://gamma-api.polymarket.com"
@@ -65,7 +67,7 @@ def _is_forward_looking(market: dict, now: datetime) -> bool:
)
def get_prediction_markets(topic: str, limit: int | None = None) -> str:
def get_prediction_markets(topic: str, limit: int | None = None, curr_date: str | None = None) -> str:
"""Return live prediction-market probabilities for an event topic.
Args:
@@ -73,12 +75,20 @@ def get_prediction_markets(topic: str, limit: int | None = None) -> str:
"US election", or a sector/company event.
limit: Max markets to return (ranked by traded volume); ``None`` uses
DEFAULT_LIMIT.
curr_date: The analysis date. Polymarket serves only live odds, so a
date before today withholds them.
Returns:
A markdown report of the most-traded open markets matching the topic,
each with its implied probability, traded volume, resolution date, and
recent (1-week) move.
"""
if curr_date and curr_date < get_current_date():
return (
f"Prediction-market odds are withheld for {curr_date}. Polymarket serves "
f"only live odds on open markets, with no historical vintage, so serving "
f"them would put post-decision information into a {curr_date} analysis."
)
if limit is None:
limit = DEFAULT_LIMIT