mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 09:11:03 +08:00
feat: order sync for multiple exchanges and position tracking improvements
- Add order sync support for Binance, Hyperliquid, Bybit, OKX, Bitget, Aster exchanges - Fix weighted average exit price calculation for partial closes - Handle position flip (翻仓) scenarios correctly - Fix symbol normalization (ETH vs ETHUSDT) - Skip order recording for exchanges with OrderSync to avoid duplicates - Add chart timezone localization
This commit is contained in:
@@ -187,7 +187,7 @@ func (s *OrderStore) CreateOrder(order *TraderOrder) error {
|
||||
order.FilledQuantity, order.AvgFillPrice, order.Commission, order.CommissionAsset,
|
||||
order.Leverage, order.ReduceOnly, order.ClosePosition, order.WorkingType, order.PriceProtect,
|
||||
order.OrderAction, order.RelatedPositionID,
|
||||
now.Format(time.RFC3339), now.Format(time.RFC3339),
|
||||
formatTimeOrNow(order.CreatedAt, now), formatTimeOrNow(order.UpdatedAt, now),
|
||||
formatTimePtr(order.FilledAt),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -550,3 +550,11 @@ func formatTimePtr(t time.Time) interface{} {
|
||||
}
|
||||
return t.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
// formatTimeOrNow returns the formatted time if not zero, otherwise returns now
|
||||
func formatTimeOrNow(t time.Time, now time.Time) string {
|
||||
if t.IsZero() {
|
||||
return now.Format(time.RFC3339)
|
||||
}
|
||||
return t.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user