fix: ensure all timestamps use UTC timezone

- Add NowFunc to GORM config for UTC auto-generated timestamps
- Add .UTC() to all time.UnixMilli() calls in trader files
- Add .UTC() to all time.Now() calls in store and api files
- Fix TypeScript unused imports in frontend
This commit is contained in:
tinkle-community
2026-01-04 20:03:56 +08:00
parent 50923f6a2e
commit 5c9e134e99
25 changed files with 96 additions and 85 deletions

View File

@@ -637,7 +637,7 @@ func (at *AutoTrader) runCycle() error {
TakeProfit: d.TakeProfit,
Confidence: d.Confidence,
Reasoning: d.Reasoning,
Timestamp: time.Now(),
Timestamp: time.Now().UTC(),
Success: false,
}
@@ -1976,7 +1976,7 @@ func (at *AutoTrader) recordPositionChange(orderID, symbol, side, action string,
Quantity: quantity,
EntryPrice: price,
EntryOrderID: orderID,
EntryTime: time.Now(),
EntryTime: time.Now().UTC(),
Leverage: leverage,
Status: "OPEN",
}
@@ -1996,7 +1996,7 @@ func (at *AutoTrader) recordPositionChange(orderID, symbol, side, action string,
at.id, at.exchangeID, at.exchange,
symbol, side, action,
quantity, price, fee, 0, // realizedPnL will be calculated
time.Now(), orderID,
time.Now().UTC(), orderID,
); err != nil {
logger.Infof(" ⚠️ Failed to process close position: %v", err)
} else {
@@ -2049,8 +2049,8 @@ func (at *AutoTrader) createOrderRecord(orderID, symbol, action, positionSide st
ReduceOnly: reduceOnly,
ClosePosition: reduceOnly,
OrderAction: orderAction,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
CreatedAt: time.Now().UTC(),
UpdatedAt: time.Now().UTC(),
}
}
@@ -2091,7 +2091,7 @@ func (at *AutoTrader) recordOrderFill(orderRecordID int64, exchangeOrderID, symb
CommissionAsset: "USDT",
RealizedPnL: 0, // Will be calculated for close orders
IsMaker: false, // Market orders are usually taker
CreatedAt: time.Now(),
CreatedAt: time.Now().UTC(),
}
// Calculate realized PnL for close orders