create-tradejs 3.1.22 → 3.1.23

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 (40) hide show
  1. package/README.md +19 -3
  2. package/dist/index.js +36 -5
  3. package/dist/skill-bundle/.codex/skills/ai-train-local-research/SKILL.md +596 -0
  4. package/dist/skill-bundle/.codex/skills/ai-train-local-research/references/gate-ablation.md +324 -0
  5. package/dist/skill-bundle/.codex/skills/ai-train-local-research/references/reporting.md +227 -0
  6. package/dist/skill-bundle/.codex/skills/ai-train-local-research/scripts/ai-gate-ablation.mjs +5082 -0
  7. package/dist/skill-bundle/.codex/skills/ai-train-local-research/scripts/ai-gate-ablation.test.mjs +1170 -0
  8. package/dist/skill-bundle/.codex/skills/backtest-config-redis/SKILL.md +17 -0
  9. package/dist/skill-bundle/.codex/skills/backtest-config-redis/scripts/get_backtest_config.sh +21 -0
  10. package/dist/skill-bundle/.codex/skills/runtime-parity-mismatch-analysis/SKILL.md +146 -0
  11. package/dist/skill-bundle/.codex/skills/save-strategy-config-from-backtest/SKILL.md +58 -0
  12. package/dist/skill-bundle/.codex/skills/save-strategy-config-from-backtest/agents/openai.yaml +4 -0
  13. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/SKILL.md +334 -0
  14. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/references/research-notes.md +247 -0
  15. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/backtest-run-metrics.mjs +647 -0
  16. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/backtest-run-metrics.test.mjs +321 -0
  17. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/fast-ai-export-metrics.mjs +744 -0
  18. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/fast-ai-export-metrics.test.mjs +553 -0
  19. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/research-notes-check.mjs +125 -0
  20. package/dist/skill-bundle/.codex/skills/strategy-improvement-research/SKILL.md +18 -1
  21. package/dist/skill-bundle/.codex/skills/strategy-release/SKILL.md +22 -0
  22. package/dist/skill-bundle/.codex/skills/strategy-release/agents/openai.yaml +4 -0
  23. package/dist/skill-bundle/.codex/skills/strategy-release/references/diagnose-live.md +126 -0
  24. package/dist/skill-bundle/.codex/skills/strategy-release/references/direction-policy.md +141 -0
  25. package/dist/skill-bundle/.codex/skills/strategy-release/references/directional-parameter-split.md +93 -0
  26. package/dist/skill-bundle/.codex/skills/strategy-release/references/evidence-limitations.md +76 -0
  27. package/dist/skill-bundle/.codex/skills/strategy-release/references/evidence-retention.md +157 -0
  28. package/dist/skill-bundle/.codex/skills/strategy-release/references/historical-hypothesis-audit.md +163 -0
  29. package/dist/skill-bundle/.codex/skills/strategy-release/references/professional-research-loop.md +198 -0
  30. package/dist/skill-bundle/.codex/skills/strategy-release/references/release-workflow.md +755 -0
  31. package/dist/skill-bundle/.codex/skills/strategy-release/references/research-objective.md +255 -0
  32. package/dist/skill-bundle/.codex/skills/strategy-release/references/verdict-contract.md +200 -0
  33. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/direction-policy-checkpoint.mjs +137 -0
  34. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/direction-policy-checkpoint.test.mjs +85 -0
  35. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/directional-parameter-checkpoint.mjs +149 -0
  36. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/directional-parameter-checkpoint.test.mjs +120 -0
  37. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/release-progress-checkpoint.mjs +621 -0
  38. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/release-progress-checkpoint.test.mjs +349 -0
  39. package/dist/skill-bundle/.codex/tradejs-skill-bundle.json +44 -3
  40. package/package.json +1 -1
@@ -0,0 +1,247 @@
1
+ # TradeJS research note contract
2
+
3
+ Use this contract for every new internal research record, including strategy
4
+ backtests, deterministic AI-gate studies, ML experiments, audits, and
5
+ cross-strategy comparisons.
6
+
7
+ ## Core research bundle linkage
8
+
9
+ When `yarn research:core` produced the evidence, record the `researchId`, spec
10
+ SHA-256, result/report/manifest paths and hashes, family hypothesis count,
11
+ Redis/export reconciliation, setup-identity fallback rate, and evidence matrix
12
+ in the immutable note. Record the explicit spec stage (`screen`,
13
+ `isolated_long`, or `confirmation`); never infer it from elapsed days or file
14
+ names. For later stages include parent research IDs and the family stage-index
15
+ lineage. Iterative `$strategy-improvement-research` child screens also include their direct
16
+ parent research IDs, round number, hashed causal-handoff payload, eligible
17
+ carried control, parent result hashes, mechanism verdict, predicted-versus-
18
+ observed trace/metric effect, remaining failure mode, and preregistered child
19
+ config deltas. The bundle does not replace the note: embed the full
20
+ resolved config and structured metrics needed for `reproduction: complete`
21
+ because `data/research` may be cleaned. Never copy a PASS label without target,
22
+ aggregate, and non-target verdicts separately.
23
+
24
+ Everything under `$PROJECT_CWD/notes/` in `TradeJS-Project` is local-only and
25
+ permanently ignored by Git. Never stage, commit, or force-add a research note. The local note is the durable
26
+ result record relative to export JSONL, Redis entries, backtest cache,
27
+ evaluation dumps, and `data/ai/output` reports, which are disposable inputs.
28
+ Deleting those inputs must not erase the exact configuration, lineage, or
29
+ reported aggregate metrics of a completed study from the local note.
30
+
31
+ ## Storage and file boundaries
32
+
33
+ - Strategy-specific research lives at
34
+ `notes/<Strategy>/YYYY-MM-DD-<short-kebab-slug>.md`. Use the exact strategy
35
+ name exported by its package for the directory name.
36
+ - Repository-wide architecture and ML records live under `notes/Shared/`.
37
+ - One comparison whose question spans several strategies lives under
38
+ `notes/CrossStrategy/`; do not duplicate it into every strategy directory.
39
+ - Do not put files directly under `notes/`.
40
+ - One research question, immutable dataset/run lineage, and decision belong to
41
+ one file. A new export, run, hypothesis family, or decision gets a new file.
42
+ Do not append dated entries to a rolling strategy log.
43
+ - Amend an existing file only to correct that same study or finish fields that
44
+ were explicitly pending for the same immutable lineage.
45
+
46
+ ## Required frontmatter
47
+
48
+ Every file starts with:
49
+
50
+ ```yaml
51
+ ---
52
+ schema: tradejs-research/v1
53
+ strategy: '<Strategy|Shared|CrossStrategy>'
54
+ date: 'YYYY-MM-DD'
55
+ kind: '<backtest|ai-gate|ml|architecture|runtime-parity>'
56
+ status: <implemented|observe|research-only|rollback|blocked|historical>
57
+ reproduction: <complete|partial|blocked|legacy-partial>
58
+ ---
59
+ ```
60
+
61
+ Use `reproduction: complete` only when the note contains every required item
62
+ below. Migrated historical records use `legacy-partial`; never fill missing
63
+ lineage from today's config or code.
64
+
65
+ ## Required section order
66
+
67
+ ```md
68
+ # <Strategy> — <research title>
69
+
70
+ ## Research question
71
+
72
+ ## Decision
73
+
74
+ ## Reproduction manifest
75
+
76
+ ## Resolved configuration
77
+
78
+ ## Metrics snapshot (machine-readable)
79
+
80
+ ## Reported metrics
81
+
82
+ ## Findings
83
+
84
+ ## Artifact inventory
85
+
86
+ ## Limitations and next step
87
+ ```
88
+
89
+ AI-gate records use the fixed report from
90
+ `../../ai-train-local-research/references/reporting.md` as their human-readable
91
+ `Reported metrics` block. They may append the audit and validation sections
92
+ required by that contract after the fixed tables.
93
+
94
+ ## Reproduction manifest
95
+
96
+ Record values, not assumptions:
97
+
98
+ - strategy, research id, UTC execution time, and exact research question;
99
+ - merge id or backtest run id, shard count, row/trade count, minimum and maximum
100
+ timestamps, data lag, ticker universe, timeframe, connector, and PnL unit;
101
+ - exact selection, skip/latest limits, terminal windows, partition boundaries,
102
+ timestamp grouping, random seed, and capacity assumptions;
103
+ - exact commands, including every flag and referenced spec file;
104
+ - git SHA and dirty state plus gate, config-id, and context fingerprints when
105
+ applicable;
106
+ - metric implementation/tool path and its git SHA when it can differ from the
107
+ strategy lineage;
108
+ - effective `AI_MODE`, `MIN_AI_QUALITY`, entry delay, slippage, risk budget, and
109
+ context-provider settings relevant to the result.
110
+
111
+ Do not record credentials or secret environment values.
112
+
113
+ ## Resolved configuration
114
+
115
+ Embed the complete secret-free resolved configuration used by the run in a
116
+ fenced `json` block. A mutable Redis key, config name, current default, or file
117
+ path alone is not sufficient. Include at least the strategy/backtest config,
118
+ runtime overrides, risk fields such as `MAX_LOSS_VALUE`, and every context env
119
+ value that affects evaluated features.
120
+
121
+ If the runner provides an immutable archived resolved-config snapshot, embed
122
+ that snapshot and also record its run/test key and SHA-256. When the historical
123
+ config cannot be recovered, use `reproduction: partial` or `blocked` and write
124
+ `n/a`; never substitute a current config.
125
+
126
+ ## Metrics snapshot
127
+
128
+ Embed the complete structured JSON summary produced by the authoritative tool,
129
+ without truncation, in a fenced `json` block. This is the machine-readable
130
+ source for the tables and preserves the reported metrics after exports or
131
+ caches are deleted.
132
+
133
+ - AI-gate baseline: use the full output of
134
+ `yarn ai-train --localOnly --json -n 0` for the selected merge group.
135
+ - AI-gate comparisons: also embed structured baseline, pocket-only, final,
136
+ partition, terminal-window, direction, concentration, capacity, and reject
137
+ summaries produced by the permanent ablation tooling.
138
+ - Backtests: use
139
+ `backtest-run-metrics.mjs --run <run-id> --json` and retain all requested
140
+ terminal windows. Add raw sweep/result summaries when the decision depends
141
+ on them.
142
+
143
+ The snapshot must contain the numbers needed to rebuild every human-readable
144
+ table in the note. Do not paste the deleted row-level export into Markdown. A
145
+ complete note preserves reported aggregate metrics and their provenance; it
146
+ does not claim to recreate arbitrary new row-level analyses after source data
147
+ is gone.
148
+
149
+ ## Reported metrics and artifacts
150
+
151
+ - Keep stable metric names, window order, rounding, and `n/a` rules.
152
+ - Define `PnL/trade` as total PnL divided by completed trades. Never substitute
153
+ the CLI progress `avg`, which is PnL per completed test/symbol; label that
154
+ operational metric explicitly when it is retained. Use `n/a` when `N = 0`.
155
+ - For every core/backtest config and reported window, preserve and display
156
+ three cohorts in fixed order: `ALL (aggregate portfolio)`, `LONG`, and
157
+ `SHORT`. Each row must contain `N`, `PnL`, `PnL/trade`, `PF`, `WR`,
158
+ `realized MaxDD`, and `cadence/day`. Define `N` as completed trades, `PnL` as
159
+ summed net realized completed-trade PnL, `PF` as gross winning PnL divided by
160
+ absolute gross losing PnL, `WR` as wins divided by `N`, `realized MaxDD` as
161
+ the maximum peak-to-trough decline of the cohort's chronological
162
+ completed-trade net-PnL equity curve, and `cadence/day` as `N / exact
163
+ calendar days`. Include zero-activity side cohorts rather than omitting them.
164
+ Label LONG/SHORT drawdown as `side-only realized MaxDD`, computed from a
165
+ time-ordered equity curve containing only that direction's completed trades.
166
+ Label ALL drawdown as `aggregate portfolio realized MaxDD`; it remains a
167
+ separate portfolio guardrail and is not interchangeable with side-only DD.
168
+ - Compute LONG and SHORT metrics after filtering the source rows by direction.
169
+ Compute aggregate `PnL/trade` as
170
+ `(LONG PnL + SHORT PnL) / (LONG N + SHORT N)`, never by averaging directional
171
+ `PnL/trade` values. The machine-readable snapshot must retain the cohort and
172
+ window dimensions needed to reproduce every row.
173
+ - Keep both directions enabled for raw-core evidence. A negative direction is
174
+ reported, not silently disabled. State that AI-gate evaluation is a later,
175
+ separate stage that examines the LONG and SHORT cohorts explicitly. Preserve
176
+ a separate baseline/candidate assessment status for ALL, LONG, and SHORT;
177
+ never use one aggregate status as the status of both side cohorts.
178
+ - A direction-targeted record must include its preregistered target side,
179
+ unaffected side, matched control, metric thresholds, identity rule,
180
+ rounding tolerance, possible occupancy interaction, non-target non-regression
181
+ rule, and aggregate guardrails. Judge it primarily on preregistered
182
+ target-side improvements in PnL, PnL/trade, PF, WR, and side-only realized
183
+ MaxDD. Require exact non-target signal/trade identities and exact N plus PnL
184
+ equality within only the documented reconciliation rounding tolerance only
185
+ when the architecture makes that side invariant. Otherwise preserve explicit
186
+ occupancy-spillover evidence: added/removed identities, N/cadence delta, and
187
+ every economic-metric delta, then apply the preregistered non-regression
188
+ rule. Report the target-side causal decision separately from the aggregate
189
+ portfolio-promotion decision. Aggregate portfolio PnL and realized MaxDD are
190
+ guardrails, not the sole acceptance or rejection criterion and not part of
191
+ the target-side verdict.
192
+ - Define observed portfolio cadence as completed trades divided by exact
193
+ calendar days. Do not divide full-universe cadence by symbol count. If a
194
+ deliberately sampled universe is projected to a larger universe, retain
195
+ both values and record tested symbols, target symbols, and the linear scale
196
+ factor; never label the projection as observed cadence.
197
+ - For core robustness studies, retain terminal 365d/180d/90d/30d windows
198
+ anchored to the immutable run end as half-open `[end - days, end)` intervals,
199
+ including zero-activity windows. Record
200
+ whether those windows came from a continuous long-run slice or standalone
201
+ horizon runs with a reset and preload.
202
+ - If a broad grid was screened on a shorter all-universe window, label that
203
+ stage selection-only, preserve every grid cell and its selection rule, and
204
+ link the exact shortlisted cell to its later full long-window run. Never let
205
+ the screening table stand in for the robustness table.
206
+ - Record whether parameter cells ran in one fan-out group or as isolated
207
+ single-config runs. Long-window full-universe finalists should be isolated to
208
+ bound heap use and prevent shared lifecycle state from crossing config cells.
209
+ Record OOM/partial completion as a failed lineage and do not calculate
210
+ strategy metrics from the completed subset.
211
+ - Record the run-manifest status at export time. An export made while the
212
+ manifest is `running` is partial even when its captured rows are individually
213
+ valid, so it cannot support PF, PnL/trade, portfolio MaxDD, direction, or
214
+ terminal-window claims. Preserve chunks until a finished run reconciles.
215
+ - Record the frozen ordered ticker list and its checksum, eligible/raw counts,
216
+ Redis snapshot timestamp, exact start/end timestamps, and missing/error test
217
+ counts. In grid runs, keep every `configId` separate and embed the exact
218
+ resolved config for each reported or rejected bucket.
219
+ - Record fingerprints, selection/calibration windows, and `effectiveFrom` for
220
+ every external membership snapshot used by a detector. If a future/current
221
+ registry or universe is applied to older decisions, set status and
222
+ reproduction to `blocked`; preserve diagnostic metrics but do not describe
223
+ them as point-in-time evidence or use them for parameter promotion.
224
+ - Preserve rejected hypotheses as immutable evidence with their causal claim,
225
+ full config, exact run IDs, and structured metrics. Do not keep only the
226
+ winning variant or a prose statement that a threshold was tried.
227
+ - Include zero-activity terminal windows rather than omitting them.
228
+ - Record checksums for every disposable input/output artifact when available.
229
+ - Artifact paths are an inventory, not the reproducibility source of truth.
230
+ - State any metric that cannot be recovered from the structured snapshot under
231
+ `Limitations and next step` and lower the reproduction status accordingly.
232
+
233
+ ## Historical migration
234
+
235
+ Historical split records retain their original body under a common v1
236
+ frontmatter and use `reproduction: legacy-partial`. Their
237
+ `source_content_sha256` verifies the pre-normalization source block. They use
238
+ the same required section spine, with the original headings demoted and body
239
+ preserved under `Reported metrics`. The original tables remain valid historical
240
+ evidence, but missing configs, fingerprints, or metric snapshots must stay
241
+ unknown.
242
+
243
+ After creating or editing notes, run:
244
+
245
+ ```bash
246
+ node .codex/skills/strategy-backtest-research/scripts/research-notes-check.mjs
247
+ ```