stop-loss-check

Direction Stop-Loss Position Validation

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "stop-loss-check" with this command: npx skills add felixwayne0318/aitrader/felixwayne0318-aitrader-stop-loss-check

Stop-Loss Validation

Core Rules

Direction Stop-Loss Position Validation

LONG SL must be < entry price stop_loss_price < entry_price - PRICE_EPSILON

SHORT SL must be > entry price stop_loss_price > entry_price + PRICE_EPSILON

Note: Use PRICE_EPSILON = entry_price * 1e-8 for floating-point comparison.

Fixed Bug

Commit: 7f940fb

Problem: When market moves fast, support/resistance levels may be on wrong side of entry price, causing immediate SL trigger.

Example:

Entry: $91,626 (LONG) Support: $91,808 (above entry!) Original: SL = $91,808 × 0.999 = $91,808.10 Result: SL triggered immediately, loss -$0.18 in 820ms

Fix:

strategy/deepseek_strategy.py lines 1502-1543

PRICE_EPSILON = max(entry_price * 1e-8, 1e-8) # Relative tolerance

if side == OrderSide.BUY: default_sl = entry_price * 0.98 # Default 2% SL if self.sl_use_support_resistance and support > 0: potential_sl = support * (1 - self.sl_buffer_pct) # Validate: SL must be below entry (with epsilon tolerance) if potential_sl < entry_price - PRICE_EPSILON: stop_loss_price = potential_sl else: stop_loss_price = default_sl # Fallback to default 2% self.log.warning(f"⚠️ Support above entry, using default SL")

Test Command

cd /home/linuxuser/nautilus_AItrader source venv/bin/activate python3 test_sl_fix.py

Expected Output

============================================================ Stop-Loss Fix Validation Test

Test 1: Bug scenario: Support above entry ✅ Passed Test 2: Normal scenario: Support below entry ✅ Passed ... 🎉 All tests passed! Stop-loss fix is correct!

Key Files

File Purpose Key Lines

strategy/deepseek_strategy.py

Main strategy 1502-1602

test_sl_fix.py

Test script

Verification Steps

  • Read strategy/deepseek_strategy.py lines 1502-1602

  • Confirm stop-loss validation logic exists (with PRICE_EPSILON tolerance)

  • Run python3 test_sl_fix.py

  • All tests pass = fix is correct

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

nautilustrader

No summary provided by upstream source.

Repository SourceNeeds Review
General

server-status

No summary provided by upstream source.

Repository SourceNeeds Review
General

diagnose

No summary provided by upstream source.

Repository SourceNeeds Review
General

deploy

No summary provided by upstream source.

Repository SourceNeeds Review