From 193b255f4120f7c90628be434c2b44b63a41cd10 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Mon, 13 Jan 2025 13:32:48 +0700 Subject: [PATCH] GateIO: Use time_ms WS fields where available Removes the deprecated _time json fields and populates our Time fields with the time_ms values --- exchanges/gateio/gateio_types.go | 288 ++++++++----------- exchanges/gateio/gateio_websocket.go | 14 +- exchanges/gateio/gateio_websocket_futures.go | 14 +- exchanges/gateio/gateio_websocket_option.go | 6 +- exchanges/gateio/gateio_wrapper.go | 14 +- 5 files changed, 149 insertions(+), 187 deletions(-) diff --git a/exchanges/gateio/gateio_types.go b/exchanges/gateio/gateio_types.go index a98d39013c9..3e2d7520237 100644 --- a/exchanges/gateio/gateio_types.go +++ b/exchanges/gateio/gateio_types.go @@ -585,18 +585,17 @@ type Orderbook struct { // Trade represents market trade. type Trade struct { - ID int64 `json:"id,string"` - TradingTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` - OrderID string `json:"order_id"` - Side string `json:"side"` - Role string `json:"role"` - Amount types.Number `json:"amount"` - Price types.Number `json:"price"` - Fee types.Number `json:"fee"` - FeeCurrency string `json:"fee_currency"` - PointFee string `json:"point_fee"` - GtFee string `json:"gt_fee"` + ID int64 `json:"id,string"` + CreateTime types.Time `json:"create_time_ms"` + OrderID string `json:"order_id"` + Side string `json:"side"` + Role string `json:"role"` + Amount types.Number `json:"amount"` + Price types.Number `json:"price"` + Fee types.Number `json:"fee"` + FeeCurrency string `json:"fee_currency"` + PointFee string `json:"point_fee"` + GtFee string `json:"gt_fee"` } // Candlestick represents candlestick data point detail. @@ -688,13 +687,12 @@ type FuturesContract struct { // TradingHistoryItem represents futures trading history item. type TradingHistoryItem struct { - ID int64 `json:"id"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` - Contract string `json:"contract"` - Text string `json:"text"` - Size float64 `json:"size"` - Price types.Number `json:"price"` + ID int64 `json:"id"` + CreateTime types.Time `json:"create_time_ms"` + Contract string `json:"contract"` + Text string `json:"text"` + Size float64 `json:"size"` + Price types.Number `json:"price"` // Added for Derived market trade history data Fee types.Number `json:"fee"` PointFee types.Number `json:"point_fee"` @@ -1218,8 +1216,7 @@ type AccountBalanceInformation struct { // MarginAccountBalanceChangeInfo represents margin account balance type MarginAccountBalanceChangeInfo struct { ID string `json:"id"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` Currency string `json:"currency"` CurrencyPair string `json:"currency_pair"` AmountChanged string `json:"change"` @@ -1388,10 +1385,8 @@ type SpotOrder struct { Succeeded bool `json:"succeeded"` ErrorLabel string `json:"label,omitempty"` Message string `json:"message,omitempty"` - CreateTime types.Time `json:"create_time,omitempty"` - CreateTimeMs types.Time `json:"create_time_ms,omitempty"` - UpdateTime types.Time `json:"update_time,omitempty"` - UpdateTimeMs types.Time `json:"update_time_ms,omitempty"` + CreateTime types.Time `json:"create_time_ms,omitempty"` + UpdateTime types.Time `json:"update_time_ms,omitempty"` CurrencyPair string `json:"currency_pair,omitempty"` Status string `json:"status,omitempty"` Type string `json:"type,omitempty"` @@ -1452,8 +1447,7 @@ type CancelOrderByIDResponse struct { // SpotPersonalTradeHistory represents personal trading history. type SpotPersonalTradeHistory struct { TradeID string `json:"id"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` + CreateTime types.Time `json:"create_time_ms"` CurrencyPair string `json:"currency_pair"` OrderID string `json:"order_id"` Side string `json:"side"` @@ -2027,8 +2021,7 @@ type WsTicker struct { // WsTrade represents a websocket push data response for a trade type WsTrade struct { ID int64 `json:"id"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` + CreateTime types.Time `json:"create_time_ms"` Side string `json:"side"` CurrencyPair currency.Pair `json:"currency_pair"` Amount types.Number `json:"amount"` @@ -2048,7 +2041,7 @@ type WsCandlesticks struct { // WsOrderbookTickerData represents the websocket orderbook best bid or best ask push data type WsOrderbookTickerData struct { - UpdateTimeMS types.Time `json:"t"` + UpdateTime types.Time `json:"t"` UpdateOrderID int64 `json:"u"` CurrencyPair currency.Pair `json:"s"` BestBidPrice types.Number `json:"b"` @@ -2059,9 +2052,7 @@ type WsOrderbookTickerData struct { // WsOrderbookUpdate represents websocket orderbook update push data type WsOrderbookUpdate struct { - UpdateTimeMs types.Time `json:"t"` - IgnoreField string `json:"e"` - UpdateTime types.Time `json:"E"` + UpdateTime types.Time `json:"t"` CurrencyPair currency.Pair `json:"s"` FirstOrderbookUpdatedID int64 `json:"U"` // First update order book id in this event since last update LastOrderbookUpdatedID int64 `json:"u"` @@ -2071,7 +2062,7 @@ type WsOrderbookUpdate struct { // WsOrderbookSnapshot represents a websocket orderbook snapshot push data type WsOrderbookSnapshot struct { - UpdateTimeMs types.Time `json:"t"` + UpdateTime types.Time `json:"t"` LastUpdateID int64 `json:"lastUpdateId"` CurrencyPair currency.Pair `json:"s"` Bids [][2]types.Number `json:"bids"` @@ -2104,10 +2095,8 @@ type WsSpotOrder struct { RebatedFee string `json:"rebated_fee,omitempty"` RebatedFeeCurrency string `json:"rebated_fee_currency,omitempty"` Event string `json:"event"` - CreateTime types.Time `json:"create_time,omitempty"` - CreateTimeMs types.Time `json:"create_time_ms,omitempty"` - UpdateTime types.Time `json:"update_time,omitempty"` - UpdateTimeMs types.Time `json:"update_time_ms,omitempty"` + CreateTime types.Time `json:"create_time_ms,omitempty"` + UpdateTime types.Time `json:"update_time_ms,omitempty"` } // WsUserPersonalTrade represents a user's personal trade pushed through the websocket connection. @@ -2116,8 +2105,7 @@ type WsUserPersonalTrade struct { UserID int64 `json:"user_id"` OrderID string `json:"order_id"` CurrencyPair currency.Pair `json:"currency_pair"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` + CreateTime types.Time `json:"create_time_ms"` Side string `json:"side"` Amount types.Number `json:"amount"` Role string `json:"role"` @@ -2130,19 +2118,17 @@ type WsUserPersonalTrade struct { // WsSpotBalance represents a spot balance. type WsSpotBalance struct { - Timestamp types.Time `json:"timestamp"` - TimestampMs types.Time `json:"timestamp_ms"` - User string `json:"user"` - Currency string `json:"currency"` - Change types.Number `json:"change"` - Total types.Number `json:"total"` - Available types.Number `json:"available"` + Timestamp types.Time `json:"timestamp_ms"` + User string `json:"user"` + Currency string `json:"currency"` + Change types.Number `json:"change"` + Total types.Number `json:"total"` + Available types.Number `json:"available"` } // WsMarginBalance represents margin account balance push data type WsMarginBalance struct { - Timestamp types.Time `json:"timestamp"` - TimestampMs types.Time `json:"timestamp_ms"` + Timestamp types.Time `json:"timestamp_ms"` User string `json:"user"` CurrencyPair string `json:"currency_pair"` Currency string `json:"currency"` @@ -2155,24 +2141,22 @@ type WsMarginBalance struct { // WsFundingBalance represents funding balance push data. type WsFundingBalance struct { - Timestamp types.Time `json:"timestamp"` - TimestampMs types.Time `json:"timestamp_ms"` - User string `json:"user"` - Currency string `json:"currency"` - Change string `json:"change"` - Freeze string `json:"freeze"` - Lent string `json:"lent"` + Timestamp types.Time `json:"timestamp_ms"` + User string `json:"user"` + Currency string `json:"currency"` + Change string `json:"change"` + Freeze string `json:"freeze"` + Lent string `json:"lent"` } // WsCrossMarginBalance represents a cross margin balance detail type WsCrossMarginBalance struct { - Timestamp types.Time `json:"timestamp"` - TimestampMs types.Time `json:"timestamp_ms"` - User string `json:"user"` - Currency string `json:"currency"` - Change string `json:"change"` - Total types.Number `json:"total"` - Available types.Number `json:"available"` + Timestamp types.Time `json:"timestamp_ms"` + User string `json:"user"` + Currency string `json:"currency"` + Change string `json:"change"` + Total types.Number `json:"total"` + Available types.Number `json:"available"` } // WsCrossMarginLoan represents a cross margin loan push data @@ -2210,17 +2194,16 @@ type WsFutureTicker struct { // WsFuturesTrades represents a list of trades push data type WsFuturesTrades struct { - Size float64 `json:"size"` - ID int64 `json:"id"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` - Price types.Number `json:"price"` - Contract currency.Pair `json:"contract"` + Size float64 `json:"size"` + ID int64 `json:"id"` + CreateTime types.Time `json:"create_time_ms"` + Price types.Number `json:"price"` + Contract currency.Pair `json:"contract"` } // WsFuturesOrderbookTicker represents the orderbook ticker push data type WsFuturesOrderbookTicker struct { - TimestampMs types.Time `json:"t"` + Timestamp types.Time `json:"t"` UpdateID int64 `json:"u"` CurrencyPair string `json:"s"` BestBidPrice types.Number `json:"b"` @@ -2231,7 +2214,7 @@ type WsFuturesOrderbookTicker struct { // WsFuturesAndOptionsOrderbookUpdate represents futures and options account orderbook update push data type WsFuturesAndOptionsOrderbookUpdate struct { - TimestampInMs types.Time `json:"t"` + Timestamp types.Time `json:"t"` ContractName currency.Pair `json:"s"` FirstUpdatedID int64 `json:"U"` LastUpdatedID int64 `json:"u"` @@ -2247,10 +2230,10 @@ type WsFuturesAndOptionsOrderbookUpdate struct { // WsFuturesOrderbookSnapshot represents a futures orderbook snapshot push data type WsFuturesOrderbookSnapshot struct { - TimestampInMs types.Time `json:"t"` - Contract currency.Pair `json:"contract"` - OrderbookID int64 `json:"id"` - Asks []struct { + Timestamp types.Time `json:"t"` + Contract currency.Pair `json:"contract"` + OrderbookID int64 `json:"id"` + Asks []struct { Price types.Number `json:"p"` Size float64 `json:"s"` } `json:"asks"` @@ -2271,12 +2254,10 @@ type WsFuturesOrderbookUpdateEvent struct { // WsFuturesOrder represents futures order type WsFuturesOrder struct { Contract currency.Pair `json:"contract"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` + CreateTime types.Time `json:"create_time_ms"` FillPrice float64 `json:"fill_price"` FinishAs string `json:"finish_as"` - FinishTime types.Time `json:"finish_time"` - FinishTimeMs types.Time `json:"finish_time_ms"` + FinishTime types.Time `json:"finish_time_ms"` Iceberg int64 `json:"iceberg"` ID int64 `json:"id"` IsClose bool `json:"is_close"` @@ -2297,17 +2278,16 @@ type WsFuturesOrder struct { // WsFuturesUserTrade represents a futures account user trade push data type WsFuturesUserTrade struct { - ID string `json:"id"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` - Contract currency.Pair `json:"contract"` - OrderID string `json:"order_id"` - Size float64 `json:"size"` - Price types.Number `json:"price"` - Role string `json:"role"` - Text string `json:"text"` - Fee float64 `json:"fee"` - PointFee int64 `json:"point_fee"` + ID string `json:"id"` + CreateTime types.Time `json:"create_time_ms"` + Contract currency.Pair `json:"contract"` + OrderID string `json:"order_id"` + Size float64 `json:"size"` + Price types.Number `json:"price"` + Role string `json:"role"` + Text string `json:"text"` + Fee float64 `json:"fee"` + PointFee int64 `json:"point_fee"` } // WsFuturesLiquidationNotification represents a liquidation notification push data @@ -2322,8 +2302,7 @@ type WsFuturesLiquidationNotification struct { OrderID int64 `json:"order_id"` OrderPrice float64 `json:"order_price"` Size float64 `json:"size"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` Contract string `json:"contract"` User string `json:"user"` } @@ -2334,8 +2313,7 @@ type WsFuturesAutoDeleveragesNotification struct { FillPrice float64 `json:"fill_price"` PositionSize int64 `json:"position_size"` TradeSize int64 `json:"trade_size"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` Contract string `json:"contract"` User string `json:"user"` } @@ -2346,8 +2324,7 @@ type WsPositionClose struct { ProfitAndLoss float64 `json:"pnl,omitempty"` Side string `json:"side"` Text string `json:"text"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` User string `json:"user"` // Added in options close position push datas @@ -2360,8 +2337,7 @@ type WsBalance struct { Balance float64 `json:"balance"` Change float64 `json:"change"` Text string `json:"text"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` Type string `json:"type"` User string `json:"user"` } @@ -2374,8 +2350,7 @@ type WsFuturesReduceRiskLimitNotification struct { LiqPrice float64 `json:"liq_price"` MaintenanceRate float64 `json:"maintenance_rate"` RiskLimit int64 `json:"risk_limit"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` User string `json:"user"` } @@ -2397,8 +2372,7 @@ type WsFuturesPosition struct { RealisedPoint float64 `json:"realised_point"` RiskLimit float64 `json:"risk_limit"` Size float64 `json:"size"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` User string `json:"user"` } @@ -2447,31 +2421,26 @@ type WsOptionUnderlyingTicker struct { // WsOptionsTrades represents options trades for websocket push data. type WsOptionsTrades struct { ID int64 `json:"id"` - CreateTime types.Time `json:"create_time"` + CreateTime types.Time `json:"create_time_ms"` Contract currency.Pair `json:"contract"` Size float64 `json:"size"` Price float64 `json:"price"` - - // Added in options websocket push data - CreateTimeMs types.Time `json:"create_time_ms"` - Underlying string `json:"underlying"` - IsCall bool `json:"is_call"` // added in underlying trades + Underlying string `json:"underlying"` + IsCall bool `json:"is_call"` // added in underlying trades } // WsOptionsUnderlyingPrice represents the underlying price. type WsOptionsUnderlyingPrice struct { - Underlying string `json:"underlying"` - Price float64 `json:"price"` - UpdateTime types.Time `json:"time"` - UpdateTimeMs types.Time `json:"time_ms"` + Underlying string `json:"underlying"` + Price float64 `json:"price"` + UpdateTime types.Time `json:"time_ms"` } // WsOptionsMarkPrice represents options mark price push data. type WsOptionsMarkPrice struct { - Contract string `json:"contract"` - Price float64 `json:"price"` - UpdateTimeMs types.Time `json:"time_ms"` - UpdateTime types.Time `json:"time"` + Contract string `json:"contract"` + Price float64 `json:"price"` + UpdateTime types.Time `json:"time_ms"` } // WsOptionsSettlement represents a options settlement push data. @@ -2486,8 +2455,7 @@ type WsOptionsSettlement struct { TradeID int64 `json:"trade_id"` TradeSize int64 `json:"trade_size"` Underlying string `json:"underlying"` - UpdateTime types.Time `json:"time"` - UpdateTimeMs types.Time `json:"time_ms"` + UpdateTime types.Time `json:"time_ms"` } // WsOptionsContract represents an option contract push data. @@ -2515,8 +2483,7 @@ type WsOptionsContract struct { Tag string `json:"tag"` TakerFeeRate float64 `json:"taker_fee_rate"` Underlying string `json:"underlying"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` } // WsOptionsContractCandlestick represents an options contract candlestick push data. @@ -2559,42 +2526,40 @@ type WsOptionsOrderbookSnapshot struct { // WsOptionsOrder represents options order push data. type WsOptionsOrder struct { - ID int64 `json:"id"` - Contract currency.Pair `json:"contract"` - CreateTime types.Time `json:"create_time"` - FillPrice float64 `json:"fill_price"` - FinishAs string `json:"finish_as"` - Iceberg float64 `json:"iceberg"` - IsClose bool `json:"is_close"` - IsLiq bool `json:"is_liq"` - IsReduceOnly bool `json:"is_reduce_only"` - Left float64 `json:"left"` - Mkfr float64 `json:"mkfr"` - Price float64 `json:"price"` - Refr float64 `json:"refr"` - Refu float64 `json:"refu"` - Size float64 `json:"size"` - Status string `json:"status"` - Text string `json:"text"` - Tif string `json:"tif"` - Tkfr float64 `json:"tkfr"` - Underlying string `json:"underlying"` - User string `json:"user"` - CreationTime types.Time `json:"time"` - CreationTimeMs types.Time `json:"time_ms"` + ID int64 `json:"id"` + Contract currency.Pair `json:"contract"` + CreateTime types.Time `json:"create_time"` + FillPrice float64 `json:"fill_price"` + FinishAs string `json:"finish_as"` + Iceberg float64 `json:"iceberg"` + IsClose bool `json:"is_close"` + IsLiq bool `json:"is_liq"` + IsReduceOnly bool `json:"is_reduce_only"` + Left float64 `json:"left"` + Mkfr float64 `json:"mkfr"` + Price float64 `json:"price"` + Refr float64 `json:"refr"` + Refu float64 `json:"refu"` + Size float64 `json:"size"` + Status string `json:"status"` + Text string `json:"text"` + Tif string `json:"tif"` + Tkfr float64 `json:"tkfr"` + Underlying string `json:"underlying"` + User string `json:"user"` + CreationTime types.Time `json:"time_ms"` } // WsOptionsUserTrade represents user's personal trades of option account. type WsOptionsUserTrade struct { - ID string `json:"id"` - Underlying string `json:"underlying"` - OrderID string `json:"order"` - Contract currency.Pair `json:"contract"` - CreateTime types.Time `json:"create_time"` - CreateTimeMs types.Time `json:"create_time_ms"` - Price types.Number `json:"price"` - Role string `json:"role"` - Size float64 `json:"size"` + ID string `json:"id"` + Underlying string `json:"underlying"` + OrderID string `json:"order"` + Contract currency.Pair `json:"contract"` + CreateTime types.Time `json:"create_time_ms"` + Price types.Number `json:"price"` + Role string `json:"role"` + Size float64 `json:"size"` } // WsOptionsLiquidates represents the liquidates push data of option account. @@ -2603,8 +2568,7 @@ type WsOptionsLiquidates struct { InitMargin float64 `json:"init_margin"` MaintMargin float64 `json:"maint_margin"` OrderMargin float64 `json:"order_margin"` - Time types.Time `json:"time"` - TimeMs types.Time `json:"time_ms"` + Time types.Time `json:"time_ms"` } // WsOptionsUserSettlement represents user's personal settlements push data of options account. @@ -2617,19 +2581,17 @@ type WsOptionsUserSettlement struct { Size float64 `json:"size"` StrikePrice float64 `json:"strike_price"` Underlying string `json:"underlying"` - SettleTime types.Time `json:"time"` - SettleTimeMs types.Time `json:"time_ms"` + SettleTime types.Time `json:"time_ms"` } // WsOptionsPosition represents positions push data for options account. type WsOptionsPosition struct { - EntryPrice float64 `json:"entry_price"` - RealisedPnl float64 `json:"realised_pnl"` - Size float64 `json:"size"` - Contract string `json:"contract"` - User string `json:"user"` - UpdateTime types.Time `json:"time"` - UpdateTimeMs types.Time `json:"time_ms"` + EntryPrice float64 `json:"entry_price"` + RealisedPnl float64 `json:"realised_pnl"` + Size float64 `json:"size"` + Contract string `json:"contract"` + User string `json:"user"` + UpdateTime types.Time `json:"time_ms"` } // InterSubAccountTransferParams represents parameters to transfer funds between sub-accounts. diff --git a/exchanges/gateio/gateio_websocket.go b/exchanges/gateio/gateio_websocket.go index ea1e0030456..5849e72d706 100644 --- a/exchanges/gateio/gateio_websocket.go +++ b/exchanges/gateio/gateio_websocket.go @@ -302,7 +302,7 @@ func (g *Gateio) processTrades(incoming []byte) error { for _, a := range standardMarginAssetTypes { if enabled, _ := g.CurrencyPairs.IsPairEnabled(data.CurrencyPair, a); enabled { if err := g.Websocket.Trade.Update(saveTradeData, trade.Data{ - Timestamp: data.CreateTimeMs.Time(), + Timestamp: data.CreateTime.Time(), CurrencyPair: data.CurrencyPair, AssetType: a, Exchange: g.Name, @@ -363,7 +363,7 @@ func (g *Gateio) processOrderbookTicker(incoming []byte, updatePushedAt time.Tim Exchange: g.Name, Pair: data.CurrencyPair, Asset: asset.Spot, - LastUpdated: data.UpdateTimeMS.Time(), + LastUpdated: data.UpdateTime.Time(), UpdatePushedAt: updatePushedAt, Bids: []orderbook.Tranche{{Price: data.BestBidPrice.Float64(), Amount: data.BestBidAmount.Float64()}}, Asks: []orderbook.Tranche{{Price: data.BestAskPrice.Float64(), Amount: data.BestAskAmount.Float64()}}, @@ -418,7 +418,7 @@ func (g *Gateio) processOrderbookUpdate(incoming []byte, updatePushedAt time.Tim for _, a := range enabledAssets { if err := g.Websocket.Orderbook.Update(&orderbook.Update{ - UpdateTime: data.UpdateTimeMs.Time(), + UpdateTime: data.UpdateTime.Time(), UpdatePushedAt: updatePushedAt, Pair: data.CurrencyPair, Asset: a, @@ -455,7 +455,7 @@ func (g *Gateio) processOrderbookSnapshot(incoming []byte, updatePushedAt time.T Exchange: g.Name, Pair: data.CurrencyPair, Asset: a, - LastUpdated: data.UpdateTimeMs.Time(), + LastUpdated: data.UpdateTime.Time(), UpdatePushedAt: updatePushedAt, Bids: bids, Asks: asks, @@ -503,8 +503,8 @@ func (g *Gateio) processSpotOrders(data []byte) error { AssetType: a, Price: resp.Result[x].Price.Float64(), ExecutedAmount: resp.Result[x].Amount.Float64() - resp.Result[x].Left.Float64(), - Date: resp.Result[x].CreateTimeMs.Time(), - LastUpdated: resp.Result[x].UpdateTimeMs.Time(), + Date: resp.Result[x].CreateTime.Time(), + LastUpdated: resp.Result[x].UpdateTime.Time(), } } g.Websocket.DataHandler <- details @@ -533,7 +533,7 @@ func (g *Gateio) processUserPersonalTrades(data []byte) error { return err } fills[x] = fill.Data{ - Timestamp: resp.Result[x].CreateTimeMs.Time(), + Timestamp: resp.Result[x].CreateTime.Time(), Exchange: g.Name, CurrencyPair: resp.Result[x].CurrencyPair, Side: side, diff --git a/exchanges/gateio/gateio_websocket_futures.go b/exchanges/gateio/gateio_websocket_futures.go index fa9ff881ef9..628824a08ca 100644 --- a/exchanges/gateio/gateio_websocket_futures.go +++ b/exchanges/gateio/gateio_websocket_futures.go @@ -352,7 +352,7 @@ func (g *Gateio) processFuturesTrades(data []byte, assetType asset.Item) error { trades := make([]trade.Data, len(resp.Result)) for x := range resp.Result { trades[x] = trade.Data{ - Timestamp: resp.Result[x].CreateTimeMs.Time(), + Timestamp: resp.Result[x].CreateTime.Time(), CurrencyPair: resp.Result[x].Contract, AssetType: assetType, Exchange: g.Name, @@ -438,7 +438,7 @@ func (g *Gateio) processFuturesAndOptionsOrderbookUpdate(incoming []byte, assetT } } updates := orderbook.Update{ - UpdateTime: data.TimestampInMs.Time(), + UpdateTime: data.Timestamp.Time(), Pair: data.ContractName, Asset: assetType, } @@ -469,7 +469,7 @@ func (g *Gateio) processFuturesOrderbookSnapshot(event string, incoming []byte, Asset: assetType, Exchange: g.Name, Pair: data.Contract, - LastUpdated: data.TimestampInMs.Time(), + LastUpdated: data.Timestamp.Time(), UpdatePushedAt: updatePushedAt, VerifyOrderbook: g.CanVerifyOrderbook, } @@ -573,13 +573,13 @@ func (g *Gateio) processFuturesOrdersPushData(data []byte, assetType asset.Item) OrderID: strconv.FormatInt(resp.Result[x].ID, 10), Status: status, Pair: resp.Result[x].Contract, - LastUpdated: resp.Result[x].FinishTimeMs.Time(), - Date: resp.Result[x].CreateTimeMs.Time(), + LastUpdated: resp.Result[x].FinishTime.Time(), + Date: resp.Result[x].CreateTime.Time(), ExecutedAmount: resp.Result[x].Size - resp.Result[x].Left, Price: resp.Result[x].Price, AssetType: assetType, AccountID: resp.Result[x].User, - CloseTime: resp.Result[x].FinishTimeMs.Time(), + CloseTime: resp.Result[x].FinishTime.Time(), } } return orderDetails, nil @@ -603,7 +603,7 @@ func (g *Gateio) procesFuturesUserTrades(data []byte, assetType asset.Item) erro fills := make([]fill.Data, len(resp.Result)) for x := range resp.Result { fills[x] = fill.Data{ - Timestamp: resp.Result[x].CreateTimeMs.Time(), + Timestamp: resp.Result[x].CreateTime.Time(), Exchange: g.Name, CurrencyPair: resp.Result[x].Contract, OrderID: resp.Result[x].OrderID, diff --git a/exchanges/gateio/gateio_websocket_option.go b/exchanges/gateio/gateio_websocket_option.go index 404801c4ca5..7ec39737e6e 100644 --- a/exchanges/gateio/gateio_websocket_option.go +++ b/exchanges/gateio/gateio_websocket_option.go @@ -401,7 +401,7 @@ func (g *Gateio) processOptionsTradesPushData(data []byte) error { trades := make([]trade.Data, len(resp.Result)) for x := range resp.Result { trades[x] = trade.Data{ - Timestamp: resp.Result[x].CreateTimeMs.Time(), + Timestamp: resp.Result[x].CreateTime.Time(), CurrencyPair: resp.Result[x].Contract, AssetType: asset.Options, Exchange: g.Name, @@ -605,7 +605,7 @@ func (g *Gateio) processOptionsOrderPushData(data []byte) error { OrderID: strconv.FormatInt(resp.Result[x].ID, 10), Status: status, Pair: resp.Result[x].Contract, - Date: resp.Result[x].CreationTimeMs.Time(), + Date: resp.Result[x].CreationTime.Time(), ExecutedAmount: resp.Result[x].Size - resp.Result[x].Left, Price: resp.Result[x].Price, AssetType: asset.Options, @@ -633,7 +633,7 @@ func (g *Gateio) processOptionsUserTradesPushData(data []byte) error { fills := make([]fill.Data, len(resp.Result)) for x := range resp.Result { fills[x] = fill.Data{ - Timestamp: resp.Result[x].CreateTimeMs.Time(), + Timestamp: resp.Result[x].CreateTime.Time(), Exchange: g.Name, CurrencyPair: resp.Result[x].Contract, OrderID: resp.Result[x].OrderID, diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index 5624f4d075f..239e3179245 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -966,7 +966,7 @@ func (g *Gateio) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.I Side: side, Price: tradeData[i].Price.Float64(), Amount: tradeData[i].Amount.Float64(), - Timestamp: tradeData[i].CreateTimeMs.Time(), + Timestamp: tradeData[i].CreateTime.Time(), } } case asset.Futures: @@ -1107,8 +1107,8 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi response.Pair = s.Pair response.Date = sOrder.CreateTime.Time() response.ClientOrderID = sOrder.Text - response.Date = sOrder.CreateTimeMs.Time() - response.LastUpdated = sOrder.UpdateTimeMs.Time() + response.Date = sOrder.CreateTime.Time() + response.LastUpdated = sOrder.UpdateTime.Time() return response, nil case asset.Futures: // TODO: See https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order @@ -1490,8 +1490,8 @@ func (g *Gateio) GetOrderInfo(ctx context.Context, orderID string, pair currency Status: orderStatus, Price: spotOrder.Price.Float64(), ExecutedAmount: spotOrder.Amount.Float64() - spotOrder.Left.Float64(), - Date: spotOrder.CreateTimeMs.Time(), - LastUpdated: spotOrder.UpdateTimeMs.Time(), + Date: spotOrder.CreateTime.Time(), + LastUpdated: spotOrder.UpdateTime.Time(), }, nil case asset.Futures, asset.DeliveryFutures: var settle currency.Code @@ -1698,8 +1698,8 @@ func (g *Gateio) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque RemainingAmount: spotOrders[x].Orders[y].Left.Float64(), Price: spotOrders[x].Orders[y].Price.Float64(), AverageExecutedPrice: spotOrders[x].Orders[y].AverageFillPrice.Float64(), - Date: spotOrders[x].Orders[y].CreateTimeMs.Time(), - LastUpdated: spotOrders[x].Orders[y].UpdateTimeMs.Time(), + Date: spotOrders[x].Orders[y].CreateTime.Time(), + LastUpdated: spotOrders[x].Orders[y].UpdateTime.Time(), Exchange: g.Name, AssetType: req.AssetType, ClientOrderID: spotOrders[x].Orders[y].Text,