Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 2.53 KB

File metadata and controls

46 lines (37 loc) · 2.53 KB

Part 1 — per-strategy buy buffer

momentum is the template: it has its own price_buffer/fair_buffer and uses them directly. To give late_entry (and deep_value/adding)

their own, edit 3 places per strategy:

1. src/config.rs — add the fields to the strategy's config struct

  • LateEntry struct at config.rs:205 — add pub price_buffer: f64, and pub fair_buffer: f64,, and defaults in its Default impl (e.g. late_entry higher: price_buffer: 0.03).
  • Copy exactly how Momentum does it: fields at config.rs:156-157, defaults at config.rs:170-171.

2. trading-engine-rust/config/strategy.toml — add the values

  • Under [strategy.late_entry] (line 55), add: price_buffer = 0.03 fair_buffer = 0.04
  • (Template: [strategy.momentum] at line 33, price_buffer/fair_buffer at 42–43.)

3. The strategy file — use the local config instead of the global

  • src/strategy/late_entry.rs:53 — change: let limit = buy_limit(ask, fair, ctx.cfg.execution.entry_price_buffer, ctx.cfg.execution.entry_fair_buffer);
  • to: let limit = buy_limit(ask, fair, l.price_buffer, l.fair_buffer);
  • (l = &ctx.cfg.strategy.late_entry is already bound at line 12/20.)
  • Same for deep_value.rs:54 → d.price_buffer, d.fair_buffer, and adding.rs:48 (bind let a = &ctx.cfg.strategy.adding; first).

pre-commit test routine (the commands)

Run from trading-engine-rust/:

  # 1. Compile — engine + all binaries (live_selftest, balance_check). Catches type/borrow errors.
  cargo build --release 

  # 2. Unit tests — all 85: signing known-answer vectors, strategy firing, exits,
  #    storage/rotation, config defaults. This is what caught your fair_buffer issue.
  cargo test --release

  # 3. Lints — treat warnings as must-fix.
  cargo clippy --release

  # 4. Config parses — a TOML syntax error is NOT caught by build/test (it's runtime),
  ##   so validate config/strategy.toml explicitly:
  python3 -c "import tomllib; tomllib.load(open('config/strategy.toml','rb')); print('TOML OK')"

Details / why each matters:

  • Build ≠ config-valid. Steps 1–3 never touch strategy.toml, so I always add step 4 — that colon bug would sail through build+test+clippy and only die on the server at startup.
  • For behavior changes (not just config), I also do a targeted runtime check: the /verify skill, or for live-order-path changes I gate with the self-test (LIVE_SELFTEST=1 ./target/release/live_selftest — places+cancels one resting order, zero fills) before any continuous live run.