Files
momentum-system/research/multi_schema.py
T
momentum devandClaude Opus 4.8 9e730a3726 Remove DuckDB remnants (datastore is Postgres)
The duckdb library is already gone (not a dependency, not importable, no
`import duckdb` anywhere) — these were leftover text references that misled.

- Delete storage/schema.py: 418 lines of DuckDB DDL with zero importers. The
  Postgres schema is created by db_pg._apply_schema + event_store._ensure_schema.
- Neutralise stale default db_path strings (./data/momentum*.duckdb) in
  event_store, config, run_live_paper, dashboard_api — the connection layer
  ignores the path (DATABASE_URL is the datastore), so these phantom file paths
  only created confusion. Dropped the now-pointless os.makedirs for them.
- research/multi_schema: the "three DuckDB files" are one Postgres DB now (all
  resolve to the same connection); doc + constants updated to match reality.
- Fix stale "DuckDB handle" comments in api/main.

Kept the DuckDB mentions in storage/db_pg.py + storage/db.py — they document
why the Postgres facade mimics DuckDB's ? placeholders and :memory: semantics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 22:43:29 -04:00

36 lines
1.1 KiB
Python

"""Research data namespaces.
Historically three separate DuckDB files (market / news / signals). The datastore
is now a single Postgres database (see :mod:`storage.db_pg`), so these are logical
names that all resolve to the same connection — the layout is retained for
call-site compatibility.
"""
from __future__ import annotations
from pathlib import Path
from storage.db import get_connection
RESEARCH_DIR = Path("data/research")
# Logical research namespaces. The datastore is one Postgres DB and the
# connection layer ignores the path, so all three resolve to the same database.
DB_FILES = {
"market": "market",
"news": "news",
"signals": "signals",
}
def research_db_path(name: str, base_dir: str | Path | None = None) -> Path:
base = Path(base_dir) if base_dir else RESEARCH_DIR
filename = DB_FILES.get(name, name)
return base / filename
def open_research_db(name: str, base_dir: str | Path | None = None):
"""Open the research datastore (Postgres). ``name`` selects a logical
namespace but currently resolves to the same database."""
return get_connection(research_db_path(name, base_dir))