fix: Multiple bug fixes and improvements

- Fix Invalid Date display in Dashboard notifications
- Fix timezone offset (8 hours) in Trading Records time display
- Fix position closing failures due to commission discrepancies (fetch actual exchange position size for reduce_only orders)
- Fix IBKR connection error 'no current event loop in thread' by ensuring asyncio event loop exists
- Fix duplicate orders on same candle by extending signal deduplication to close signals
- Add responsive design for Profile page (mobile-friendly)
- Remove unused strategy_code module and database table
- Fix LLM service to support multiple providers (OpenRouter, OpenAI, DeepSeek, Grok, Google)
- Add auto-detection of configured LLM provider based on API key availability
- Fix AI code generation to use unified LLMService with proper provider selection
- Fix crypto symbol format handling (ETH/USDT no longer becomes ETH/USDT/USDT)
- Fix Commission display showing '0E-8' in Trading Records
- Fix P&L display for signal-only trades (show '--' for unrealized P&L)
- Fix OAuth login not updating last_login_at for new users
- Add migration script for notification_settings column
- Update env.example with new LLM provider configurations
- Remove ESLint rule that was not defined in config
This commit is contained in:
TIANHE
2026-01-24 03:22:14 +08:00
parent 7de1570b3a
commit f4e5a9f8e0
22 changed files with 1358 additions and 464 deletions
@@ -2370,11 +2370,14 @@ class TradingExecutor:
cooldown_sec = 30 # keep small; worker already retries the claimed order via attempts/max_attempts
try:
stsig = int(signal_ts or 0)
# Strict "same candle" de-dup should ONLY apply to open signals.
# Rationale: on higher timeframes (e.g. 1D), scale-in signals (add_*) may legitimately trigger
# multiple times within the same candle/day as price evolves; we must not block them by candle key.
# Strict "same candle" de-dup applies to open and close signals.
# Rationale:
# - open_* signals should only trigger once per candle (prevents repeated entries)
# - close_* signals should only trigger once per candle (prevents repeated close attempts)
# - add_*/reduce_* signals may legitimately trigger multiple times within same candle
# as price evolves for DCA/scaling strategies
sig_norm = str(signal_type or "").strip().lower()
strict_candle_dedup = stsig > 0 and sig_norm in ("open_long", "open_short")
strict_candle_dedup = stsig > 0 and sig_norm in ("open_long", "open_short", "close_long", "close_short")
if strict_candle_dedup:
cur.execute(