4879 Commits
Author SHA1 Message Date
gavindiazandClaude Code 8aaaf5d86a chore: ignore trading runtime state and research artifacts
CI / Backend tests (push) Canceled after 0s
CI / Foundation forecast smoke (real Torch) (push) Canceled after 0s
CI / Frontend checks (push) Canceled after 0s
state.json / journal.jsonl / breaker.json are per-process runtime state and
journal.jsonl can carry account data — never commit them. research/data,
research/models and research/reports are regenerable pipeline outputs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 20:22:12 +08:00
gavindiazandClaude Code bd2253af01 docs: sync trading/research docs and add the risk-library mapping
Root README now points at the auto-trading shell and research pipeline;
AGENTS.md gains a keep-docs-in-sync rule; trading/README.md maps every method
from the two research docs to trading/risk and documents manage_position;
research/README.md documents the backtest hook and --backtest CLI.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 20:21:46 +08:00
gavindiazandClaude Code 1bcfe6e374 feat(research): complete the offline pipeline and add live-identical backtest
research/ now runs end-to-end (fetch -> features/labels -> walk-forward ->
train -> OOS evaluate -> save), and backtest_strategy() replays the same
signal(ctx) strategy over a historical frame with the same manage_position
hook the live loop calls, simulating SL/TP, trailing, partial closes and cost
per bar. --backtest wires it into the CLI.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 20:20:49 +08:00
gavindiazandClaude Code 42627f15af feat(trading/loop): size entries from risk and manage open positions per cycle
The loop sizes entry volume by risk percent when a strategy leaves volume None
(returning to TRADING_MAX_LOTS when the broker spec or stop geometry is
missing), and gains a position-management pass that runs the strategy's
manage_position(ctx, position) hook before any new entry — executing modify /
close / partial_close through the dry-run-layered Executor. PositionAction is
the shared contract.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 20:15:16 +08:00
gavindiazandClaude Code 006a6c4763 feat(trading/strategies): add declarative strategy layer and registry
A Strategy subclass in trading/strategies/ with params_spec + signal(ctx) is now
auto-discovered by the registry (name or module path), parameterized via
TRADING_STRATEGY_PARAMS, and loadable without touching the loop or CLI. Ships
ma_cross and model_threshold; legacy bare signal(ctx) modules keep working via
FunctionStrategy.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 19:56:40 +08:00
gavindiazandClaude Code c97393c745 feat(trading/risk): abstract position-sizing and exit rules from the research docs
Moves the stop-loss and position-sizing research docs into a reusable
trading.risk package (broker / sizing / exits / guards / indicators), keeping
the docs' invariants: R frozen at entry, monotonic tightening, broker-precision
rounding, and all entry gates default-OFF behind TRADING_GUARD_*.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-25 19:55:46 +08:00
gavindiazandClaude Code a5df68a22e docs: add live trading checklist
Operator-facing pre-flight gate before real orders: MTDATA_TRADE_*
guardrail inventory with defaults, idempotency, dry-run rehearsal
(verified CLI tokens only), first-size orders and incident response.
Indexed in the README trading table.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-22 21:07:42 +08:00
gavindiazandClaude Code be65ef441b feat(trading): add dry-run execution shell skeleton
Polling signal loop with a state machine, circuit breaker, layered
dry-run execution (subprocess mtdata-cli trade_*) and a JSONL journal.
The default strategy emits no signal, so the loop is safe to run as-is;
orders never reach the broker until a strategy and the live tier are
explicitly wired up.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-22 21:07:42 +08:00
gavindiazandClaude Code ddaeb6685f feat(research): add offline research pipeline skeleton
Data -> storage (parquet/CSV) -> features/labels -> walk-forward
(strategy_validate) -> train -> evaluate, driving mtdata-cli as a
subprocess. Binary P(+1) target from triple-barrier labels; sklearn
models (optional lightgbm) persisted via ModelWrapper for the trading/
execution shell's signal(ctx) interface.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-22 21:07:42 +08:00
gavindiazandClaude Code f09790bda6 docs: restore root README and fix indicator count
Recreate the missing root README.md (pyproject.toml declares
readme = "README.md", so packaging failed without it) as an English
landing page linking to docs/, README_CN.md, and 指标列表.md. All CLI
examples were verified against the runtime tool catalog and pass
tests/core/cli/test_cli_docs.py.

Also fix a 194 -> 193 typo in README_CN.md so the indicator count
matches the runtime pandas-ta-classic catalog and 指标列表.md.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-21 22:16:05 +08:00
gavindiaz c835ba99b0 docs: update indicator catalog (193) and add detailed manual
CI / Backend tests (push) Canceled after 0s
CI / Foundation forecast smoke (real Torch) (push) Canceled after 0s
CI / Frontend checks (push) Canceled after 0s
2026-09-14 17:55:09 +08:00
gavindiaz 13f72f9187 Merge upstream/main from GitHub
CI / Backend tests (push) Canceled after 0s
CI / Foundation forecast smoke (real Torch) (push) Canceled after 0s
CI / Frontend checks (push) Canceled after 0s
2026-09-03 21:22:59 +08:00
Emerson Gomes e4aa2fa14b fix(stress-test): add uniform --shock-pct flag 2026-09-02 21:00:05 -05:00
Emerson Gomes a839af8553 fix(screener): add formatted market-cap beside the raw value 2026-09-02 21:00:05 -05:00
Emerson Gomes 47958be8db fix(market-status): report closed session instead of stale quote 2026-09-02 20:59:59 -05:00
Emerson Gomes f91047af13 fix(market): pass quote point and radar rank_order 2026-09-02 20:59:59 -05:00
Emerson Gomes 5ffa42814f fix(confluence): add side filter for support vs resistance 2026-09-02 20:59:59 -05:00
Emerson Gomes 3d99201815 fix(barriers): infer grid_style=preset from --preset 2026-09-02 20:59:50 -05:00
Emerson Gomes ef44bd1681 fix(output): keep spread completeness and standard model rows 2026-09-02 20:59:50 -05:00
Emerson Gomes 2644bd7b27 fix(snapshot): project labeled HMM regime fields 2026-09-02 20:59:46 -05:00
Emerson Gomes 1885dce709 fix(calendar): accept comma-separated impact levels 2026-09-02 20:49:30 -05:00
Emerson Gomes 74e27841e7 fix(calendar): warn when non-US filters match no Finviz events 2026-09-02 20:48:11 -05:00
Emerson Gomes b009dec8ef fix(trade-history): convert open-position timestamps to UTC 2026-09-02 20:47:12 -05:00
Emerson Gomes bd50cc2e63 fix(output): disclose stale tickets, skip reasons, and compact trust cues
Map stale position quotes to tickets, warn on null tick spreads, and surface scan skip reasons plus bar-vs-live direction divergence so compact output can be acted on without a second full-detail call.
2026-09-02 20:05:01 -05:00
Emerson Gomes 86c1266e23 fix(forecast): break tune/optimize import cycle 2026-09-02 19:20:51 -05:00
Emerson Gomes a67b2e3bf3 fix(barriers): use shared Monte Carlo method set 2026-09-02 19:20:49 -05:00
Emerson Gomes 4f8486ce5a fix(mcp): stop swallowing tool-call coercion errors 2026-09-02 19:20:47 -05:00
Emerson Gomes 007767c226 fix(schema): reject overflowing minutes_back at request boundary 2026-09-02 19:20:44 -05:00
Emerson Gomes 8cddcd4195 fix(market-status): render exact hours as readable words 2026-09-02 19:20:42 -05:00
Emerson Gomes 1f29ec0d8c fix(wait): ignore replayed position_opened history deals
Only match position_opened from DEAL_ENTRY_IN when the ticket is still open and was not already in the wait baseline, so closed fills cannot wake the watcher.
2026-09-02 14:07:15 -05:00
Emerson Gomes f7698a19f5 fix(mcp): anchor JSON Schema patterns for llama.cpp
llama.cpp drops unanchored pattern constraints and PCRE shorthands such
as \S, which produced incomplete grammar conversion warnings. Use
anchored, hex-escaped whitespace classes instead.
2026-09-02 07:38:25 -05:00
Emerson Gomes 0f709cb94e fix(wait): splice live quotes instead of aborting on history lag
Wait-event market watchers now keep tick history for the window and attach the executable quote when the archive lags, using a spread/tick/relative agreement band that works for FX, crypto, and stocks.
2026-09-01 21:13:59 -05:00
Emerson GomesandCursor 70b53189b9 fix(patterns): stop silent degradation and untrue availability claims
Pattern detection had two recurring defects: a fallback that quietly
substituted different data than the caller asked for, and metadata that
asserted a point-in-time or guarantee the computation could not support.

Data substitution:

- Denoising on the classic/harmonic/elliott/fractal path smoothed only
  `close`, so the smoothed close routinely fell outside its own raw candle
  and ~68% of rows were reverted to raw -- preferentially at the local
  extremes pivot detection keys on. Require the full OHLC set, matching the
  candlestick path, and reject an explicitly partial column list.
- A failed denoise still echoed the requested spec with
  `preprocessing_causality: "causal"`. Report `denoise_applied: false`,
  `denoise_error` and `preprocessing_causality: "raw_prices"` instead.
- One non-finite OHLC value makes the aggregate candlestick dispatcher
  throw, leaving only the few directly-attached detectors. The failure was
  unrecorded because `dispatch_names` is the string "all", not a list. Add a
  `detector_coverage` block plus a warning, and surface names the installed
  backend does not provide (`outside` is absent from pandas-ta-classic).

Untrue claims:

- Elliott `available_at_index` was 67% irreproducible when re-running over a
  window truncated at that index, because pivot spacing and (under the
  default `scale_mode="auto"`) the swing scale are whole-window statistics.
  Report the right edge as the guarantee and demote the confirmation-derived
  figure to `earliest_possible_index_estimate` with a caveat, matching the
  harmonic contract. Also track when a min-distance choice was settled so a
  pivot surviving a later challenge is not claimed knowable at its own bar.
- The "no patterns detected in N bars" note omitted `observed_bars` outside
  candlestick mode, asserting absence over bars never fetched.
- `df.attrs["pattern_ohlc_fallback"]` was written for the API layer to
  disclose and never read, and was written after a slice so it could not
  reach the caller. Wire it into warnings and report `analyzed_bars` when a
  detector caps its own input window.
- `data_freshness` emitted the literal string "None", which is truthy and
  then broke the year parse that would have raised a staleness warning.

Silent no-ops and misattribution:

- The documented `mode="all"` namespacing (`{"harmonic": {...}}`) reported
  the section name as an invalid key and failed the fractal and harmonic
  sections. Validate a section's contents against that detector, and
  attribute an unknown top-level key to every detector that could own it
  rather than only fractal and harmonic.
- `detail="summary"` dropped `warnings`, `data_quality`, `candles` and
  `effective_window` -- exactly the fields that say not to trust a result.
- `min_strength`, `min_gap` and `robust_only` were accepted and ignored
  outside candlestick mode; reject a non-default value like the adjacent
  `engine` and `whitelist` guards do.
- Fractal `include_stale_levels` was discarded by the visibility allowlist
  unless `include_completed` was also set, and stale rows were hidden
  without being counted.
- Six Elliott config knobs were unread: the four rule/classifier blend
  weights (no blend exists; an existing test pinned that) and two additive
  unconfirmed-pattern penalties superseded by the confidence cap. Remove
  them so they become explicit unknown-key errors.

Scoring correctness:

- Candlestick geometry keyed its body-size expectation off the deprioritize
  set, so hammers, shooting stars and harami were scored as if a large body
  confirmed them, while marubozu was scored as if a small one did. Classify
  the expectation per pattern.
- A zero-range bar scored `body_ratio = 0.5` ("unknown"), making a perfect
  doji rank below an imperfect one; it has a zero body by construction.
- `min_gap` spaced candidates selected at threshold 0.0, so a weak hit could
  consume the slot and erase a qualifying signal one bar away. Space among
  rows that meet `min_strength`.
- `inside` was signed by candle colour, contradicting the harami detected on
  the identical bars and defeating the dedupe that exists to replace it.
  Report it as non-directional and let the specific form suppress it.
- A hikkake confirmation bar (magnitude 200) was given the three-bar setup
  span, putting `start_index` inside the setup.
- Candlestick `recency` used the reported bar count while `end_index` indexes
  the warmup-inclusive frame, clamping `bars_ago` to 0 for every pattern in
  the warmup span and biasing the cross-detector ranking.
- Volume-confirmation warmup ignored pattern span, so a multi-bar pattern on
  the first visible bar had a short baseline.

Verified: ruff clean, 10115 backend tests pass, schemas 83/83.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 13:54:32 -05:00
Emerson GomesandCursor 818c918143 fix(barriers): detect t=0 breaches and correct simulation statistics
TP/SL distances are measured from the entry quote while simulated paths are
scored from the exit quote, so a barrier inside the spread was already crossed
before the first simulated bar. Neither close comparisons nor the Brownian
bridge could observe it, and both tools reported ordinary-looking probabilities
for a position that would resolve instantly.

The minimum barrier distance used the payoff deduction, which excludes spread
when live quotes embed it in path geometry, so the round-trip cost floor
silently dropped spread exactly when it mattered most.

Antithetic paths are mirrored pairs, so p(1-p)/n misstated sampling error in
both directions: too narrow for prob_no_hit, too wide for monotone first-hit
probabilities. Each Wilson interval is now sized by its own design effect.
Independent-seed and walk-forward evidence can close the trade gate instead of
only reporting optimism, and cross-seed stability now separates estimator noise
from selection churn rather than blaming simulation size for a missing edge.

Also disclose the implicit min_prob_resolve floor and the realized-payoff
profit_factor basis, reject mode-mismatched min_barrier_* keys instead of
ignoring them, and fix the labeling history guard, the silent high_low fallback
to close-only detection, and the inert same_bar_policy in close-only mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 12:03:23 -05:00
Emerson Gomes 7b4348574a test(web): align history timestamp default 2026-09-01 11:06:40 -05:00
Emerson Gomes f696e34aab fix(mt5): detect unloaded timezone settings 2026-09-01 11:06:20 -05:00
Emerson Gomes 9e7c16da22 fix(wait): default omitted watchers to empty list 2026-09-01 10:49:40 -05:00
Emerson Gomes e4a6aea9cb fix(data): simplify wait event timing 2026-09-01 09:24:32 -05:00
Emerson Gomes 08b3e6bfb6 fix(forecast): correct barrier calculations 2026-09-01 08:08:48 -05:00
Emerson Gomes 6534c4696b fix(barriers): accept pips in probability forecast 2026-08-31 21:47:49 -05:00
Emerson Gomes 76f5f0c432 fix(forecast): accept prevalidated barrier specs 2026-08-31 19:50:22 -05:00
Emerson Gomes 8309e3131e feat(barriers): add pips unit, rename --barrier, and align defaults
Add unit=pips via forex_pip_size while keeping ticks as broker tick/point. Rename labels_triple_barrier --barriers to --barrier with no alias, and default forecast_barrier_optimize to mc_gbm_bb to match forecast_barrier_prob.
2026-08-31 15:45:54 -05:00
Emerson Gomes 24f019920b fix(volatility): note decimal vol vs percent-point barriers
Keep compact unit on volatility_term_structure and explain that 0.0465 decimal times 100 is percent-points for labels_triple_barrier and forecast_barrier_prob.
2026-08-31 15:45:45 -05:00
Emerson Gomes 42cf5a37d4 fix(forecast): stop claiming stored models after artifact removal
When forecast_task_status finds model_store_status other than present, rewrite the completion message and set model_reusable false so expired or deleted artifacts are not advertised as reusable.
2026-08-31 15:45:45 -05:00
Emerson Gomes e60b41010b fix(options): stop labeling delayed Yahoo chains as unusable
Key option_chain_quality on missing quote timestamps even when last-trade contract_as_of exists, point remediation at Tradier configuration, and name MTDATA_OPTIONS_PROVIDER/MTDATA_OPTIONS_API_KEY in Heston rejection copy. Anonymous Yahoo status stays ready_degraded.
2026-08-31 15:45:29 -05:00
Emerson Gomes 43ba46caba fix(data): suffix indicator columns computed from denoised prices
Close-only pre-TI denoise was feeding smoothed close into RSI while leaving the column named rsi_14. Rename those columns whenever the indicator input was denoised, emit indicator_column_suffix only after a rename, and keep indicator_input on compact output.
2026-08-31 15:45:24 -05:00
Emerson Gomes bf8e7dafb1 docs(help): disclose options limits, BSM r/q, and top-markets time
Document compact options_expirations default of 12 and has_more, map barrier risk_free_rate/dividend_yield to r/q (FX q as foreign/base), and say top-markets time follows data_source.
2026-08-31 15:35:07 -05:00
Emerson Gomes b8f30196f4 fix(output): split live-quote warnings from non-viable execution
Emit execution_not_ready or optimizer_non_viable instead of quote_not_live when the quote is live, and skip freshness_unverified when stress-test marks are not_applicable.
2026-08-31 15:34:54 -05:00
Emerson Gomes d640ee79f1 fix(trade): keep preview quote gate, protection errors, and risk units
Pass compacted quote_context, sl_tp_error, and validation_error through compact TOON, keep lookback_bars on support_resistance, and label candidate risk_currency as account_currency.
2026-08-31 15:34:49 -05:00
Emerson Gomes bf91c0d5ff fix(calendar): disclose that mt5 is not a calendar provider
Update the source Field and help so auto uses Finviz and source=mt5 is documented as a capability error.
2026-08-31 15:34:42 -05:00