com um clique
trade-safety-review
// Reviews trading code for safety invariants and code reuse. Use when modifying trading logic, orders, positions, sizing, or adding features that interact with IBKR.
// Reviews trading code for safety invariants and code reuse. Use when modifying trading logic, orders, positions, sizing, or adding features that interact with IBKR.
Debug the trading webapp frontend using Chrome DevTools MCP. Use when frontend is not behaving as expected, WebSocket connections failing, charts not rendering, or API calls returning errors.
Check PRD progress and determine next steps for the Warrior trading system. Use when user asks "what's next", wants project status, or starting a new session.
When uncertain about API behavior, library usage, or integration details, build a minimal proof-of-concept against live APIs before implementing. Prevents hallucinated solutions.
| name | trade-safety-review |
| description | Reviews trading code for safety invariants and code reuse. Use when modifying trading logic, orders, positions, sizing, or adding features that interact with IBKR. |
This skill enforces trade safety invariants and code reuse patterns for the warrior trading system.
Before implementing ANY new logic, search these locations for existing code:
| Category | Location | Existing Functions |
|---|---|---|
| Filters | ibkr-scanner-core/ibkr_scanner_core/logic/filters.py | pct_change(), passes_price_filter(), passes_pct_change_filter(), passes_float_filter(), passes_rvol_filter(), passes_numeric_filters(), news_is_recent(), is_market_hours() |
| Trading | ibkr-scanner-core/ibkr_scanner_core/logic/trading.py | trade_windows(), risk_size(), TradeLimitTracker, parse_time() |
| Models | ibkr-scanner-core/ibkr_scanner_core/models/ | Candidate, NewsItem, CatalystVerdict, WatchlistItem, SignalEvent, DecisionSnapshot |
| Category | Location | Contents |
|---|---|---|
| Indicators | candle-patterns/candle_patterns/indicators/ | ema.py, macd.py, rvol.py, vwap.py, trend_confirmation.py |
| Patterns | candle-patterns/candle_patterns/ | bull_flag.py, micro_pullback.py, vwap_break.py, opening_range_retest.py, base.py |
| Fixtures | candle-patterns/tests/fixtures/ | Test data for patterns and exit signals |
Before writing new logic, run these searches:
# Search for function name or similar logic
grep -r "function_name_or_keyword" ibkr-scanner-core/ibkr_scanner_core/
grep -r "function_name_or_keyword" candle-patterns/candle_patterns/
# Search for similar calculations
grep -r "pct_change\|percent\|change" ibkr-scanner-core/
grep -r "vwap\|rvol\|ema\|macd" candle-patterns/
If similar logic exists:
# UPDATE THESE VALUES WHEN CHANGING ACCOUNTS
account_type: paper # paper | live
max_loss_per_trade: 50.00 # USD
max_trades_per_day: 3
flatten_time: "15:50" # ET
entry_window_start: "09:30" # ET
entry_window_end: "11:00" # ET
When modifying ANY of these files, verify ALL invariants:
Files requiring safety review:
ibkr-scanner-core/ibkr_scanner_core/logic/trading.pyibkr-scanner-core/ibkr_scanner_core/trading/trade_gate.py (when created)ibkr-scanner-core/ibkr_scanner_core/trading/order_manager.py (when created)ibkr-scanner-core/ibkr_scanner_core/orchestrator.py (when created)order, trade, position, or bracket in the name# MUST default to True
paper_mode: bool = True
True# MUST default to False
auto_trade_enabled: bool = False
False# MUST use risk_size() from logic/trading.py
max_loss: float = 50.0 # Never exceed this
risk_size() function, not custom calculationmax_loss parameter respected (currently $50)# MUST use TradeLimitTracker from logic/trading.py
max_trades_per_day: int = 3
TradeLimitTracker class# MUST use trade_windows() from logic/trading.py
entry_start: str = "09:30" # ET
entry_end: str = "11:00" # ET
trade_windows() functionflatten_time: str = "15:50" # ET
When reviewing trading-related changes:
List all files modified that touch trading logic.
For each new function:
For each safety invariant:
# Filters
from ibkr_scanner_core.logic.filters import (
pct_change,
passes_numeric_filters,
news_is_recent,
is_market_hours,
)
# Trading
from ibkr_scanner_core.logic.trading import (
trade_windows,
risk_size,
TradeLimitTracker,
)
# Indicators
from candle_patterns.indicators.vwap import calculate_vwap
from candle_patterns.indicators.macd import calculate_macd
from candle_patterns.indicators.ema import calculate_ema
from candle_patterns.indicators.rvol import calculate_rvol
| Setting | Default | Why |
|---|---|---|
paper_mode | True | Prevents real money loss |
auto_trade_enabled | False | Requires explicit opt-in |
max_loss_per_trade | $50 | Caps single-trade risk |
max_trades_per_day | 3 | Caps daily exposure |
flatten_time | 15:50 ET | No overnight positions |