-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbatch_bond_analytics.py
More file actions
61 lines (45 loc) · 1.84 KB
/
Copy pathbatch_bond_analytics.py
File metadata and controls
61 lines (45 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Batch bond-analytics CLI entry point.
Computes bond analytics for one or more issuers over a trade-date range and
writes the results directly into ``bond_analytics_db`` (``quant_cache_db`` is
never touched). Shows a themed progress GUI by default; pass ``--no-gui`` for
a plain console progress bar.
Run with uv (recommended)::
uv run batch_bond_analytics.py --config ./config/cqfi.yaml \\
--issuer FRA ITA --start 2020-01-01 --end 2020-12-31
If you execute this file directly from an IDE, it will re-launch using
``.venv`` when that environment exists (created by ``uv sync``) — same as
``main.py``.
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
VENV_PYTHON = ROOT / ".venv" / ("Scripts/python.exe" if sys.platform == "win32" else "bin/python")
def _ensure_venv() -> None:
"""Re-exec with the project venv when the package is not importable."""
try:
import cqfi # noqa: F401
return
except ModuleNotFoundError:
pass
if VENV_PYTHON.is_file() and Path(sys.executable).resolve() != VENV_PYTHON.resolve():
sys.exit(subprocess.call([str(VENV_PYTHON), str(Path(__file__).resolve()), *sys.argv[1:]]))
print(
"cqfi is not installed in this Python environment.\n"
"\n"
"This is a uv project — sync and run via uv:\n"
"\n"
" uv sync\n"
" uv run batch_bond_analytics.py --issuer FRA --start 2020-01-01 --end 2020-01-31\n"
"\n"
f"Current interpreter: {sys.executable}\n"
f"Expected venv: {VENV_PYTHON}\n",
file=sys.stderr,
)
sys.exit(1)
_ensure_venv()
import cqfi.config # noqa: F401,E402 — disable LangSmith before langchain loads
from cqfi.batch.cli import main # noqa: E402
if __name__ == "__main__":
sys.exit(main())