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,163 @@
1
+ # Historical hypothesis audit
2
+
3
+ Use this audit before inventing release-core hypotheses. Its purpose is to
4
+ prevent a new Codex task from forgetting a stronger prior core result, rerunning
5
+ an already rejected idea, or treating an unrelated refactor as research.
6
+ When the objective fingerprint changed, follow this inventory with the complete
7
+ candidate revalidation board from
8
+ [research-objective.md](research-objective.md); do not revalidate only the
9
+ previous winner.
10
+
11
+ ## Contents
12
+
13
+ 1. Build the inventory
14
+ 2. Match commits to evidence
15
+ 3. Bridge prior results to the current experiment
16
+ 4. Prioritize untested hypotheses
17
+ 5. Required artifact
18
+
19
+ ## 1. Build the inventory
20
+
21
+ Inspect the complete strategy history, the current strategy files, and every
22
+ shared helper imported by that strategy:
23
+
24
+ ```bash
25
+ git log --reverse --date=iso-strict \
26
+ --format='%H%x09%aI%x09%s' -- packages/strategies/src/<Strategy>
27
+ git show --stat --patch <commit-sha> -- \
28
+ packages/strategies/src/<Strategy> <referenced-shared-paths>
29
+ yarn research:core index
30
+ ```
31
+
32
+ Also inspect `notes/<Strategy>/`, relevant `notes/CrossStrategy/` records, the
33
+ core-research family ledger/index, Redis config snapshots cited by those
34
+ records, and retained release artifacts. Search by full/short Git SHA, config
35
+ field, canonical config hash, behavior/diff hash, research id, and run id. A
36
+ missing Git SHA in a note is not proof that no evidence exists.
37
+
38
+ Classify every behavior-relevant commit or dirty patch as exactly one of:
39
+
40
+ - `verified-result`: complete reconciled evidence exists for the same behavior;
41
+ - `rejected-result`: complete evidence exists and rejected it;
42
+ - `partial-result`: useful evidence exists but is not selection-grade;
43
+ - `untested-behavior`: a causal behavior change has no result evidence;
44
+ - `refactor-no-hypothesis`: no intended decision/economic behavior change;
45
+ - `superseded-duplicate`: the same causal delta was tested under another
46
+ commit/config lineage;
47
+ - `unreconstructable`: the behavior or required point-in-time inputs cannot be
48
+ reproduced honestly.
49
+
50
+ Do not infer the class from the commit subject. Inspect the patch. Config,
51
+ filter, engine, order-plan, exit-lifecycle, risk, and deterministic-gate changes
52
+ are hypothesis candidates; tests, formatting, module moves, and performance-only
53
+ refactors are not unless the patch changed decisions or execution semantics.
54
+
55
+ ## 2. Match commits to evidence
56
+
57
+ Match evidence semantically, not only by filename:
58
+
59
+ - exact or documented dirty Git lineage;
60
+ - canonical resolved core config and behavior/diff hash;
61
+ - ordered universe and checksum;
62
+ - half-open window and cache coverage;
63
+ - fees, slippage, entry delay, interval, connector, and context lineage;
64
+ - completed manifest, export hash, and Redis N/W/L/PnL reconciliation;
65
+ - result status and whether the evidence was control, candidate, diagnostic, or
66
+ release-selection grade.
67
+
68
+ If a current behavior was introduced by several commits, collapse them into one
69
+ causal hypothesis record. If one commit introduced several independent
70
+ mechanisms, split them. Never spend several trial slots on semantic duplicates.
71
+
72
+ When a change is already part of the current control but was never ablated, the
73
+ current baseline proves only its combined economics. Reconstruct an explicit
74
+ off/on ablation before claiming that the historical mechanism helped.
75
+
76
+ ## 3. Bridge prior results to the current experiment
77
+
78
+ Before freezing new families, create a bridge table containing every previously
79
+ tested or shortlisted core/gate/direction/rescue result, deduplicated by
80
+ behavior/config fingerprint:
81
+
82
+ ```text
83
+ source lineage | behavior/config delta | window | universe | costs | ALL/LONG/SHORT |
84
+ N | PnL | PF | PnL/trade | DD | cadence | evidence grade | current comparability
85
+ ```
86
+
87
+ Classify comparability as:
88
+
89
+ - `exact`: logic, config, universe, window, costs, and context match;
90
+ - `bridge-required`: the causal config is reconstructable but one or more
91
+ experiment dimensions differ;
92
+ - `diagnostic-only`: evidence cannot support a direct economic comparison.
93
+
94
+ Do not compare raw PnL from 1500d/300 symbols with 1800d/507 symbols as if it
95
+ were the same experiment. Equally, do not ignore the former. Re-score every
96
+ compatible retained candidate under the frozen objective. For every
97
+ `bridge-required` result that could reach the new Pareto frontier, rerun its
98
+ exact causal config on the new frozen window/universe/cost contract before
99
+ testing novel ideas. Attribute the delta to source/config, membership, window,
100
+ costs, or context with matched metrics where possible.
101
+
102
+ The current release control is not accepted merely because it is named `:ai`.
103
+ If it is materially worse than a prior comparable result, explain and reproduce
104
+ that regression first. A final claim that “nothing works” is invalid while a
105
+ stronger prior result remains unbridged.
106
+
107
+ ## 4. Prioritize untested hypotheses
108
+
109
+ Use reconstructable `untested-behavior` records before generating novel
110
+ families. Select at most three causally distinct records as round-1 anchors,
111
+ ranked by:
112
+
113
+ 1. strength and completeness of any adjacent/prior evidence;
114
+ 2. direct relevance to the current ALL/LONG/SHORT failure mode;
115
+ 3. causal clarity and point-in-time validity;
116
+ 4. support and cadence potential;
117
+ 5. difference from hypotheses already tested in the ledger.
118
+
119
+ An untested historical behavior consumes the normal trial budget; it is not a
120
+ free extra look. Metric-only re-scoring and exact bridge reruns of previously
121
+ tested behavior do not consume new causal slots, but remain in the global
122
+ multiple-testing ledger. Remaining records stay in the immutable backlog. They
123
+ may motivate the post-round-3 rescue board when they address a selected seed's
124
+ measured failure. A changed threshold, feature, payoff, direction policy, or
125
+ other decision behavior is a new candidate; prefer it as an anchor or, if
126
+ discovered later, spend a rescue slot. Rebuilding the unchanged control or
127
+ normalizing metadata does not count as a candidate.
128
+ Do not return `STOP_RESEARCH` or claim the strategy is exhausted while a
129
+ reconstructable untested historical hypothesis with stronger evidence than the
130
+ tested set remains unbridged and fits an available anchor/rescue slot. If the
131
+ bounded budget is exhausted first, report the remaining backlog explicitly as
132
+ `INSUFFICIENT_EVIDENCE`, not as market unsuitability.
133
+
134
+ ## 5. Required artifact
135
+
136
+ Persist and hash a machine-readable inventory before round 1:
137
+
138
+ ```json
139
+ {
140
+ "schema": "tradejs-strategy-hypothesis-inventory/v1",
141
+ "strategy": "<Strategy>",
142
+ "headGitSha": "<sha>",
143
+ "entries": [
144
+ {
145
+ "sourceCommits": ["<sha>"],
146
+ "causalFamily": "<family-or-null>",
147
+ "configOrBehaviorDelta": {},
148
+ "behaviorSha256": "<sha-or-null>",
149
+ "status": "verified-result|rejected-result|partial-result|untested-behavior|refactor-no-hypothesis|superseded-duplicate|unreconstructable",
150
+ "evidenceResearchIds": [],
151
+ "priorResult": null,
152
+ "comparability": "exact|bridge-required|diagnostic-only|null",
153
+ "decision": "round1-anchor|rescue-backlog|closed|excluded",
154
+ "reason": "<bounded reason>"
155
+ }
156
+ ],
157
+ "bridgeRuns": [],
158
+ "unresolvedBacklog": []
159
+ }
160
+ ```
161
+
162
+ Reference its SHA from every child spec, causal handoff, final note, and release
163
+ decision. An absent or stale inventory makes the release evidence incomplete.
@@ -0,0 +1,198 @@
1
+ # Professional algo-research loop
2
+
3
+ ## Contents
4
+
5
+ 1. Write the trading thesis
6
+ 2. Revalidate the candidate history
7
+ 3. Build an opportunity map
8
+ 4. Construct a hypothesis portfolio
9
+ 5. Diagnose before adapting
10
+ 6. Think in compositions
11
+ 7. Make a professional decision
12
+
13
+ The workflow is a decision framework, not a compliance checklist. Behave like
14
+ the owner of the strategy's future expectancy: understand how the edge is
15
+ supposed to work, find where the realized process breaks, and spend the bounded
16
+ trial budget on the highest-information causal interventions.
17
+
18
+ ## 1. Write the trading thesis
19
+
20
+ Before selecting variants, explain in plain language:
21
+
22
+ - who is expected to be forced or mispriced;
23
+ - what observable setup identifies that condition at signal time;
24
+ - why the proposed entry timing should improve price or confirmation;
25
+ - how the stop expresses thesis invalidation;
26
+ - how profit should be realized and why the target/trail is achievable;
27
+ - which market regimes should help or hurt;
28
+ - what cadence and event independence the mechanism can realistically support.
29
+
30
+ Compare this thesis with the current code, figures, traces, and realized trades.
31
+ List every semantic gap. A strategy with no defensible thesis is not rescued by
32
+ threshold search; use one bounded falsification family to test whether any edge
33
+ exists, then retire it if the mechanism remains unsupported.
34
+
35
+ ## 2. Revalidate the candidate history
36
+
37
+ Freeze the versioned objective from [research-objective.md](research-objective.md),
38
+ then re-score every reconstructable historical behavior candidate before
39
+ inventing a new one. A new objective changes which candidate is preferred; it
40
+ does not erase prior trials or make an exposed tail unexposed.
41
+
42
+ Separate three activities:
43
+
44
+ - metric-only re-scoring of compatible normalized trades;
45
+ - exact bridge reruns when the current frozen window/universe/cost contract
46
+ differs;
47
+ - genuinely new behavior, which belongs in the new causal-family budget.
48
+
49
+ Persist the revalidation board and global trial ledger. Use the resulting
50
+ Pareto frontier as evidence for the opportunity map, but still execute new
51
+ causal improvement rounds in the new lineage. Neither a prior `STOP_RESEARCH`
52
+ nor a newly rescored winner substitutes for the requested research attempt.
53
+
54
+ ## 3. Build an opportunity map
55
+
56
+ Decompose the performance failure across these intervention points:
57
+
58
+ 1. **Opportunity formation** — too few/many raw setups, duplicated symbols per
59
+ event, stale zones/pivots, universe or timeframe mismatch.
60
+ 2. **Entry selection and timing** — premature entry, confirmation delay,
61
+ distance/chase, quality/context discrimination, side asymmetry.
62
+ 3. **Risk geometry** — stop not tied to causal invalidation, target unreachable,
63
+ fee/slippage economics, position sizing inconsistency.
64
+ 4. **Position lifecycle** — winners returned, losers held, wrong opposite exit,
65
+ missing thesis-invalidation exit, occupancy/cooldown spillover.
66
+ 5. **Regime and direction** — edge exists only in one side or causal regime;
67
+ current gate hides it or mixes incompatible policies.
68
+ 6. **Concentration and capacity** — one timestamp, symbol, sector, or correlated
69
+ event supplies most PnL; event fan-out overstates independent support.
70
+ 7. **Execution/parity** — delayed fills, protection, fees, runtime state, or
71
+ package boundaries differ from the researched behavior.
72
+
73
+ For each point record evidence, estimated economic impact, independent support,
74
+ signal-time observability, implementation complexity, and a falsifying result.
75
+ Use `unknown`, not invented precision.
76
+
77
+ The opportunity map must identify:
78
+
79
+ - the largest loss budget that a causal intervention can plausibly remove;
80
+ - the strongest existing edge worth protecting;
81
+ - the main cadence bottleneck;
82
+ - the main tail/drawdown source;
83
+ - the cheapest experiment that distinguishes two competing explanations.
84
+
85
+ When one isolated global config change improves one side and worsens the other,
86
+ record a directional-parameter opportunity. Use the dedicated classifier and
87
+ [directional-parameter-split.md](directional-parameter-split.md) rather than
88
+ discarding the field, accepting the aggregate compromise, or duplicating every
89
+ parameter speculatively.
90
+
91
+ Persist and hash this map before round 1. Do not confuse a report containing
92
+ many metrics with a diagnosis that ranks actionable causes.
93
+
94
+ ## 4. Construct a hypothesis portfolio
95
+
96
+ Choose three causally distinct families from the opportunity map, not from a
97
+ generic parameter menu. The portfolio must include these roles when possible:
98
+
99
+ - **Exploit** — preserve or amplify the strongest evidenced edge;
100
+ - **Repair** — attack the largest attributable loss or lifecycle failure;
101
+ - **Explore/falsify** — test a distinct market mechanism or the counter-thesis
102
+ most likely to invalidate the current explanation.
103
+
104
+ Generate at least two candidate mechanisms for every role before choosing the
105
+ anchor. Rank them qualitatively by:
106
+
107
+ `expected economic impact × information gain × support ÷ complexity/risk`.
108
+
109
+ Do not pretend this score is statistically precise. Its purpose is to force an
110
+ explicit choice between meaningful experiments.
111
+
112
+ Good variants change one causal transition: setup formation, confirmation,
113
+ invalidation, payoff, exit, or gate decision. A bundle is allowed only when its
114
+ parts are inseparable for the thesis and a matching ablation is included.
115
+
116
+ Bad variants include:
117
+
118
+ - adjacent thresholds chosen only because a nearby value looked profitable;
119
+ - filters defined from exit reason, realized PnL, future regime, or delayed fill;
120
+ - broad indicator combinations without a market-mechanism claim;
121
+ - deleting a losing side from raw evidence;
122
+ - reducing cadence until a few correlated winners remain.
123
+
124
+ ## 5. Diagnose before adapting
125
+
126
+ After each round, answer these questions before creating children:
127
+
128
+ 1. Did the intended trace transition actually change?
129
+ 2. Was the PnL delta caused by matched-trade improvement, removed losers, added
130
+ winners, or occupancy spillover?
131
+ 3. Is the improvement independent across events, symbols, folds, and regimes?
132
+ 4. Did costs, drawdown, or tail losses move consistently with the thesis?
133
+ 5. Which observation supports or falsifies the mechanism?
134
+ 6. What is now the highest-value uncertainty?
135
+
136
+ Update a belief ledger for every family:
137
+
138
+ ```json
139
+ {
140
+ "family": "<id>",
141
+ "priorClaim": "<causal claim>",
142
+ "observations": ["<metric/trace/identity facts>"],
143
+ "mechanismVerdict": "supported|falsified|inconclusive",
144
+ "protectedEdge": "<edge the child must retain>",
145
+ "remainingFailure": "<dominant failure>",
146
+ "nextExperiment": "<single discriminating intervention>",
147
+ "falsifier": "<result that retires the family>"
148
+ }
149
+ ```
150
+
151
+ - If supported, refine the remaining failure without discarding the protected
152
+ edge.
153
+ - If inconclusive, prefer an ablation or higher-information contrast over a
154
+ smaller threshold nudge.
155
+ - If falsified, change mechanism or retire the family; do not rescue the label.
156
+
157
+ Outcome-derived cohorts may diagnose where money was lost. Translate them into
158
+ a signal-time observable hypothesis and validate it on a later partition; never
159
+ turn the outcome cohort itself into a filter.
160
+
161
+ ## 6. Think in compositions
162
+
163
+ The product is core plus deterministic gate, not a raw-core beauty contest.
164
+
165
+ - A high-cadence weak core may be valuable if a causal gate retains enough
166
+ independent positive events.
167
+ - A profitable but sparse gate is a clue, not a release: identify why it wins,
168
+ widen support through causal neighboring setups, or preserve it as one sleeve
169
+ of the same strategy composition.
170
+ - A profitable direction mixed with a losing direction requires the explicit
171
+ direction-policy checkpoint.
172
+ - A recent regime pocket may justify micro-forward monitoring, but never a
173
+ silently fitted historical rule.
174
+
175
+ Optimize the hierarchy from [research-objective.md](research-objective.md):
176
+ out-of-sample expectancy per risk after costs, selection-adjusted Sharpe,
177
+ drawdown/tail robustness, temporal stability, independent support, and
178
+ executable cadence. Never maximize PnL, Sharpe, win rate, a streak, a recent
179
+ window, or cadence alone.
180
+
181
+ ## 7. Make a professional decision
182
+
183
+ At every checkpoint choose one concrete action:
184
+
185
+ - run the next highest-information experiment;
186
+ - repair invalid evidence and rerun;
187
+ - carry a side-qualified candidate into gate research;
188
+ - select one immutable prospective composition;
189
+ - start/prepare the authorized risk-1 micro-forward;
190
+ - retire a falsified family with a stated reason.
191
+
192
+ Do not answer with a passive blocker when a safe in-scope experiment can reduce
193
+ the uncertainty. Do not build unrelated infrastructure merely because it would
194
+ make the study ideal. Add infrastructure only when it is the smallest path to
195
+ distinguish candidates or establish runtime parity.
196
+
197
+ The final narrative must say what was learned about the market mechanism, not
198
+ only which thresholds won.