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.
Files changed (99) hide show
  1. aether_quant-0.0.1.dist-info/METADATA +7 -0
  2. aether_quant-0.0.1.dist-info/RECORD +99 -0
  3. aether_quant-0.0.1.dist-info/WHEEL +5 -0
  4. aether_quant-0.0.1.dist-info/entry_points.txt +2 -0
  5. aether_quant-0.0.1.dist-info/licenses/LICENSE +133 -0
  6. aether_quant-0.0.1.dist-info/top_level.txt +13 -0
  7. analyzer/README.md +69 -0
  8. analyzer/__init__.py +17 -0
  9. analyzer/market_analyzer.py +521 -0
  10. aq_cli.py +3633 -0
  11. audit/README.md +47 -0
  12. audit/__init__.py +38 -0
  13. audit/hash_chain.py +52 -0
  14. audit/postgres_audit.py +61 -0
  15. audit/postgres_worker.py +402 -0
  16. audit/redis_queue.py +124 -0
  17. audit/status_export.py +62 -0
  18. data_pipeline/README.md +257 -0
  19. data_pipeline/__init__.py +6 -0
  20. data_pipeline/bar_synthesis.py +97 -0
  21. data_pipeline/dividend_backfill.py +243 -0
  22. data_pipeline/factor_file_backfill.py +276 -0
  23. data_pipeline/fetch.py +206 -0
  24. data_pipeline/fred_backfill.py +435 -0
  25. data_pipeline/ib_backfill.py +287 -0
  26. data_pipeline/v2_manifest.py +75 -0
  27. data_pipeline/yfinance_backfill.py +501 -0
  28. evaluation/README.md +152 -0
  29. evaluation/__init__.py +73 -0
  30. evaluation/ablation.py +310 -0
  31. evaluation/benchmark_comparison.py +195 -0
  32. evaluation/confidence_threshold_calibration.py +157 -0
  33. evaluation/factor_neutralization_check.py +94 -0
  34. evaluation/feature_parity.py +321 -0
  35. evaluation/feature_reconciliation.py +286 -0
  36. evaluation/impact_model.py +77 -0
  37. evaluation/kill_switch_replay.py +186 -0
  38. evaluation/limit_fill_simulator.py +152 -0
  39. evaluation/model_predictions.py +192 -0
  40. evaluation/monte_carlo.py +161 -0
  41. evaluation/public_benchmarks.py +117 -0
  42. evaluation/rank_book_simulator.py +494 -0
  43. evaluation/rank_ic_core.py +204 -0
  44. evaluation/rank_signal_calibration.py +690 -0
  45. evaluation/rolling_ic_gate_calibration.py +190 -0
  46. evaluation/rolling_ic_gate_replay.py +138 -0
  47. execution/README.md +281 -0
  48. execution/__init__.py +80 -0
  49. execution/config_cache.py +48 -0
  50. execution/cost_model.py +213 -0
  51. execution/lean_config_render.py +131 -0
  52. execution/live_credentials.py +38 -0
  53. execution/live_credentials_io.py +52 -0
  54. execution/order_gate.py +388 -0
  55. execution/paper_readiness.py +181 -0
  56. execution/paper_readiness_io.py +54 -0
  57. execution/paper_readiness_report.py +103 -0
  58. execution/paper_readiness_scheduler.py +137 -0
  59. execution/reconciliation.py +160 -0
  60. execution/runtime_config_io.py +38 -0
  61. execution/secret_scan.py +73 -0
  62. features/README.md +77 -0
  63. features/__init__.py +137 -0
  64. features/alt_data_features.py +154 -0
  65. features/bond_features.py +275 -0
  66. features/cross_asset_sensitivity.py +79 -0
  67. features/derivatives_macro_features.py +72 -0
  68. features/macro_features.py +79 -0
  69. features/options_greeks.py +329 -0
  70. features/sector_map.py +53 -0
  71. features/technical_indicators.py +185 -0
  72. generate_backtest_report.py +311 -0
  73. generate_evaluation_report.py +712 -0
  74. inference/README.md +105 -0
  75. inference/__init__.py +36 -0
  76. inference/exported_model.py +929 -0
  77. inference/parallel_inference.py +160 -0
  78. inference/strategy_selector_inference.py +75 -0
  79. json_safety.py +130 -0
  80. portfolio/README.md +447 -0
  81. portfolio/__init__.py +41 -0
  82. portfolio/book_construction.py +786 -0
  83. portfolio/book_neutrality.py +178 -0
  84. portfolio/hrp_allocation.py +159 -0
  85. portfolio/options_arbitrage_detector.py +232 -0
  86. portfolio/options_assignment_risk.py +119 -0
  87. portfolio/options_margin_sizing.py +333 -0
  88. portfolio/options_strategy.py +1999 -0
  89. portfolio/rank_signal.py +219 -0
  90. portfolio/rolling_ic_gate.py +183 -0
  91. risk/README.md +275 -0
  92. risk/__init__.py +38 -0
  93. risk/asset_class_router.py +584 -0
  94. risk/forex_risk.py +158 -0
  95. risk/futures_risk.py +202 -0
  96. risk/kill_switch.py +261 -0
  97. risk/manual_override.py +118 -0
  98. risk/position_sizing.py +303 -0
  99. 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
+ ]