fix(quant): eliminate all synthetic market/timeseries data, use 100% real exchange bars, and report 'No data available' when absent (v2.0.23)

This commit is contained in:
Hermes Agent committed 2026-11-30 08:36:06 +00:00
1 parent 9716a0ab61
commit 922f485388
27 files changed
+24021 -17509

No files matched your search

+34 -27
View File
@@ -130,24 +130,26 @@ CREATE INDEX IF NOT EXISTS idx_eq_date ON archive_equations(date_utc) WHERE da
CREATE TABLE IF NOT EXISTS quant_timeseries_bars (
symbol TEXT NOT NULL,
date_utc TEXT NOT NULL,
data_available INTEGER NOT NULL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'No data available',
entity_eng TEXT NOT NULL,
entity_ing TEXT NOT NULL,
entity_ing_aq INTEGER NOT NULL,
guilds_csv TEXT NOT NULL,
tradingview_symbol TEXT NOT NULL,
tradingview_url TEXT NOT NULL,
close_usd REAL NOT NULL,
change_pct REAL NOT NULL,
change_bps INTEGER NOT NULL,
volume_ratio_20d REAL NOT NULL,
close_usd REAL,
change_pct REAL,
change_bps INTEGER,
volume_ratio_20d REAL,
market_cap_str TEXT NOT NULL,
close_digit_aq INTEGER NOT NULL,
close_digit_aq INTEGER,
close_spoken_ing TEXT NOT NULL,
close_spoken_ing_aq INTEGER NOT NULL,
scaled_cap_spoken_ing_aq INTEGER NOT NULL,
bps_spoken_ing_aq INTEGER NOT NULL,
close_spoken_ing_aq INTEGER,
scaled_cap_spoken_ing_aq INTEGER,
bps_spoken_ing_aq INTEGER,
co_present_in_news_wire INTEGER NOT NULL,
contingent_points REAL NOT NULL,
contingent_points REAL,
locks_json TEXT NOT NULL,
PRIMARY KEY (symbol, date_utc)
) WITHOUT ROWID;
@@ -585,34 +587,36 @@ def build_catalog_sqlite_db(db_path: Path | str | None = None) -> dict[str, Any]
conn.execute(
"""
INSERT OR REPLACE INTO quant_timeseries_bars (
symbol, date_utc, entity_eng, entity_ing, entity_ing_aq, guilds_csv,
symbol, date_utc, data_available, status, entity_eng, entity_ing, entity_ing_aq, guilds_csv,
tradingview_symbol, tradingview_url, close_usd, change_pct, change_bps,
volume_ratio_20d, market_cap_str, close_digit_aq, close_spoken_ing,
close_spoken_ing_aq, scaled_cap_spoken_ing_aq, bps_spoken_ing_aq,
co_present_in_news_wire, contingent_points, locks_json
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
sym,
str(bar["date_utc"]),
1 if bar.get("data_available") else 0,
str(bar.get("status") or ("ok" if bar.get("data_available") else "No data available")),
ent_eng,
ent_ing,
ent_aq,
guilds_csv,
tv_sym,
tv_url,
float(bar["close_usd"]),
float(bar["change_pct"]),
int(bar["change_bps"]),
float(bar["volume_ratio_20d"]),
str(bar.get("market_cap_str", mcap_str)),
int(bar["close_digit_aq"]),
str(bar["close_spoken_ing"]),
int(bar["close_spoken_ing_aq"]),
int(bar["scaled_cap_spoken_ing_aq"]),
int(bar["bps_spoken_ing_aq"]),
float(bar["close_usd"]) if bar.get("close_usd") is not None else None,
float(bar["change_pct"]) if bar.get("change_pct") is not None else None,
int(bar["change_bps"]) if bar.get("change_bps") is not None else None,
float(bar["volume_ratio_20d"]) if bar.get("volume_ratio_20d") is not None else None,
str(bar.get("market_cap_str") or "No data available"),
int(bar["close_digit_aq"]) if bar.get("close_digit_aq") is not None else None,
str(bar.get("close_spoken_ing") or "No data available"),
int(bar["close_spoken_ing_aq"]) if bar.get("close_spoken_ing_aq") is not None else None,
int(bar["scaled_cap_spoken_ing_aq"]) if bar.get("scaled_cap_spoken_ing_aq") is not None else None,
int(bar["bps_spoken_ing_aq"]) if bar.get("bps_spoken_ing_aq") is not None else None,
1 if bar.get("co_present_in_news_wire") else 0,
float(bar.get("contingent_points", 0.0)),
float(bar["contingent_points"]) if bar.get("contingent_points") is not None else None,
json.dumps(locks_payload, ensure_ascii=False),
),
)
@@ -785,13 +789,16 @@ def query_timeseries_bars(
symbol: str | None = None,
start_date: str | None = None,
end_date: str | None = None,
min_points: float = 0.0,
min_points: float | None = None,
db_path: Path | str | None = None,
) -> list[dict[str, Any]]:
conn = _open_readonly_catalog(db_path)
try:
clauses = ["contingent_points >= ?"]
params: list[Any] = [float(min_points)]
clauses: list[str] = []
params: list[Any] = []
if min_points is not None:
clauses.append("contingent_points IS NOT NULL AND contingent_points >= ?")
params.append(float(min_points))
if symbol:
clauses.append("UPPER(symbol) = ?")
params.append(symbol.strip().upper())
@@ -801,9 +808,9 @@ def query_timeseries_bars(
if end_date:
clauses.append("date_utc <= ?")
params.append(end_date.strip())
where_sql = " AND ".join(clauses)
where_sql = (" WHERE " + " AND ".join(clauses)) if clauses else ""
rows = conn.execute(
f"SELECT * FROM quant_timeseries_bars WHERE {where_sql} ORDER BY date_utc DESC, symbol ASC",
f"SELECT * FROM quant_timeseries_bars{where_sql} ORDER BY date_utc DESC, symbol ASC",
params,
).fetchall()
return [dict(r) for r in rows]