@tradejs/cli 3.1.28-beta.258 → 3.1.29-beta.259

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.
package/README.md CHANGED
@@ -80,6 +80,132 @@ npx tradejs-app dev
80
80
 
81
81
  ## Notes
82
82
 
83
+ ### Jev signal assessment (next package release)
84
+
85
+ This workflow requires the CLI, runtime and app versions containing the Jev
86
+ integration; it is not available in earlier published versions. In Account
87
+ settings, open **Jev**, choose OpenRouter, TypeSafe or a custom Decisions API,
88
+ and save its key, full decision endpoint and versioned model. These credentials
89
+ are separate from AI / LLM settings. A chat-completions endpoint is not supported.
90
+
91
+ Run commands from your generated project's root. Start with a bounded historical
92
+ window and one strategy configuration:
93
+
94
+ ```bash
95
+ # Enrich signals with Jev. Calls the provider for missing recordings.
96
+ yarn exec tradejs backtest -c TrendFollow:base -d 30 --cacheOnly --jev
97
+
98
+ # Repeat with recorded answers only. Missing answers fail the run.
99
+ yarn exec tradejs backtest -c TrendFollow:base -d 30 --cacheOnly --jev --jevRecorded
100
+ ```
101
+
102
+ Without `--jev`, ordinary backtests do not evaluate Jev, even if a configuration
103
+ contains `JEV`. Use `--ai --jev` to save completed trades with Jev features for
104
+ AI training. `--jev` alone records Jev assessments without enabling AI export.
105
+ Jev can ask eight independent questions: trend, swing, current participation,
106
+ setup participation, entry extension, confirmation, setup strength, and geometry.
107
+ It asks each question only when the corresponding signal-time facts exist and
108
+ marks missing facts explicitly. The shared projection
109
+ selects a few signal-time trend, swing, volume, delta, entry-distance and
110
+ extension facts. It does not send the whole `baseContext`, raw figure points,
111
+ calculated gate scores, or outcome fields. The normalized answers are stored in
112
+ `signal.assessment` and the compact `additionalIndicators.jev` feature group,
113
+ which is available to the strategy's AI gate and AI export. Jev scores do not
114
+ approve or reject entries. Backtests do not apply the AI gate; `ai-train`
115
+ evaluates it on exported outcomes, while runtime follows `AI_MODE`.
116
+
117
+ Any strategy can optionally attach `jevEvidence` through its `StrategyAPI.entry`
118
+ `additionalIndicators` with a version, `knownAt` timestamp, up to 16 scalar
119
+ setup facts and 16 scalar geometry facts:
120
+
121
+ ```ts
122
+ additionalIndicators: {
123
+ jevEvidence: {
124
+ version: 'setup-v1',
125
+ knownAt: timestamp,
126
+ facts: { confirmationCount: 2, entryExtensionAtr: 0.4 },
127
+ geometry: { normalizedWidthAtr: 1.5 },
128
+ },
129
+ },
130
+ ```
131
+
132
+ This is a strategy-neutral contract. Questions without supporting facts are
133
+ omitted and their scores remain null; no strategy name is hard-coded in Jev.
134
+ Invalid or future-dated evidence fails validation.
135
+ The signal builder moves `jevEvidence` out of ordinary `additionalIndicators`,
136
+ so AI payloads and prompts do not receive these repeated facts unless Jev
137
+ produces its compact scores.
138
+
139
+ The default minimum score is `0.5` per dimension. A strategy configuration may
140
+ set `JEV.minScores` and `JEV.requireGeometry` for local Jev research. Backtests
141
+ preserve these fields when `--jev` selects the evaluator. Absent geometry is
142
+ marked as missing; invalid geometry and invalid trade levels remain visible in
143
+ the assessment. Jev does not decide whether to enter a trade. These are
144
+ assessment scores, not calibrated probabilities of profitable trades.
145
+
146
+ Provider responses and decisions are saved under `data/ai/jev`, or the directory
147
+ selected with `--jevRecordsDir`. Input, selected question version and provider
148
+ identity determine each signal record. Equivalent facts reuse one provider
149
+ response even when signal timestamps or symbols differ. Input v4 records
150
+ explicitly store missing facts and their sources. The changed question hash
151
+ prevents older four-question recordings and local models from being replayed as
152
+ answers to the new questions.
153
+ `--jevRecorded` requires the same signal-time input facts, question set and
154
+ provider as the recording run. A shorter backtest may warm up indicators from
155
+ a different history or reach the same date with a different trade state, so its
156
+ record ID can differ even when the signal date overlaps a longer run.
157
+ Using identical date bounds is essential for reproducible comparisons. Filtering
158
+ entries may change subsequent strategy state, so an observe run does not
159
+ necessarily contain every candidate required by a gated run.
160
+
161
+ Train a local deterministic gate from the recorded teacher answers:
162
+
163
+ ```bash
164
+ yarn exec tradejs jev --action export --strategy TrendFollow --out data/ai/jev/study.jsonl
165
+ yarn exec tradejs jev --action train --input data/ai/jev/study.jsonl --out data/ai/jev/gate.json
166
+ yarn exec tradejs jev --action compare --input data/ai/jev/study.jsonl --model data/ai/jev/gate.json --out data/ai/jev/comparison.json
167
+ yarn exec tradejs backtest -c TrendFollow:base -d 30 --cacheOnly --jev --jevModelFile data/ai/jev/gate.json
168
+ ```
169
+
170
+ `export --input <completed-ai-export.jsonl>` optionally joins completed outcomes
171
+ by their exact assessment record id. Rejected candidates still provide teacher
172
+ labels, but have no observed trade outcome. Do not treat missing outcomes as
173
+ losses. `evaluate --input <ai-export.jsonl>` reads the exact Jev recordings
174
+ linked to completed `--ai --jev` rows. An `--ai`-only export cannot reconstruct
175
+ the original signal-time Jev facts, so `evaluate` fails with a clear message
176
+ instead of making an incomplete provider request. Pass the original
177
+ `--recordsDir` if the backtest used a custom `--jevRecordsDir`. Use a new output
178
+ path for each run.
179
+
180
+ Training fits shallow trees to Jev scores, without trade outcomes as features or
181
+ labels. It requires at least 30 samples across 10 distinct signal times, selects
182
+ one strategy and one teacher/provider lineage, and separates train/validation/test
183
+ chronologically as 60/20/20. Three additional expanding-window folds check later
184
+ periods with independently fitted trees. The report measures teacher agreement, score error
185
+ and matched-outcome economics. These summaries are not sequential portfolio
186
+ backtests and do not establish profitability. Validate a frozen gate on a later
187
+ period with `--jevModelFile` before runtime use. Studies are bounded to 20,000
188
+ rows; `--maxDepth` and `--minLeaf` control rule complexity.
189
+
190
+ For runtime, put `JEV` inside the strategy's Git-owned `config` declaration:
191
+
192
+ ```ts
193
+ JEV: {
194
+ source: 'local',
195
+ mode: 'observe',
196
+ modelFile: 'data/ai/jev/gate.json',
197
+ modelSha256: '<SHA-256 printed by jev --action train>',
198
+ }
199
+ ```
200
+
201
+ Distribute the exact model file with the deployment. Provider runtime uses
202
+ `source: 'provider'`, a pinned `provider: { endpoint, model }`, and the account's
203
+ Jev key instead of the two model-file fields. Only `mode: 'observe'` is
204
+ supported: Jev enriches the signal and the configured AI gate decides entry.
205
+ A provider failure marks Jev unavailable in runtime; an incomplete backtest
206
+ fails so its research sample stays complete. Recorded mode never calls the
207
+ provider. Enabling Jev does not enable order placement.
208
+
83
209
  - `@tradejs/cli` expects project wiring from `tradejs.config.ts` via `@tradejs/core/config`.
84
210
  - Local infrastructure is created through `infra-init` and started through `infra-up`.
85
211
  - Use `npx @tradejs/cli <command> --help` for command-specific flags.