aponyx 0.1.18__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.
- aponyx/__init__.py +14 -0
- aponyx/backtest/__init__.py +31 -0
- aponyx/backtest/adapters.py +77 -0
- aponyx/backtest/config.py +84 -0
- aponyx/backtest/engine.py +560 -0
- aponyx/backtest/protocols.py +101 -0
- aponyx/backtest/registry.py +334 -0
- aponyx/backtest/strategy_catalog.json +50 -0
- aponyx/cli/__init__.py +5 -0
- aponyx/cli/commands/__init__.py +8 -0
- aponyx/cli/commands/clean.py +349 -0
- aponyx/cli/commands/list.py +302 -0
- aponyx/cli/commands/report.py +167 -0
- aponyx/cli/commands/run.py +377 -0
- aponyx/cli/main.py +125 -0
- aponyx/config/__init__.py +82 -0
- aponyx/data/__init__.py +99 -0
- aponyx/data/bloomberg_config.py +306 -0
- aponyx/data/bloomberg_instruments.json +26 -0
- aponyx/data/bloomberg_securities.json +42 -0
- aponyx/data/cache.py +294 -0
- aponyx/data/fetch.py +659 -0
- aponyx/data/fetch_registry.py +135 -0
- aponyx/data/loaders.py +205 -0
- aponyx/data/providers/__init__.py +13 -0
- aponyx/data/providers/bloomberg.py +383 -0
- aponyx/data/providers/file.py +111 -0
- aponyx/data/registry.py +500 -0
- aponyx/data/requirements.py +96 -0
- aponyx/data/sample_data.py +415 -0
- aponyx/data/schemas.py +60 -0
- aponyx/data/sources.py +171 -0
- aponyx/data/synthetic_params.json +46 -0
- aponyx/data/transforms.py +336 -0
- aponyx/data/validation.py +308 -0
- aponyx/docs/__init__.py +24 -0
- aponyx/docs/adding_data_providers.md +682 -0
- aponyx/docs/cdx_knowledge_base.md +455 -0
- aponyx/docs/cdx_overlay_strategy.md +135 -0
- aponyx/docs/cli_guide.md +607 -0
- aponyx/docs/governance_design.md +551 -0
- aponyx/docs/logging_design.md +251 -0
- aponyx/docs/performance_evaluation_design.md +265 -0
- aponyx/docs/python_guidelines.md +786 -0
- aponyx/docs/signal_registry_usage.md +369 -0
- aponyx/docs/signal_suitability_design.md +558 -0
- aponyx/docs/visualization_design.md +277 -0
- aponyx/evaluation/__init__.py +11 -0
- aponyx/evaluation/performance/__init__.py +24 -0
- aponyx/evaluation/performance/adapters.py +109 -0
- aponyx/evaluation/performance/analyzer.py +384 -0
- aponyx/evaluation/performance/config.py +320 -0
- aponyx/evaluation/performance/decomposition.py +304 -0
- aponyx/evaluation/performance/metrics.py +761 -0
- aponyx/evaluation/performance/registry.py +327 -0
- aponyx/evaluation/performance/report.py +541 -0
- aponyx/evaluation/suitability/__init__.py +67 -0
- aponyx/evaluation/suitability/config.py +143 -0
- aponyx/evaluation/suitability/evaluator.py +389 -0
- aponyx/evaluation/suitability/registry.py +328 -0
- aponyx/evaluation/suitability/report.py +398 -0
- aponyx/evaluation/suitability/scoring.py +367 -0
- aponyx/evaluation/suitability/tests.py +303 -0
- aponyx/examples/01_generate_synthetic_data.py +53 -0
- aponyx/examples/02_fetch_data_file.py +82 -0
- aponyx/examples/03_fetch_data_bloomberg.py +104 -0
- aponyx/examples/04_compute_signal.py +164 -0
- aponyx/examples/05_evaluate_suitability.py +224 -0
- aponyx/examples/06_run_backtest.py +242 -0
- aponyx/examples/07_analyze_performance.py +214 -0
- aponyx/examples/08_visualize_results.py +272 -0
- aponyx/main.py +7 -0
- aponyx/models/__init__.py +45 -0
- aponyx/models/config.py +83 -0
- aponyx/models/indicator_transformation.json +52 -0
- aponyx/models/indicators.py +292 -0
- aponyx/models/metadata.py +447 -0
- aponyx/models/orchestrator.py +213 -0
- aponyx/models/registry.py +860 -0
- aponyx/models/score_transformation.json +42 -0
- aponyx/models/signal_catalog.json +29 -0
- aponyx/models/signal_composer.py +513 -0
- aponyx/models/signal_transformation.json +29 -0
- aponyx/persistence/__init__.py +16 -0
- aponyx/persistence/json_io.py +132 -0
- aponyx/persistence/parquet_io.py +378 -0
- aponyx/py.typed +0 -0
- aponyx/reporting/__init__.py +10 -0
- aponyx/reporting/generator.py +517 -0
- aponyx/visualization/__init__.py +20 -0
- aponyx/visualization/app.py +37 -0
- aponyx/visualization/plots.py +309 -0
- aponyx/visualization/visualizer.py +242 -0
- aponyx/workflows/__init__.py +18 -0
- aponyx/workflows/concrete_steps.py +720 -0
- aponyx/workflows/config.py +122 -0
- aponyx/workflows/engine.py +279 -0
- aponyx/workflows/registry.py +116 -0
- aponyx/workflows/steps.py +180 -0
- aponyx-0.1.18.dist-info/METADATA +552 -0
- aponyx-0.1.18.dist-info/RECORD +104 -0
- aponyx-0.1.18.dist-info/WHEEL +4 -0
- aponyx-0.1.18.dist-info/entry_points.txt +2 -0
- aponyx-0.1.18.dist-info/licenses/LICENSE +21 -0
aponyx/docs/cli_guide.md
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
# CLI User Guide
|
|
2
|
+
|
|
3
|
+
Aponyx CLI consolidates systematic credit research workflows into single-command execution.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Create minimal config
|
|
9
|
+
cat > workflow.yaml << EOF
|
|
10
|
+
label: my_test
|
|
11
|
+
signal: spread_momentum
|
|
12
|
+
product: cdx_ig_5y
|
|
13
|
+
strategy: balanced
|
|
14
|
+
EOF
|
|
15
|
+
|
|
16
|
+
# Run complete workflow
|
|
17
|
+
uv run aponyx run workflow.yaml
|
|
18
|
+
|
|
19
|
+
# Generate report (by label)
|
|
20
|
+
uv run aponyx report --workflow my_test
|
|
21
|
+
|
|
22
|
+
# List available items
|
|
23
|
+
uv run aponyx list signals
|
|
24
|
+
uv run aponyx list workflows
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Logging:** Default is WARNING. Use `-v` for DEBUG. Logs saved to `logs/aponyx_{timestamp}.log`.
|
|
28
|
+
|
|
29
|
+
## Command Reference
|
|
30
|
+
|
|
31
|
+
- **`run`** — Execute research workflow (data → signal → suitability → backtest → performance → visualization)
|
|
32
|
+
- **`report`** — Generate multi-format reports from workflow results
|
|
33
|
+
- **`list`** — Show available signals, products, indicators, transformations, securities, strategies, datasets, steps, or workflows
|
|
34
|
+
- **`clean`** — Remove cached workflow results and indicator cache
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `run` — Execute Research Workflow
|
|
41
|
+
|
|
42
|
+
Execute complete or partial research pipeline using YAML configuration.
|
|
43
|
+
|
|
44
|
+
**Prerequisites:** Data must be in registry (run data fetching scripts first).
|
|
45
|
+
|
|
46
|
+
**Usage:**
|
|
47
|
+
```bash
|
|
48
|
+
uv run aponyx run <config_path>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**YAML Configuration Schema:**
|
|
52
|
+
|
|
53
|
+
| Field | Type | Required | Default | Description |
|
|
54
|
+
|-------|------|----------|---------|-------------|
|
|
55
|
+
| `label` | string | ✓ | - | Workflow label (lowercase, underscores, numbers only: ^[a-z][a-z0-9_]*$) |
|
|
56
|
+
| `signal` | string | ✓ | - | Signal name from signal_catalog.json |
|
|
57
|
+
| `product` | string | ✓ | - | Product identifier (e.g., "cdx_ig_5y") |
|
|
58
|
+
| `strategy` | string | ✓ | - | Strategy name from strategy_catalog.json |
|
|
59
|
+
| `indicator` | string | | from signal | Override indicator transformation (must exist in indicator_transformation.json) |
|
|
60
|
+
| `score_transformation` | string | | from signal | Override score transformation (must exist in score_transformation.json) |
|
|
61
|
+
| `signal_transformation` | string | | from signal | Override signal transformation (must exist in signal_transformation.json) |
|
|
62
|
+
| `securities` | dict | | from indicator | Custom security mapping (e.g., `cdx: cdx_hy_5y`) |
|
|
63
|
+
| `data` | string | | "synthetic" | Data source: `synthetic`, `file`, `bloomberg` |
|
|
64
|
+
| `steps` | list | | all | Specific steps to execute (e.g., `[data, signal, backtest]`) |
|
|
65
|
+
| `force` | boolean | | false | Force re-run all steps (skip cache)
|
|
66
|
+
|
|
67
|
+
**Examples:**
|
|
68
|
+
|
|
69
|
+
**Minimal configuration** (`workflow_minimal.yaml`):
|
|
70
|
+
```yaml
|
|
71
|
+
label: minimal_test
|
|
72
|
+
signal: spread_momentum
|
|
73
|
+
product: cdx_ig_5y
|
|
74
|
+
strategy: balanced
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Complete configuration** (`workflow_complete.yaml`):
|
|
78
|
+
```yaml
|
|
79
|
+
label: complete_test
|
|
80
|
+
signal: cdx_etf_basis
|
|
81
|
+
product: cdx_ig_5y
|
|
82
|
+
strategy: balanced
|
|
83
|
+
indicator: cdx_etf_spread_diff
|
|
84
|
+
score_transformation: z_score_20d
|
|
85
|
+
signal_transformation: bounded_1_5
|
|
86
|
+
securities:
|
|
87
|
+
cdx: cdx_ig_5y
|
|
88
|
+
etf: lqd
|
|
89
|
+
data: synthetic
|
|
90
|
+
steps: [data, signal, suitability, backtest, performance, visualization]
|
|
91
|
+
force: true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Run workflows:**
|
|
95
|
+
```bash
|
|
96
|
+
# Use example configs
|
|
97
|
+
uv run aponyx run examples/workflow_minimal.yaml
|
|
98
|
+
uv run aponyx run examples/workflow_complete.yaml
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Terminal Output:**
|
|
102
|
+
```
|
|
103
|
+
=== Workflow Configuration ===
|
|
104
|
+
Label: minimal_test [config]
|
|
105
|
+
Product: cdx_ig_5y [config]
|
|
106
|
+
Signal: spread_momentum [config]
|
|
107
|
+
Indicator Transform: spread_momentum_5d [from signal]
|
|
108
|
+
Securities: cdx:cdx_ig_5y [from indicator]
|
|
109
|
+
Score Transform: volatility_adjust_20d [from signal]
|
|
110
|
+
Signal Transform: passthrough [from signal]
|
|
111
|
+
Strategy: balanced [config]
|
|
112
|
+
Data: synthetic [default]
|
|
113
|
+
Steps: all [default]
|
|
114
|
+
Force re-run: False [default]
|
|
115
|
+
==============================
|
|
116
|
+
|
|
117
|
+
Completed 6 steps in 1.5s
|
|
118
|
+
Results: data/workflows/minimal_test_20251213_205920/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Source Tags:**
|
|
122
|
+
- `[config]` — Explicitly provided in YAML
|
|
123
|
+
- `[from signal]` — Resolved from signal metadata
|
|
124
|
+
- `[from indicator]` — Resolved from indicator metadata
|
|
125
|
+
- `[default]` — System default value
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### `report` — Generate Research Report
|
|
130
|
+
|
|
131
|
+
Generate comprehensive reports from workflow results.
|
|
132
|
+
|
|
133
|
+
**Usage:**
|
|
134
|
+
```bash
|
|
135
|
+
uv run aponyx report [OPTIONS]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Options:**
|
|
139
|
+
|
|
140
|
+
| Option | Type | Default | Description |
|
|
141
|
+
|--------|------|---------|-------------|
|
|
142
|
+
| `--workflow` | TEXT | Required | Workflow label or numeric index (0 = most recent) |
|
|
143
|
+
| `--format` | CHOICE | console | Format: `console`, `markdown`, `html` |
|
|
144
|
+
|
|
145
|
+
**Workflow Selection:**
|
|
146
|
+
|
|
147
|
+
- **By label**: Use the workflow label from YAML config (stable reference)
|
|
148
|
+
- **By index**: Use numeric index from `aponyx list workflows` (ephemeral, sorted by timestamp descending)
|
|
149
|
+
|
|
150
|
+
**Examples:**
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Console summary (by label)
|
|
154
|
+
uv run aponyx report --workflow minimal_test
|
|
155
|
+
|
|
156
|
+
# By numeric index (0 = most recent)
|
|
157
|
+
uv run aponyx report --workflow 0
|
|
158
|
+
|
|
159
|
+
# Generate markdown (saved to workflow's reports/ folder)
|
|
160
|
+
uv run aponyx report --workflow minimal_test --format markdown
|
|
161
|
+
|
|
162
|
+
# Generate HTML (saved to workflow's reports/ folder)
|
|
163
|
+
uv run aponyx report --workflow minimal_test --format html
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Note:** Numeric indices are ephemeral and change as new workflows are created. Use labels for stable references in scripts. Reports are saved to the workflow's `reports/` folder.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### `list` — Show Catalog Items
|
|
171
|
+
|
|
172
|
+
List available signals, strategies, datasets, or workflow results.
|
|
173
|
+
|
|
174
|
+
**Usage:**
|
|
175
|
+
```bash
|
|
176
|
+
uv run aponyx list {signals|products|indicators|score-transformations|signal-transformations|securities|datasets|strategies|steps|workflows}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Item Types:**
|
|
180
|
+
|
|
181
|
+
| Item Type | Description |
|
|
182
|
+
|-----------|-------------|
|
|
183
|
+
| `signals` | Available signals from signal_catalog.json |
|
|
184
|
+
| `products` | Available products (CDX indices) |
|
|
185
|
+
| `indicators` | Indicator transformations from indicator_transformation.json |
|
|
186
|
+
| `score-transformations` | Score transformations (z-score, volatility adjust, etc.) |
|
|
187
|
+
| `signal-transformations` | Signal transformations (bounds, neutral zones) |
|
|
188
|
+
| `securities` | Available securities for data fetching |
|
|
189
|
+
| `datasets` | Cached datasets in data registry |
|
|
190
|
+
| `strategies` | Available strategies from strategy_catalog.json |
|
|
191
|
+
| `steps` | Workflow steps in canonical order |
|
|
192
|
+
| `workflows` | Completed workflow results |
|
|
193
|
+
|
|
194
|
+
**Workflow Filters (workflows only):**
|
|
195
|
+
|
|
196
|
+
| Option | Type | Description |
|
|
197
|
+
|--------|------|-------------|
|
|
198
|
+
| `--signal` | TEXT | Filter by signal name |
|
|
199
|
+
| `--product` | TEXT | Filter by product identifier |
|
|
200
|
+
| `--strategy` | TEXT | Filter by strategy name |
|
|
201
|
+
|
|
202
|
+
**Examples:**
|
|
203
|
+
```bash
|
|
204
|
+
uv run aponyx list signals
|
|
205
|
+
uv run aponyx list products
|
|
206
|
+
uv run aponyx list indicators
|
|
207
|
+
uv run aponyx list score-transformations
|
|
208
|
+
uv run aponyx list signal-transformations
|
|
209
|
+
uv run aponyx list securities
|
|
210
|
+
uv run aponyx list strategies
|
|
211
|
+
uv run aponyx list datasets
|
|
212
|
+
uv run aponyx list steps
|
|
213
|
+
uv run aponyx list workflows # All workflows (up to 50 most recent)
|
|
214
|
+
uv run aponyx list workflows --signal spread_momentum
|
|
215
|
+
uv run aponyx list workflows --product cdx_ig_5y --strategy balanced
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Workflow Output:**
|
|
219
|
+
|
|
220
|
+
Displays table with IDX (ephemeral index), LABEL, SIGNAL, STRATEGY, PRODUCT, STATUS, and TIMESTAMP. Sorted by timestamp descending (newest first). Limited to 50 results unless filtered.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### `clean` — Clear Cached Results
|
|
225
|
+
|
|
226
|
+
Remove cached workflow results with age-based filtering.
|
|
227
|
+
|
|
228
|
+
**Usage:**
|
|
229
|
+
```bash
|
|
230
|
+
uv run aponyx clean [OPTIONS]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Options:**
|
|
234
|
+
|
|
235
|
+
| Option | Type | Description |
|
|
236
|
+
|--------|------|-------------|
|
|
237
|
+
| `--workflows` | FLAG | Enable workflow pruning mode |
|
|
238
|
+
| `--indicators` | FLAG | Clean indicator cache |
|
|
239
|
+
| `--signal` | TEXT | Filter by signal name (workflows only) |
|
|
240
|
+
| `--older-than` | TEXT | Age threshold (e.g., "30d", minimum 1 day) |
|
|
241
|
+
| `--all` | FLAG | Clean all matching items |
|
|
242
|
+
| `--dry-run` | FLAG | Preview without deleting |
|
|
243
|
+
|
|
244
|
+
**Examples:**
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Preview all workflow deletions
|
|
248
|
+
uv run aponyx clean --workflows --all --dry-run
|
|
249
|
+
|
|
250
|
+
# Clean workflows older than 30 days
|
|
251
|
+
uv run aponyx clean --workflows --older-than 30d
|
|
252
|
+
|
|
253
|
+
# Clean specific signal's workflows older than 7 days
|
|
254
|
+
uv run aponyx clean --workflows --signal spread_momentum --older-than 7d
|
|
255
|
+
|
|
256
|
+
# Clean all workflows (no preview)
|
|
257
|
+
uv run aponyx clean --workflows --all
|
|
258
|
+
|
|
259
|
+
# Clean indicator cache
|
|
260
|
+
uv run aponyx clean --indicators
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Validation:**
|
|
264
|
+
- `--older-than` format: `{number}d` (e.g., "30d", "7d")
|
|
265
|
+
- Minimum age: 1 day (prevents accidental deletion of current work)
|
|
266
|
+
- Can combine `--signal` and `--older-than` filters
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Understanding Workflows
|
|
271
|
+
|
|
272
|
+
### Execution Pipeline
|
|
273
|
+
|
|
274
|
+
Workflows execute 6 steps in order:
|
|
275
|
+
|
|
276
|
+
1. **data** — Load market data from registry
|
|
277
|
+
2. **signal** — Compute signal values (z-score normalized)
|
|
278
|
+
3. **suitability** — Pre-backtest evaluation (PASS/HOLD/FAIL)
|
|
279
|
+
4. **backtest** — Simulate P&L with transaction costs (proportional sizing by default)
|
|
280
|
+
5. **performance** — Extended metrics (Sharpe, Sortino, attribution)
|
|
281
|
+
6. **visualization** — Generate interactive charts
|
|
282
|
+
|
|
283
|
+
**Dependencies:** Steps depend on previous steps. `signal` requires `data`; `backtest` requires `signal` + `suitability`; etc.
|
|
284
|
+
|
|
285
|
+
**Smart caching:** Completed steps are skipped unless `--force` is used.
|
|
286
|
+
|
|
287
|
+
### Output Structure
|
|
288
|
+
|
|
289
|
+
Results saved to: `data/workflows/{label}_{timestamp}/`
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
├── metadata.json # Run parameters (label, signal, strategy, product, securities_used, status, timestamp)
|
|
293
|
+
├── signals/
|
|
294
|
+
│ └── signal.parquet # Signal time series
|
|
295
|
+
├── reports/
|
|
296
|
+
│ ├── suitability_evaluation_{timestamp}.md # Pre-backtest analysis
|
|
297
|
+
│ └── performance_analysis_{timestamp}.md # Post-backtest metrics
|
|
298
|
+
├── backtest/
|
|
299
|
+
│ ├── pnl.parquet # P&L time series
|
|
300
|
+
│ └── positions.parquet # Position time series
|
|
301
|
+
└── visualizations/ # Plotly charts (HTML)
|
|
302
|
+
├── equity_curve.html
|
|
303
|
+
├── drawdown.html
|
|
304
|
+
└── signal.html
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**Cache:** `data/cache/{provider}/{security}_{hash}.parquet` (TTL-based, auto-regenerated)
|
|
308
|
+
|
|
309
|
+
### Configuration Files
|
|
310
|
+
|
|
311
|
+
All workflows use YAML configuration files with required and optional fields.
|
|
312
|
+
|
|
313
|
+
**Minimal workflow** (`workflow_minimal.yaml`):
|
|
314
|
+
```yaml
|
|
315
|
+
label: minimal_test
|
|
316
|
+
signal: spread_momentum
|
|
317
|
+
product: cdx_ig_5y
|
|
318
|
+
strategy: balanced
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Custom securities**:
|
|
322
|
+
```yaml
|
|
323
|
+
label: custom_securities
|
|
324
|
+
signal: cdx_etf_basis
|
|
325
|
+
product: cdx_ig_5y
|
|
326
|
+
strategy: balanced
|
|
327
|
+
securities:
|
|
328
|
+
cdx: cdx_hy_5y
|
|
329
|
+
etf: hyg
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Partial pipeline**:
|
|
333
|
+
```yaml
|
|
334
|
+
label: partial_test
|
|
335
|
+
signal: spread_momentum
|
|
336
|
+
product: cdx_ig_5y
|
|
337
|
+
strategy: balanced
|
|
338
|
+
steps: [data, signal, backtest]
|
|
339
|
+
force: true
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Bloomberg data**:
|
|
343
|
+
```yaml
|
|
344
|
+
label: bloomberg_test
|
|
345
|
+
signal: spread_momentum
|
|
346
|
+
product: cdx_ig_5y
|
|
347
|
+
strategy: balanced
|
|
348
|
+
data: bloomberg
|
|
349
|
+
force: true # Update current day data
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Runtime overrides**:
|
|
353
|
+
```yaml
|
|
354
|
+
label: override_test
|
|
355
|
+
signal: cdx_etf_basis
|
|
356
|
+
product: cdx_ig_5y
|
|
357
|
+
strategy: balanced
|
|
358
|
+
indicator: cdx_etf_spread_diff # Override indicator transformation
|
|
359
|
+
score_transformation: z_score_60d # Override score transformation (e.g., 60-day instead of 20-day)
|
|
360
|
+
signal_transformation: bounded_1_5 # Override signal transformation (apply bounds)
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Proportional sizing** (position size scales with signal magnitude - default):
|
|
364
|
+
```yaml
|
|
365
|
+
label: proportional_test
|
|
366
|
+
signal: cdx_etf_basis
|
|
367
|
+
product: cdx_ig_5y
|
|
368
|
+
strategy: balanced # Uses proportional sizing mode by default
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Usage:**
|
|
372
|
+
```bash
|
|
373
|
+
uv run aponyx run examples/workflow_minimal.yaml
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Default Resolution Priority:**
|
|
377
|
+
1. Explicitly provided in YAML config (`[config]`)
|
|
378
|
+
2. Resolved from signal metadata (`[from signal]`)
|
|
379
|
+
3. Resolved from indicator metadata (`[from indicator]`)
|
|
380
|
+
4. System defaults (`[default]`)
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Position Sizing Modes
|
|
385
|
+
|
|
386
|
+
Strategies support two sizing modes that determine how signal values translate to position sizes:
|
|
387
|
+
|
|
388
|
+
### Proportional Sizing (Default)
|
|
389
|
+
|
|
390
|
+
**Mode:** `sizing_mode: "proportional"`
|
|
391
|
+
|
|
392
|
+
Position scales with signal magnitude:
|
|
393
|
+
- Position = signal × `position_size_mm`
|
|
394
|
+
- Higher conviction signals → Larger positions
|
|
395
|
+
- Rebalancing occurs when signal magnitude changes (with transaction costs)
|
|
396
|
+
- Position values recorded as actual notional in MM (e.g., 5.0, -3.5)
|
|
397
|
+
|
|
398
|
+
**Strategies:** `conservative`, `balanced`, `aggressive`, `experimental` (all default to proportional)
|
|
399
|
+
|
|
400
|
+
**Use case:** When signal strength indicates conviction and you want position size to reflect that.
|
|
401
|
+
|
|
402
|
+
### Binary Sizing (Strategy Configuration)
|
|
403
|
+
|
|
404
|
+
**Mode:** `sizing_mode: "binary"` (set in strategy_catalog.json)
|
|
405
|
+
|
|
406
|
+
Position is full size regardless of signal magnitude:
|
|
407
|
+
- Non-zero signal → Full `position_size_mm` (direction from sign)
|
|
408
|
+
- Signal magnitude is ignored (only sign matters)
|
|
409
|
+
- Position values recorded as ±1 (direction indicator)
|
|
410
|
+
|
|
411
|
+
**Configuration:** Set `sizing_mode: "binary"` in strategy_catalog.json for the strategy.
|
|
412
|
+
|
|
413
|
+
**Use case:** When you want consistent position sizes and only care about signal direction.
|
|
414
|
+
|
|
415
|
+
### Risk Management Differences
|
|
416
|
+
|
|
417
|
+
| Feature | Binary | Proportional (Default) |
|
|
418
|
+
|---------|--------|------------------------|
|
|
419
|
+
| Stop loss check | vs entry notional × DV01 | vs current notional |
|
|
420
|
+
| Take profit check | vs entry notional × DV01 | vs current notional |
|
|
421
|
+
| Rebalancing | None (position is fixed) | On signal magnitude change |
|
|
422
|
+
| Transaction costs | Entry/exit only | Entry/exit + rebalancing |
|
|
423
|
+
| Cooldown release | Signal returns to zero | Signal returns to zero OR sign change |
|
|
424
|
+
|
|
425
|
+
**Note:** All default strategies use proportional sizing. To use binary sizing, modify the strategy's `sizing_mode` in `strategy_catalog.json`.
|
|
426
|
+
|
|
427
|
+
### Example Comparison
|
|
428
|
+
|
|
429
|
+
```yaml
|
|
430
|
+
# Proportional (default): Position = signal × 10MM
|
|
431
|
+
# Signal 0.5 → 5MM position, Signal 1.5 → 15MM position
|
|
432
|
+
label: proportional_test
|
|
433
|
+
signal: spread_momentum
|
|
434
|
+
strategy: balanced # sizing_mode: proportional (default), position_size_mm: 10.0
|
|
435
|
+
|
|
436
|
+
# Binary sizing requires a strategy with sizing_mode: "binary" in strategy_catalog.json
|
|
437
|
+
# All default strategies use proportional sizing
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Common Workflows
|
|
443
|
+
|
|
444
|
+
### Production Research
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
# Create Bloomberg workflow config
|
|
448
|
+
cat > workflow_bloomberg.yaml << EOF
|
|
449
|
+
label: bloomberg_run
|
|
450
|
+
signal: spread_momentum
|
|
451
|
+
product: cdx_ig_5y
|
|
452
|
+
strategy: balanced
|
|
453
|
+
data: bloomberg
|
|
454
|
+
force: true
|
|
455
|
+
EOF
|
|
456
|
+
|
|
457
|
+
# 1. Run workflow with Bloomberg data
|
|
458
|
+
uv run aponyx run workflow_bloomberg.yaml
|
|
459
|
+
|
|
460
|
+
# 2. Generate HTML report (saved to workflow's reports/ folder)
|
|
461
|
+
uv run aponyx report --workflow bloomberg_run --format html
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Batch Processing
|
|
465
|
+
|
|
466
|
+
```bash
|
|
467
|
+
# Process multiple configs in sequence
|
|
468
|
+
for config in configs/*.yaml; do
|
|
469
|
+
uv run aponyx run "$config"
|
|
470
|
+
done
|
|
471
|
+
|
|
472
|
+
# Generate consolidated reports (using labels from configs)
|
|
473
|
+
uv run aponyx report --workflow run1 --format markdown
|
|
474
|
+
uv run aponyx report --workflow run2 --format markdown
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Maintenance
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
# Preview what will be deleted
|
|
481
|
+
uv run aponyx clean --workflows --all --dry-run
|
|
482
|
+
|
|
483
|
+
# Fresh start (clear all cached results)
|
|
484
|
+
uv run aponyx clean --workflows --all
|
|
485
|
+
|
|
486
|
+
# Remove old workflows (older than 30 days)
|
|
487
|
+
uv run aponyx clean --workflows --older-than 30d
|
|
488
|
+
|
|
489
|
+
# Clean specific signal's old workflows
|
|
490
|
+
uv run aponyx clean --workflows --signal old_signal --older-than 7d
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Troubleshooting
|
|
496
|
+
|
|
497
|
+
### Installation & Setup
|
|
498
|
+
|
|
499
|
+
**Command not found:**
|
|
500
|
+
```bash
|
|
501
|
+
uv pip install -e . # Install package
|
|
502
|
+
uv pip show aponyx # Verify installation
|
|
503
|
+
uv run aponyx --help # Test command
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Configuration Issues
|
|
507
|
+
|
|
508
|
+
**YAML parsing errors:**
|
|
509
|
+
```bash
|
|
510
|
+
# Validate syntax
|
|
511
|
+
python -c "import yaml; yaml.safe_load(open('workflow.yaml'))"
|
|
512
|
+
|
|
513
|
+
# Common issues:
|
|
514
|
+
# - Use spaces, not tabs for indentation
|
|
515
|
+
# - Colons require space after (key: value, not key:value)
|
|
516
|
+
# - List items use brackets: steps: [data, signal]
|
|
517
|
+
# - Dict items use colons: securities: {cdx: cdx_ig_5y}
|
|
518
|
+
# - Strings with special chars need quotes
|
|
519
|
+
|
|
520
|
+
# Reference valid configs
|
|
521
|
+
ls examples/*.yaml
|
|
522
|
+
cat examples/workflow_minimal.yaml
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
**Missing required fields:**
|
|
526
|
+
```bash
|
|
527
|
+
# Error: "Missing required field: label"
|
|
528
|
+
# Solution: Add all required fields to YAML
|
|
529
|
+
|
|
530
|
+
cat > workflow.yaml << EOF
|
|
531
|
+
label: my_test
|
|
532
|
+
signal: spread_momentum
|
|
533
|
+
product: cdx_ig_5y
|
|
534
|
+
strategy: balanced
|
|
535
|
+
EOF
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
**Invalid catalog references:**
|
|
539
|
+
```bash
|
|
540
|
+
# Error: "Signal 'invalid_signal' not found in catalog"
|
|
541
|
+
# Solution: List available items
|
|
542
|
+
|
|
543
|
+
uv run aponyx list signals
|
|
544
|
+
uv run aponyx list indicators
|
|
545
|
+
uv run aponyx list score-transformations
|
|
546
|
+
uv run aponyx list signal-transformations
|
|
547
|
+
uv run aponyx list securities
|
|
548
|
+
uv run aponyx list products
|
|
549
|
+
uv run aponyx list strategies
|
|
550
|
+
|
|
551
|
+
# Check catalog files directly
|
|
552
|
+
cat src/aponyx/models/signal_catalog.json
|
|
553
|
+
cat src/aponyx/models/indicator_transformation.json
|
|
554
|
+
cat src/aponyx/models/score_transformation.json
|
|
555
|
+
cat src/aponyx/models/signal_transformation.json
|
|
556
|
+
cat src/aponyx/data/bloomberg_securities.json
|
|
557
|
+
cat src/aponyx/backtest/strategy_catalog.json
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
**Permission errors:**
|
|
561
|
+
```bash
|
|
562
|
+
# Check directory permissions
|
|
563
|
+
ls -la data/workflows/ reports/ logs/
|
|
564
|
+
|
|
565
|
+
# Create directories if missing
|
|
566
|
+
mkdir -p data/workflows reports logs
|
|
567
|
+
|
|
568
|
+
# Fix permissions if needed
|
|
569
|
+
chmod -R u+w data/ reports/ logs/
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Performance & Debugging
|
|
573
|
+
|
|
574
|
+
**Enable verbose logging:**
|
|
575
|
+
```bash
|
|
576
|
+
uv run aponyx -v run examples/workflow_minimal.yaml
|
|
577
|
+
|
|
578
|
+
# Check log file for details
|
|
579
|
+
tail -f logs/aponyx_*.log
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
**Cache issues:**
|
|
583
|
+
```bash
|
|
584
|
+
# Clear workflow cache and re-run
|
|
585
|
+
uv run aponyx clean --workflows --all
|
|
586
|
+
|
|
587
|
+
# Clear indicator cache
|
|
588
|
+
uv run aponyx clean --indicators
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
## See Also
|
|
594
|
+
|
|
595
|
+
- **Main Documentation:** [README.md](../../README.md)
|
|
596
|
+
- **Architecture:** [governance_design.md](governance_design.md)
|
|
597
|
+
- **Signal Catalog:** [../models/signal_catalog.json](../models/signal_catalog.json)
|
|
598
|
+
- **Indicator Transformation Catalog:** [../models/indicator_transformation.json](../models/indicator_transformation.json)
|
|
599
|
+
- **Score Transformation Catalog:** [../models/score_transformation.json](../models/score_transformation.json)
|
|
600
|
+
- **Signal Transformation Catalog:** [../models/signal_transformation.json](../models/signal_transformation.json)
|
|
601
|
+
- **Securities Catalog:** [../data/bloomberg_securities.json](../data/bloomberg_securities.json)
|
|
602
|
+
- **Strategy Catalog:** [../backtest/strategy_catalog.json](../backtest/strategy_catalog.json)
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
**Maintained by:** stabilefrisur
|
|
607
|
+
**Last Updated:** December 13, 2025
|