- PLAN.md: full implementation plan from issue - config.py: configurable thresholds, API keys via .env - ingestion/: EDGAR RSS poller + Form 4 XML parser - db/: SQLite schema + interface (WAL mode) - signals/: filter engine (buy/10b5-1/value/role) + cluster detector - alerts/: Slack webhook alert with score gating - broker/: Alpaca paper/live trade execution - backtest/: historical signal backtesting with yfinance - main.py: CLI entrypoint (run | fetch-once | backtest)
14 lines
422 B
Python
14 lines
422 B
Python
from db.db import get_recent_buys_for_ticker
|
|
import config
|
|
|
|
|
|
def detect_cluster(ticker: str) -> dict:
|
|
buys = get_recent_buys_for_ticker(ticker, config.CLUSTER_WINDOW_DAYS)
|
|
unique_insiders = {b["insider_name"] for b in buys}
|
|
total_value = sum(b["total_value"] or 0 for b in buys)
|
|
return {
|
|
"cluster_size": len(unique_insiders),
|
|
"total_cluster_value": total_value,
|
|
"buys": buys,
|
|
}
|