Skip to content

v1.0.1 — Critical SHORT position bug fix

Choose a tag to compare

@qrak qrak released this 26 Jun 16:47
· 635 commits to master since this release

Critical Bug Fix

SHORT position price_progress always 0% in SL tightening context

The Bug

For SHORT positions, the sentinel SL value in get_position_context() was always nudged upward (+1e-8). Since SHORT stop-loss sits above entry, moving it up widens the SL rather than tightening it. The tightening evaluation returned is_tightening=False for every SHORT position, causing price_progress to always read 0.0% — regardless of actual price movement toward targets.

Impact: The LLM never saw evidence of price progress for SHORT positions, so it never suggested SL tightening via UPDATE_SL for SHORT trades.

The Fix

Direction-aware sentinel SL — changed from 1 line to 2:

Before (broken for SHORT):
proposed_sl=pos.stop_loss + 1e-8

After:
sentinel_sl = pos.stop_loss - 1e-8 if pos.direction == "SHORT" else pos.stop_loss + 1e-8
proposed_sl=sentinel_sl

  • SHORT: nudges SL down (-1e-8 toward entry) -> tightening
  • LONG: unchanged (+1e-8) — no regression

Verified

  • 25/25 SL tightening tests pass
  • Full suite: 1097 passed, 3 pre-existing live-admin failures (unrelated)
  • Direction-aware sentinel confirmed correct for both LONG and SHORT in a full codebase audit (no other directional bugs found)

Commit

81a5f90 on master