aether-quant 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aether_quant-0.0.1.dist-info/METADATA +7 -0
- aether_quant-0.0.1.dist-info/RECORD +99 -0
- aether_quant-0.0.1.dist-info/WHEEL +5 -0
- aether_quant-0.0.1.dist-info/entry_points.txt +2 -0
- aether_quant-0.0.1.dist-info/licenses/LICENSE +133 -0
- aether_quant-0.0.1.dist-info/top_level.txt +13 -0
- analyzer/README.md +69 -0
- analyzer/__init__.py +17 -0
- analyzer/market_analyzer.py +521 -0
- aq_cli.py +3633 -0
- audit/README.md +47 -0
- audit/__init__.py +38 -0
- audit/hash_chain.py +52 -0
- audit/postgres_audit.py +61 -0
- audit/postgres_worker.py +402 -0
- audit/redis_queue.py +124 -0
- audit/status_export.py +62 -0
- data_pipeline/README.md +257 -0
- data_pipeline/__init__.py +6 -0
- data_pipeline/bar_synthesis.py +97 -0
- data_pipeline/dividend_backfill.py +243 -0
- data_pipeline/factor_file_backfill.py +276 -0
- data_pipeline/fetch.py +206 -0
- data_pipeline/fred_backfill.py +435 -0
- data_pipeline/ib_backfill.py +287 -0
- data_pipeline/v2_manifest.py +75 -0
- data_pipeline/yfinance_backfill.py +501 -0
- evaluation/README.md +152 -0
- evaluation/__init__.py +73 -0
- evaluation/ablation.py +310 -0
- evaluation/benchmark_comparison.py +195 -0
- evaluation/confidence_threshold_calibration.py +157 -0
- evaluation/factor_neutralization_check.py +94 -0
- evaluation/feature_parity.py +321 -0
- evaluation/feature_reconciliation.py +286 -0
- evaluation/impact_model.py +77 -0
- evaluation/kill_switch_replay.py +186 -0
- evaluation/limit_fill_simulator.py +152 -0
- evaluation/model_predictions.py +192 -0
- evaluation/monte_carlo.py +161 -0
- evaluation/public_benchmarks.py +117 -0
- evaluation/rank_book_simulator.py +494 -0
- evaluation/rank_ic_core.py +204 -0
- evaluation/rank_signal_calibration.py +690 -0
- evaluation/rolling_ic_gate_calibration.py +190 -0
- evaluation/rolling_ic_gate_replay.py +138 -0
- execution/README.md +281 -0
- execution/__init__.py +80 -0
- execution/config_cache.py +48 -0
- execution/cost_model.py +213 -0
- execution/lean_config_render.py +131 -0
- execution/live_credentials.py +38 -0
- execution/live_credentials_io.py +52 -0
- execution/order_gate.py +388 -0
- execution/paper_readiness.py +181 -0
- execution/paper_readiness_io.py +54 -0
- execution/paper_readiness_report.py +103 -0
- execution/paper_readiness_scheduler.py +137 -0
- execution/reconciliation.py +160 -0
- execution/runtime_config_io.py +38 -0
- execution/secret_scan.py +73 -0
- features/README.md +77 -0
- features/__init__.py +137 -0
- features/alt_data_features.py +154 -0
- features/bond_features.py +275 -0
- features/cross_asset_sensitivity.py +79 -0
- features/derivatives_macro_features.py +72 -0
- features/macro_features.py +79 -0
- features/options_greeks.py +329 -0
- features/sector_map.py +53 -0
- features/technical_indicators.py +185 -0
- generate_backtest_report.py +311 -0
- generate_evaluation_report.py +712 -0
- inference/README.md +105 -0
- inference/__init__.py +36 -0
- inference/exported_model.py +929 -0
- inference/parallel_inference.py +160 -0
- inference/strategy_selector_inference.py +75 -0
- json_safety.py +130 -0
- portfolio/README.md +447 -0
- portfolio/__init__.py +41 -0
- portfolio/book_construction.py +786 -0
- portfolio/book_neutrality.py +178 -0
- portfolio/hrp_allocation.py +159 -0
- portfolio/options_arbitrage_detector.py +232 -0
- portfolio/options_assignment_risk.py +119 -0
- portfolio/options_margin_sizing.py +333 -0
- portfolio/options_strategy.py +1999 -0
- portfolio/rank_signal.py +219 -0
- portfolio/rolling_ic_gate.py +183 -0
- risk/README.md +275 -0
- risk/__init__.py +38 -0
- risk/asset_class_router.py +584 -0
- risk/forex_risk.py +158 -0
- risk/futures_risk.py +202 -0
- risk/kill_switch.py +261 -0
- risk/manual_override.py +118 -0
- risk/position_sizing.py +303 -0
- risk/rl_sizing.py +189 -0
inference/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# inference
|
|
2
|
+
|
|
3
|
+
Pure, Lean-free forward-pass interpreter for the JSON-exported neural
|
|
4
|
+
network models (`ml/model_weights.json` and each
|
|
5
|
+
`ml/expert_models/<name>/model_weights.json`). No `AlgorithmImports`/
|
|
6
|
+
`QCAlgorithm` dependency and no `self.*` state — free functions only,
|
|
7
|
+
fully unit-testable without a Lean runtime. `main.py`'s `_run_model()`/
|
|
8
|
+
`_run_expert_models()`/`_run_multitask_model()`/`_run_sequence_model()` are
|
|
9
|
+
thin call sites over this package.
|
|
10
|
+
|
|
11
|
+
## Modules
|
|
12
|
+
|
|
13
|
+
- `exported_model.py` — the interpreter core (all entry points below).
|
|
14
|
+
- `parallel_inference.py` — opt-in per-symbol multiprocessing for
|
|
15
|
+
`main.py::on_data()`'s Pass 1 inference cluster
|
|
16
|
+
(`phase_v2.inference_parallelism.enabled`, default `false`). Measured
|
|
17
|
+
dramatically slower than sequential at real universe scale on Windows'
|
|
18
|
+
`spawn` start method (see `aq profile --parallel`); kept as an opt-in
|
|
19
|
+
for hosts where that tradeoff differs.
|
|
20
|
+
- `strategy_selector_inference.py` — torch-free scoring for the learned
|
|
21
|
+
options **strategy-selector model** (`ml/strategy_selector_model.json`
|
|
22
|
+
once `train_strategy_selector.py` has produced one):
|
|
23
|
+
`build_strategy_selector_features()` assembles the per-symbol feature
|
|
24
|
+
row and `score_strategies()` ranks the 43 registered option strategies.
|
|
25
|
+
Consumed by `main.py` and surfaced on the webui's Options & Strategy
|
|
26
|
+
page; realistically dormant until real option positions trade (see
|
|
27
|
+
`train_strategy_selector.py`'s module docstring).
|
|
28
|
+
|
|
29
|
+
## Entry points (exported_model.py)
|
|
30
|
+
|
|
31
|
+
- `run_exported_model(model_export, inputs)` — walks a flat
|
|
32
|
+
`{"architecture": [...], "state_dict": {...}}` layer list (`linear`,
|
|
33
|
+
`layernorm`, `relu`, `dropout`, `sigmoid`) and returns one scalar.
|
|
34
|
+
Fully vectorized numpy.
|
|
35
|
+
- `run_exported_multitask_model(model_export, inputs) -> dict[str, float]`
|
|
36
|
+
— for the joint direction+magnitude+volatility model
|
|
37
|
+
(`ml/multitask_model.json`). Consumes the branching
|
|
38
|
+
`{"trunk": [...], "heads": {"direction": [...], "magnitude": [...],
|
|
39
|
+
"volatility": [...]}}` export (NOT interchangeable with the flat
|
|
40
|
+
export); runs the trunk once, each head independently. `_softplus`
|
|
41
|
+
guarantees the volatility head is `>= 0`; the direction head ends in
|
|
42
|
+
`_sigmoid`; magnitude is raw regression.
|
|
43
|
+
- `run_exported_sequence_multitask_model(model_export, sequence) ->
|
|
44
|
+
dict[str, float]` — the causal-TCN sequence encoder
|
|
45
|
+
(`ml/sequence_model.json`). Takes a `(window, features)` matrix
|
|
46
|
+
(`sequence[-1]` = current bar); trunk layers are
|
|
47
|
+
`conv1d_causal`/`relu`/`dropout`, pooled at the most-recent (causal)
|
|
48
|
+
timestep before the same 3-head shape. Backed by `_softmax`,
|
|
49
|
+
`_layernorm_axis`, `_conv1d_causal` and `_multihead_attention` — each
|
|
50
|
+
cross-checked against the real PyTorch module to well under float32
|
|
51
|
+
tolerance (`_multihead_attention` is infrastructure for a future
|
|
52
|
+
attention-based model, not wired to a trained export).
|
|
53
|
+
|
|
54
|
+
All trunks/heads are limited to `linear`/`layernorm`/`relu`/`dropout`/
|
|
55
|
+
`sigmoid`/`softplus` (+`conv1d_causal` for sequence models) — never
|
|
56
|
+
`gelu`/`silu`/`batchnorm1d`, which this interpreter cannot run; the
|
|
57
|
+
trainers default their architectures accordingly.
|
|
58
|
+
|
|
59
|
+
## Batched inference & caching (the production path)
|
|
60
|
+
|
|
61
|
+
`main.py` never calls the single-model entry points in loops; it uses the
|
|
62
|
+
batched, cached forms built once in `_ensure_ready()`:
|
|
63
|
+
|
|
64
|
+
- `run_exported_models_batched()` / `run_exported_multitask_models_batched()`
|
|
65
|
+
— stack the 4 experts' weights into one leading batch axis and run one
|
|
66
|
+
`_linear_batched()`/`_layernorm_batched()` call per layer. Falls back to
|
|
67
|
+
the per-model loop (one bad expert never takes the others down) when
|
|
68
|
+
fewer than 2 experts are present or shapes don't match.
|
|
69
|
+
- `run_exported_sequence_multitask_model_batched(model_export, sequences)`
|
|
70
|
+
— the opposite batching shape: ONE shared sequence model across `N`
|
|
71
|
+
symbols' `(window, features)` inputs via `_conv1d_causal_batched()` and
|
|
72
|
+
`_linear_shared_batched()`. `None` entries (unwarmed symbol buffers)
|
|
73
|
+
are preserved at their index; falls back to per-symbol calls on ragged
|
|
74
|
+
input. Gated by
|
|
75
|
+
`phase_v2.sequence_model.batched_across_symbols_enabled` (default
|
|
76
|
+
`false`), and only when multiprocess parallelism is off — the two are
|
|
77
|
+
alternatives, not combinable.
|
|
78
|
+
- `convert_state_dict_arrays(export)` — converts `state_dict` lists to
|
|
79
|
+
numpy arrays once at load time so per-bar `np.asarray()` calls become
|
|
80
|
+
no-ops. `build_layer_stacks()`/`BatchedLayerStackCache`/
|
|
81
|
+
`build_models_batched_cache()` (+ multitask siblings) precompute the
|
|
82
|
+
per-layer weight/bias stacks via an optional `stack_cache` parameter
|
|
83
|
+
(default `None` = original behavior).
|
|
84
|
+
- **`cpp_inference_ext/`** — optional C++/pybind11 accelerator for
|
|
85
|
+
`_linear_batched()` (builds an importable module named `cpp_inference`;
|
|
86
|
+
the folder name deliberately differs from the module name to avoid
|
|
87
|
+
namespace-package shadowing). `exported_model.py` attempts the import
|
|
88
|
+
and falls back to the numpy path on any failure. Build with
|
|
89
|
+
`pip install -e cpp_inference_ext/` (needs a C++ compiler; never a hard
|
|
90
|
+
dependency).
|
|
91
|
+
|
|
92
|
+
The cumulative effect of batching + caching (+ the optional C++ path) was
|
|
93
|
+
a measured ~-89% profiled hot-path cost reduction; full before/after
|
|
94
|
+
methodology in `development/Problems.md` #31/#32, harness in
|
|
95
|
+
`scripts/profile_inference.py` (`aq profile`).
|
|
96
|
+
|
|
97
|
+
## Testing
|
|
98
|
+
|
|
99
|
+
`tests/test_exported_model.py` is the parity net: hand-computed
|
|
100
|
+
`_linear`/`_layernorm`/`_sigmoid`/`_softplus` assertions at tight
|
|
101
|
+
tolerance, full-stack forward-pass tests against independently
|
|
102
|
+
hand-transcribed reference implementations, and batched-vs-individual
|
|
103
|
+
parity tests using both synthetic multi-model fixtures and the real
|
|
104
|
+
`ml/expert_models/*` exports. See `development/architecture.md`'s per-bar
|
|
105
|
+
hot-path table for where this package sits in the latency budget.
|
inference/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from .exported_model import (
|
|
2
|
+
BatchedLayerStackCache,
|
|
3
|
+
BatchedMultitaskLayerStackCache,
|
|
4
|
+
build_models_batched_cache,
|
|
5
|
+
build_multitask_models_batched_cache,
|
|
6
|
+
convert_state_dict_arrays,
|
|
7
|
+
resolve_sequence_window_size,
|
|
8
|
+
run_exported_model,
|
|
9
|
+
run_exported_multitask_model,
|
|
10
|
+
run_exported_multitask_models_batched,
|
|
11
|
+
run_exported_models_batched,
|
|
12
|
+
run_exported_sequence_multitask_model,
|
|
13
|
+
run_exported_sequence_multitask_model_batched,
|
|
14
|
+
)
|
|
15
|
+
from .parallel_inference import init_worker, run_symbol_inference, windows_parallelism_slowdown_warning
|
|
16
|
+
from .strategy_selector_inference import build_strategy_selector_features, score_strategies
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"BatchedLayerStackCache",
|
|
20
|
+
"BatchedMultitaskLayerStackCache",
|
|
21
|
+
"build_models_batched_cache",
|
|
22
|
+
"build_multitask_models_batched_cache",
|
|
23
|
+
"build_strategy_selector_features",
|
|
24
|
+
"convert_state_dict_arrays",
|
|
25
|
+
"init_worker",
|
|
26
|
+
"resolve_sequence_window_size",
|
|
27
|
+
"run_exported_model",
|
|
28
|
+
"run_exported_multitask_model",
|
|
29
|
+
"run_exported_multitask_models_batched",
|
|
30
|
+
"run_exported_models_batched",
|
|
31
|
+
"run_exported_sequence_multitask_model",
|
|
32
|
+
"run_exported_sequence_multitask_model_batched",
|
|
33
|
+
"run_symbol_inference",
|
|
34
|
+
"score_strategies",
|
|
35
|
+
"windows_parallelism_slowdown_warning",
|
|
36
|
+
]
|