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:
@@ -316,8 +316,29 @@ def get_trades():
|
||||
)
|
||||
rows = cur.fetchall() or []
|
||||
cur.close()
|
||||
|
||||
# Convert created_at to UTC timestamp (seconds) for frontend
|
||||
# This ensures consistent timezone handling
|
||||
processed_rows = []
|
||||
for row in rows:
|
||||
trade = dict(row)
|
||||
created_at = trade.get('created_at')
|
||||
if created_at:
|
||||
if hasattr(created_at, 'timestamp'):
|
||||
# datetime object - convert to UTC timestamp
|
||||
trade['created_at'] = int(created_at.timestamp())
|
||||
elif isinstance(created_at, str):
|
||||
# ISO string - parse and convert
|
||||
try:
|
||||
from datetime import datetime
|
||||
dt = datetime.fromisoformat(created_at.replace('Z', '+00:00'))
|
||||
trade['created_at'] = int(dt.timestamp())
|
||||
except Exception:
|
||||
pass
|
||||
processed_rows.append(trade)
|
||||
|
||||
# Frontend expects data.trades; keep data.items for compatibility with list-style components.
|
||||
return jsonify({'code': 1, 'msg': 'success', 'data': {'trades': rows, 'items': rows}})
|
||||
return jsonify({'code': 1, 'msg': 'success', 'data': {'trades': processed_rows, 'items': processed_rows}})
|
||||
except Exception as e:
|
||||
logger.error(f"get_trades failed: {str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
@@ -833,7 +854,24 @@ def get_strategy_notifications():
|
||||
rows = cur.fetchall() or []
|
||||
cur.close()
|
||||
|
||||
return jsonify({'code': 1, 'msg': 'success', 'data': {'items': rows}})
|
||||
# Convert created_at to UTC timestamp (seconds) for frontend
|
||||
processed_rows = []
|
||||
for row in rows:
|
||||
item = dict(row)
|
||||
created_at = item.get('created_at')
|
||||
if created_at:
|
||||
if hasattr(created_at, 'timestamp'):
|
||||
item['created_at'] = int(created_at.timestamp())
|
||||
elif isinstance(created_at, str):
|
||||
try:
|
||||
from datetime import datetime
|
||||
dt = datetime.fromisoformat(created_at.replace('Z', '+00:00'))
|
||||
item['created_at'] = int(dt.timestamp())
|
||||
except Exception:
|
||||
pass
|
||||
processed_rows.append(item)
|
||||
|
||||
return jsonify({'code': 1, 'msg': 'success', 'data': {'items': processed_rows}})
|
||||
except Exception as e:
|
||||
logger.error(f"get_strategy_notifications failed: {str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user