feat: migrate timestamps to int64 and security improvements

- Convert all time.Time fields to int64 Unix milliseconds (UTC)
- Add PostgreSQL migration to convert timestamp columns to bigint
- Reduce Binance sync window from 7 days to 24 hours
- Fix dashboard trader name visibility (add nofx-text-main color)
- Add position value column to history table
- Remove hardcoded API keys from test files
This commit is contained in:
tinkle-community
2026-01-06 15:56:07 +08:00
parent 5c4c9cdc99
commit 799d8b9c2e
22 changed files with 1620 additions and 231 deletions

View File

@@ -40,7 +40,7 @@ func CreatePositionSnapshot(traderID, exchangeID, exchangeType string, trader Tr
logger.Infof("📥 Found %d positions on exchange", len(positions))
// Step 3: Create snapshot record for each position
now := time.Now()
nowMs := time.Now().UnixMilli()
createdCount := 0
for _, posMap := range positions {
@@ -74,18 +74,18 @@ func CreatePositionSnapshot(traderID, exchangeID, exchangeType string, trader Tr
TraderID: traderID,
ExchangeID: exchangeID,
ExchangeType: exchangeType,
ExchangePositionID: fmt.Sprintf("snapshot_%s_%s_%d", symbol, side, now.UnixMilli()),
ExchangePositionID: fmt.Sprintf("snapshot_%s_%s_%d", symbol, side, nowMs),
Symbol: symbol,
Side: side,
Quantity: positionAmt,
EntryPrice: entryPrice,
EntryOrderID: "snapshot", // Mark as snapshot
EntryTime: now,
EntryTime: nowMs,
Leverage: int(leverage),
Status: "OPEN",
Source: "snapshot", // Mark source as snapshot
CreatedAt: now,
UpdatedAt: now,
CreatedAt: nowMs,
UpdatedAt: nowMs,
}
if err := positionStore.CreateOpenPosition(snapshotPosition); err != nil {