diff --git a/exchanges/huobi/cfutures_types.go b/exchanges/huobi/cfutures_types.go index d2d84d0c1f8..031b1708b6a 100644 --- a/exchanges/huobi/cfutures_types.go +++ b/exchanges/huobi/cfutures_types.go @@ -1,5 +1,7 @@ package huobi +import "github.com/thrasher-corp/gocryptotrader/types" + // WsSwapReqKline stores req kline data for swap websocket type WsSwapReqKline struct { Rep string `json:"rep"` @@ -19,22 +21,22 @@ type WsSwapReqKline struct { // WsSwapReqTradeDetail stores requested trade detail data for swap websocket type WsSwapReqTradeDetail struct { - Rep string `json:"rep"` - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + Rep string `json:"rep"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` Data []struct { - ID int64 `json:"id"` - Price float64 `json:"price"` - Amount float64 `json:"amount"` - Direction string `json:"direction"` - Timestamp int64 `json:"ts"` + ID int64 `json:"id"` + Price float64 `json:"price"` + Amount float64 `json:"amount"` + Direction string `json:"direction"` + Timestamp types.Time `json:"ts"` } `json:"data"` } // SwapWsSubPremiumKline stores subscribed premium kline data for futures websocket type SwapWsSubPremiumKline struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` Volume float64 `json:"vol"` @@ -49,10 +51,10 @@ type SwapWsSubPremiumKline struct { // SwapWsReqPremiumKline stores requested premium kline data for futures websocket type SwapWsReqPremiumKline struct { - Rep string `json:"rep"` - ID string `json:"id"` - WsID int64 `json:"wsid"` - Timestamp int64 `json:"ts"` + Rep string `json:"rep"` + ID string `json:"id"` + WsID int64 `json:"wsid"` + Timestamp types.Time `json:"ts"` Data []struct { Volume float64 `json:"vol"` Count float64 `json:"count"` @@ -67,8 +69,8 @@ type SwapWsReqPremiumKline struct { // SwapWsSubEstimatedFunding stores estimated funding rate data for swap websocket type SwapWsSubEstimatedFunding struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` Volume float64 `json:"vol,string"` @@ -83,10 +85,10 @@ type SwapWsSubEstimatedFunding struct { // SwapWsReqEstimatedFunding stores requested estimated funding data for swap websocket type SwapWsReqEstimatedFunding struct { - Rep string `json:"rep"` - ID string `json:"id"` - WsID int64 `json:"wsid"` - Timestamp int64 `json:"ts"` + Rep string `json:"rep"` + ID string `json:"id"` + WsID int64 `json:"wsid"` + Timestamp types.Time `json:"ts"` Data []struct { Volume float64 `json:"vol,string"` Count float64 `json:"count,string"` @@ -101,8 +103,8 @@ type SwapWsReqEstimatedFunding struct { // SwapWsSubBasisData stores subscribed basis data for swap websocket type SwapWsSubBasisData struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick []struct { ID int64 `json:"id"` ContractPrice float64 `json:"contract_price,string"` @@ -114,10 +116,10 @@ type SwapWsSubBasisData struct { // SwapWsReqBasisData stores requested basis data for swap websocket type SwapWsReqBasisData struct { - Rep string `json:"rep"` - ID string `json:"id"` - WsID int64 `json:"wsid"` - Timestamp int64 `json:"ts"` + Rep string `json:"rep"` + ID string `json:"id"` + WsID int64 `json:"wsid"` + Timestamp types.Time `json:"ts"` Data []struct { ID int64 `json:"id"` ContractPrice float64 `json:"contract_price"` @@ -129,33 +131,33 @@ type SwapWsReqBasisData struct { // SwapWsSubOrderData stores subscribed order data for swap websocket type SwapWsSubOrderData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - ContractCode string `json:"contract_code"` - Volume float64 `json:"volume"` - Price float64 `json:"price"` - OrderPriceType string `json:"order_price_type"` - Direction string `json:"direction"` - Offset string `json:"offset"` - Status int64 `json:"status"` - LeverateRate float64 `json:"lever_rate"` - OrderID int64 `json:"order_id"` - OrderIDString string `json:"order_id_str"` - ClientOrderID int64 `json:"client_order_id"` - OrderSource string `json:"order_source"` - OrderType int64 `json:"order_type"` - CreatedAt int64 `json:"created_at"` - CanceledAt int64 `json:"canceled_at"` - TradeVolume float64 `json:"trade_volume"` - TradeTurnover float64 `json:"trade_turnover"` - Fee float64 `json:"fee"` - FeeAsset string `json:"fee_asset"` - TradeAvgPrice float64 `json:"trade_avg_price"` - MarginFrozen float64 `json:"margin_frozen"` - Profit float64 `json:"profit"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + ContractCode string `json:"contract_code"` + Volume float64 `json:"volume"` + Price float64 `json:"price"` + OrderPriceType string `json:"order_price_type"` + Direction string `json:"direction"` + Offset string `json:"offset"` + Status int64 `json:"status"` + LeverateRate float64 `json:"lever_rate"` + OrderID int64 `json:"order_id"` + OrderIDString string `json:"order_id_str"` + ClientOrderID int64 `json:"client_order_id"` + OrderSource string `json:"order_source"` + OrderType int64 `json:"order_type"` + CreatedAt int64 `json:"created_at"` + CanceledAt int64 `json:"canceled_at"` + TradeVolume float64 `json:"trade_volume"` + TradeTurnover float64 `json:"trade_turnover"` + Fee float64 `json:"fee"` + FeeAsset string `json:"fee_asset"` + TradeAvgPrice float64 `json:"trade_avg_price"` + MarginFrozen float64 `json:"margin_frozen"` + Profit float64 `json:"profit"` Trade []struct { ID string `json:"id"` TradeID int64 `json:"trade_id"` @@ -172,19 +174,19 @@ type SwapWsSubOrderData struct { // SwapWsSubMatchOrderData stores subscribed match order data for swap websocket type SwapWsSubMatchOrderData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - ContractCode string `json:"contract_code"` - Status int64 `json:"status"` - OrderID int64 `json:"order_id"` - OrderIDString string `json:"order_id_str"` - ClientOrderID int64 `json:"client_order_id"` - OrderType string `json:"order_type"` - TradeVolume int64 `json:"trade_volume"` - Volume float64 `json:"volume"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + ContractCode string `json:"contract_code"` + Status int64 `json:"status"` + OrderID int64 `json:"order_id"` + OrderIDString string `json:"order_id_str"` + ClientOrderID int64 `json:"client_order_id"` + OrderType string `json:"order_type"` + TradeVolume int64 `json:"trade_volume"` + Volume float64 `json:"volume"` Trade []struct { ID string `json:"id"` TradeID int64 `json:"trade_id"` @@ -198,11 +200,11 @@ type SwapWsSubMatchOrderData struct { // SwapWsSubEquityData stores subscribed account data for swap account equity updates through websocket type SwapWsSubEquityData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` - UID string `json:"uid"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` + UID string `json:"uid"` + Event string `json:"event"` Data []struct { Symbol string `json:"symbol"` MarginBalance float64 `json:"margin_balance"` @@ -222,11 +224,11 @@ type SwapWsSubEquityData struct { // SwapWsSubPositionUpdates stores subscribed position updates data for swap websocket type SwapWsSubPositionUpdates struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Event string `json:"event"` Data []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -247,9 +249,9 @@ type SwapWsSubPositionUpdates struct { // SwapWsSubLiquidationOrders stores subscribed liquidation orders data for swap futures type SwapWsSubLiquidationOrders struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` OrdersData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -263,9 +265,9 @@ type SwapWsSubLiquidationOrders struct { // SwapWsSubFundingData stores funding rate data for swap websocket type SwapWsSubFundingData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` FundingData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -279,10 +281,10 @@ type SwapWsSubFundingData struct { // SwapWsSubContractInfo stores funding rate data for swap websocket type SwapWsSubContractInfo struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` + Event string `json:"event"` ContractData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -330,9 +332,9 @@ type SwapWsSubTriggerOrderUpdates struct { // SwapIndexPriceData gets price of a perpetual swap type SwapIndexPriceData struct { Data []struct { - ContractCode string `json:"contract_code"` - IndexPrice float64 `json:"index_price"` - IndexTimestamp int64 `json:"index_ts"` + ContractCode string `json:"contract_code"` + IndexPrice float64 `json:"index_price"` + IndexTimestamp types.Time `json:"index_ts"` } `json:"data"` } @@ -364,7 +366,7 @@ type SwapMarketDepthData struct { Channel string `json:"ch"` ID int64 `json:"id"` MRID int64 `json:"mrid"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:"version"` } `json:"tick"` } @@ -372,14 +374,14 @@ type SwapMarketDepthData struct { // SwapKlineData stores kline data for perpetual swaps type SwapKlineData struct { Data []struct { - Volume float64 `json:"vol"` - Close float64 `json:"close"` - Count float64 `json:"count"` - High float64 `json:"high"` - IDTimestamp int64 `json:"id"` - Low float64 `json:"low"` - Open float64 `json:"open"` - Amount float64 `json:"amount"` + Volume float64 `json:"vol"` + Close float64 `json:"close"` + Count float64 `json:"count"` + High float64 `json:"high"` + IDTimestamp types.Time `json:"id"` + Low float64 `json:"low"` + Open float64 `json:"open"` + Amount float64 `json:"amount"` } `json:"data"` } @@ -387,17 +389,17 @@ type SwapKlineData struct { type MarketOverviewData struct { Channel string `json:"ch"` Tick struct { - Vol float64 `json:"vol,string"` - Ask []float64 `json:"ask"` - Bid []float64 `json:"bid"` - Close float64 `json:"close,string"` - Count float64 `json:"count"` - High float64 `json:"high,string"` - ID int64 `json:"id"` - Low float64 `json:"low,string"` - Open float64 `json:"open,string"` - Timestamp int64 `json:"ts"` - Amount float64 `json:"amount,string"` + Vol float64 `json:"vol,string"` + Ask []float64 `json:"ask"` + Bid []float64 `json:"bid"` + Close float64 `json:"close,string"` + Count float64 `json:"count"` + High float64 `json:"high,string"` + ID int64 `json:"id"` + Low float64 `json:"low,string"` + Open float64 `json:"open,string"` + Timestamp types.Time `json:"ts"` + Amount float64 `json:"amount,string"` } `json:"tick"` } @@ -406,11 +408,11 @@ type LastTradeData struct { Ch string `json:"ch"` Tick struct { Data []struct { - Amount float64 `json:"amount,string"` - Direction string `json:"direction"` - ID int64 `json:"id"` - Price float64 `json:"price,string"` - Timestamp int64 `json:"ts"` + Amount float64 `json:"amount,string"` + Direction string `json:"direction"` + ID int64 `json:"id"` + Price float64 `json:"price,string"` + Timestamp types.Time `json:"ts"` } `json:"data"` } `json:"tick"` } @@ -418,17 +420,17 @@ type LastTradeData struct { // BatchTradesData stores batch trades for a given swap contract type BatchTradesData struct { ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []CoinMarginedFuturesTrade `json:"data"` } // CoinMarginedFuturesTrade holds coinmarginedfutures trade data type CoinMarginedFuturesTrade struct { - Amount float64 `json:"amount"` - Direction string `json:"direction"` - ID int64 `json:"id"` - Price float64 `json:"price"` - Timestamp int64 `json:"ts"` + Amount float64 `json:"amount"` + Direction string `json:"direction"` + ID int64 `json:"id"` + Price float64 `json:"price"` + Timestamp types.Time `json:"ts"` } // InsuranceAndClawbackData stores insurance fund's and clawback rate's data @@ -447,8 +449,8 @@ type HistoricalInsuranceFundBalance struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` Tick []struct { - InsuranceFund float64 `json:"insurance_fund"` - Timestamp int64 `json:"ts"` + InsuranceFund float64 `json:"insurance_fund"` + Timestamp types.Time `json:"ts"` } `json:"tick"` TotalPage int64 `json:"total_page"` TotalSize int64 `json:"total_size"` @@ -479,9 +481,9 @@ type OpenInterestData struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` Tick []struct { - Volume float64 `json:"volume"` - AmountType float64 `json:"amountType"` - Timestamp int64 `json:"ts"` + Volume float64 `json:"volume"` + AmountType float64 `json:"amountType"` + Timestamp types.Time `json:"ts"` } `json:"tick"` } `json:"data"` } @@ -507,10 +509,10 @@ type TraderSentimentIndexAccountData struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` List []struct { - BuyRatio float64 `json:"buy_ratio"` - SellRatio float64 `json:"sell_ratio"` - LockedRatio float64 `json:"locked_ratio"` - Timestamp int64 `json:"ts"` + BuyRatio float64 `json:"buy_ratio"` + SellRatio float64 `json:"sell_ratio"` + LockedRatio float64 `json:"locked_ratio"` + Timestamp types.Time `json:"ts"` } `json:"list"` } `json:"data"` } @@ -521,9 +523,9 @@ type TraderSentimentIndexPositionData struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` List []struct { - BuyRatio float64 `json:"buy_ratio"` - SellRatio float64 `json:"sell_ratio"` - Timestamp int64 `json:"ts"` + BuyRatio float64 `json:"buy_ratio"` + SellRatio float64 `json:"sell_ratio"` + Timestamp types.Time `json:"ts"` } `json:"list"` } `json:"data"` } @@ -594,7 +596,7 @@ type PremiumIndexKlineData struct { Open float64 `json:"open,string"` Amount float64 `json:"amount,string"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // EstimatedFundingRateData stores estimated funding rate data @@ -610,7 +612,7 @@ type EstimatedFundingRateData struct { Open float64 `json:"open"` Amount float64 `json:"amount"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // BasisData stores basis data for swaps @@ -623,7 +625,7 @@ type BasisData struct { ID int64 `json:"id"` IndexPrice string `json:"index_price"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // SwapAccountInformation stores swap account information @@ -668,7 +670,7 @@ type SwapPositionInfo struct { // SwapAssetsAndPositionsData stores positions and assets data for swaps type SwapAssetsAndPositionsData struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -705,7 +707,7 @@ type SwapAssetsAndPositionsData struct { // SubAccountsAssetData stores asset data for all subaccounts type SubAccountsAssetData struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { SubUID int64 `json:"sub_uid"` List []struct { @@ -720,7 +722,7 @@ type SubAccountsAssetData struct { // SingleSubAccountAssetsInfo stores asset info for a single subaccount type SingleSubAccountAssetsInfo struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -741,7 +743,7 @@ type SingleSubAccountAssetsInfo struct { // SingleSubAccountPositionsInfo stores single subaccount's positions data type SingleSubAccountPositionsInfo struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -766,19 +768,19 @@ type AvailableLeverageData struct { ContractCode string `json:"contract_code"` AvailableLeverage string `json:"available_level_rate"` } `json:"data"` - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` } // FinancialRecordData stores an accounts financial records type FinancialRecordData struct { Data struct { FinancialRecord []struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - ContractCode string `json:"contract_code"` - OrderType int64 `json:"type"` - Amount float64 `json:"amount"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + ContractCode string `json:"contract_code"` + OrderType int64 `json:"type"` + Amount float64 `json:"amount"` } `json:"financial_record"` TotalPage int64 `json:"total_page"` CurrentPage int64 `json:"current_page"` @@ -797,7 +799,7 @@ type SwapOrderLimitInfo struct { CloseLimit float64 `json:"close_limit"` } `json:"list"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // SwapTradingFeeData stores trading fee data for swaps @@ -811,7 +813,7 @@ type SwapTradingFeeData struct { CloseMakerFee float64 `json:"close_maker_fee,string"` CloseTakerFee float64 `json:"close_taker_fee,string"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // TransferLimitData stores transfer limits @@ -830,7 +832,7 @@ type TransferLimitData struct { NetTransferInMaxDaily float64 `json:"net_transfer_in_max_daily"` NetTransferOutMaxDaily float64 `json:"net_transfer_out_max_daily"` } `json:"data"` - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` } // PositionLimitData stores position limit data @@ -841,7 +843,7 @@ type PositionLimitData struct { BuyLimit float64 `json:"buy_limit"` SellLimit float64 `json:"sell_limit"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // InternalAccountTransferData stores transfer data between subaccounts and main account @@ -854,16 +856,16 @@ type InternalAccountTransferData struct { // InternalAccountTransferRecords stores data for transfer records within the account type InternalAccountTransferRecords struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data struct { TransferRecord []struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - SubUID int64 `json:"sub_uid"` - SubAccountName string `json:"sub_account_name"` - TransferType int64 `json:"transfer_type"` - Amount float64 `json:"amount"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + SubUID int64 `json:"sub_uid"` + SubAccountName string `json:"sub_account_name"` + TransferType int64 `json:"transfer_type"` + Amount float64 `json:"amount"` } `json:"transfer_record"` TotalPage int64 `json:"total_page"` CurrentPage int64 `json:"current_page"` @@ -878,7 +880,7 @@ type SwapOrderData struct { OrderIDString string `json:"order_id_string"` ClientOrderID int64 `json:"client_order_id"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // BatchOrderData stores data for batch orders @@ -895,7 +897,7 @@ type BatchOrderData struct { OrderIDString string `json:"order_id_str"` } `json:"success"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // BatchOrderRequestType stores batch order request data @@ -921,8 +923,8 @@ type CancelOrdersData struct { ErrCode int64 `json:"err_code"` ErrMsg string `json:"err_msg"` } `json:"errors"` - Successes string `json:"successes"` - Timestamp int64 `json:"ts"` + Successes string `json:"successes"` + Timestamp types.Time `json:"ts"` } // LightningCloseOrderData stores order data from a lightning close order @@ -932,7 +934,7 @@ type LightningCloseOrderData struct { OrderIDString string `json:"order_id_str"` ClientOrderID int64 `json:"client_order_id"` } - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // SwapOrderInfo stores info for swap orders @@ -962,7 +964,7 @@ type SwapOrderInfo struct { FeeAsset float64 `json:"fee_asset"` LiquidationType int64 `json:"liquidation_type"` } - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // OrderDetailData acquires order details @@ -1006,7 +1008,7 @@ type OrderDetailData struct { TotalSize int64 `json:"total_size"` CurrentPage int64 `json:"current_page"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // SwapOpenOrdersData stores open orders data for swaps @@ -1039,7 +1041,7 @@ type SwapOpenOrdersData struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // SwapOrderHistory gets order history for swaps @@ -1073,7 +1075,7 @@ type SwapOrderHistory struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // AccountTradeHistoryData stores account trade history for swaps @@ -1102,7 +1104,7 @@ type AccountTradeHistoryData struct { FeeAsset string `json:"fee_asset"` } `json:"trades"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // TriggerOrderData stores trigger order data @@ -1123,7 +1125,7 @@ type CancelTriggerOrdersData struct { } `json:"errors"` Successes string `json:"successes"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // TriggerOpenOrdersData stores trigger open orders data @@ -1151,7 +1153,7 @@ type TriggerOpenOrdersData struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // TriggerOrderHistory stores trigger order history data for swaps @@ -1186,7 +1188,7 @@ type TriggerOrderHistory struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // TransferMarginBetweenAccountsData stores margin transfer data between spot and swap accounts diff --git a/exchanges/huobi/futures_types.go b/exchanges/huobi/futures_types.go index 692f5645cb6..842304827c6 100644 --- a/exchanges/huobi/futures_types.go +++ b/exchanges/huobi/futures_types.go @@ -1,18 +1,20 @@ package huobi +import "github.com/thrasher-corp/gocryptotrader/types" + // FContractInfoData gets contract info data for futures type FContractInfoData struct { Data []struct { - Symbol string `json:"symbol"` - ContractCode string `json:"contract_code"` - ContractType string `json:"contract_type"` - ContractSize float64 `json:"contract_size"` - PriceTick float64 `json:"price_tick"` - DeliveryDate string `json:"delivery_date"` - DeliveryTime int64 `json:"delivery_time,string"` - CreateDate string `json:"create_date"` - ContractStatus int64 `json:"contract_status"` - SettlementTime int64 `json:"settlement_time,string"` + Symbol string `json:"symbol"` + ContractCode string `json:"contract_code"` + ContractType string `json:"contract_type"` + ContractSize float64 `json:"contract_size"` + PriceTick float64 `json:"price_tick"` + DeliveryDate string `json:"delivery_date"` + DeliveryTime types.Time `json:"delivery_time,string"` + CreateDate string `json:"create_date"` + ContractStatus int64 `json:"contract_status"` + SettlementTime types.Time `json:"settlement_time,string"` } } @@ -22,7 +24,7 @@ type FContractIndexPriceInfo struct { Symbol string `json:"symbol"` IndexPrice float64 `json:"index_price"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FContractPriceLimits gets limits for futures contracts @@ -34,13 +36,13 @@ type FContractPriceLimits struct { ContractCode string `json:"contract_code"` ContractType string `json:"contract_type"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FContractOIData stores open interest data for futures contracts type FContractOIData struct { Data []UContractOpenInterest `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // UContractOpenInterest stores open interest data for futures contracts @@ -63,19 +65,19 @@ type FEstimatedDeliveryPriceInfo struct { Data struct { DeliveryPrice float64 `json:"delivery_price"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FMarketDepth gets orderbook data for futures type FMarketDepth struct { - Ch string `json:"ch"` - Timestamp int64 `json:"ts"` + Ch string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { MRID int64 `json:"mrid"` ID int64 `json:"id"` Bids [][2]float64 `json:"bids"` Asks [][2]float64 `json:"asks"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:"version"` Ch string `json:"ch"` } `json:"tick"` @@ -97,16 +99,16 @@ type obItem struct { type FKlineData struct { Ch string `json:"ch"` Data []struct { - Volume float64 `json:"vol"` - Close float64 `json:"close"` - Count float64 `json:"count"` - High float64 `json:"high"` - IDTimestamp int64 `json:"id"` - Low float64 `json:"low"` - Open float64 `json:"open"` - Amount float64 `json:"amount"` + Volume float64 `json:"vol"` + Close float64 `json:"close"` + Count float64 `json:"count"` + High float64 `json:"high"` + IDTimestamp types.Time `json:"id"` + Low float64 `json:"low"` + Open float64 `json:"open"` + Amount float64 `json:"amount"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FMarketOverviewData stores overview data for futures @@ -116,16 +118,16 @@ type FMarketOverviewData struct { Vol float64 `json:"vol,string"` Ask [2]float64 Bid [2]float64 - Close float64 `json:"close,string"` - Count float64 `json:"count"` - High float64 `json:"high,string"` - ID int64 `jso:"id"` - Low float64 `json:"low,string"` - Open float64 `json:"open,string"` - Timestamp int64 `json:"ts"` - Amount float64 `json:"amount,string"` + Close float64 `json:"close,string"` + Count float64 `json:"count"` + High float64 `json:"high,string"` + ID int64 `jso:"id"` + Low float64 `json:"low,string"` + Open float64 `json:"open,string"` + Timestamp types.Time `json:"ts"` + Amount float64 `json:"amount,string"` } `json:"tick"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FLastTradeData stores last trade's data for a contract @@ -133,41 +135,41 @@ type FLastTradeData struct { Ch string `json:"ch"` Tick struct { Data []struct { - Amount float64 `json:"amount,string"` - Direction string `json:"direction"` - ID int64 `json:"id"` - Price float64 `json:"price,string"` - Timestamp int64 `json:"ts"` + Amount float64 `json:"amount,string"` + Direction string `json:"direction"` + ID int64 `json:"id"` + Price float64 `json:"price,string"` + Timestamp types.Time `json:"ts"` } `json:"data"` - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` } `json:"tick"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FBatchTradesForContractData stores batch of trades data for a contract type FBatchTradesForContractData struct { - Ch string `json:"ch"` - Timestamp int64 `json:"ts"` + Ch string `json:"ch"` + Timestamp types.Time `json:"ts"` Data []struct { ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []FuturesTrade `json:"data"` } `json:"data"` } // FuturesTrade is futures trade data type FuturesTrade struct { - Amount float64 `json:"amount"` - Direction string `json:"direction"` - ID int64 `json:"id"` - Price float64 `json:"price"` - Timestamp int64 `json:"ts"` + Amount float64 `json:"amount"` + Direction string `json:"direction"` + ID int64 `json:"id"` + Price float64 `json:"price"` + Timestamp types.Time `json:"ts"` } // FClawbackRateAndInsuranceData stores clawback rate and insurance data for futures type FClawbackRateAndInsuranceData struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { Symbol string `json:"symbol"` InsuranceFund float64 `json:"insurance_fund"` @@ -177,12 +179,12 @@ type FClawbackRateAndInsuranceData struct { // FHistoricalInsuranceRecordsData stores historical records of insurance fund balances for futures type FHistoricalInsuranceRecordsData struct { - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` Data struct { Symbol string `json:"symbol"` Tick []struct { - InsuranceFund float64 `json:"insurance_fund"` - Timestamp int64 `json:"ts"` + InsuranceFund float64 `json:"insurance_fund"` + Timestamp types.Time `json:"ts"` } `json:"tick"` } `json:"data"` } @@ -201,7 +203,7 @@ type FTieredAdjustmentFactorInfo struct { } `json:"ladders"` } `json:"list"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FOIData gets oi data on futures @@ -210,12 +212,12 @@ type FOIData struct { Symbol string `json:"symbol"` ContractType string `json:"contract_type"` Tick []struct { - Volume float64 `json:"volume,string"` - AmountType int64 `json:"amount_type"` - Timestamp int64 `json:"ts"` + Volume float64 `json:"volume,string"` + AmountType int64 `json:"amount_type"` + Timestamp types.Time `json:"ts"` } `json:"tick"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FInfoSystemStatusData stores system status info for futures @@ -228,21 +230,21 @@ type FInfoSystemStatusData struct { TransferIn int64 `json:"transfer_in"` TransferOut int64 `json:"transfer_out"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTopAccountsLongShortRatio stores long/short ratio for top futures accounts type FTopAccountsLongShortRatio struct { Data struct { List []struct { - BuyRatio float64 `json:"buy_ratio"` - SellRatio float64 `json:"sell_ratio"` - LockedRatio float64 `json:"locked_ratio"` - Timestamp int64 `json:"ts"` + BuyRatio float64 `json:"buy_ratio"` + SellRatio float64 `json:"sell_ratio"` + LockedRatio float64 `json:"locked_ratio"` + Timestamp types.Time `json:"ts"` } `json:"list"` Symbol string `json:"symbol"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTopPositionsLongShortRatio stores long short ratio for top futures positions @@ -250,12 +252,12 @@ type FTopPositionsLongShortRatio struct { Data struct { Symbol string `json:"symbol"` List []struct { - BuyRatio float64 `json:"buy_ratio"` - SellRatio float64 `json:"sell_ratio"` - Timestamp int64 `json:"timestamp"` + BuyRatio float64 `json:"buy_ratio"` + SellRatio float64 `json:"sell_ratio"` + Timestamp types.Time `json:"timestamp"` } `json:"list"` } `json:"data"` - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` } // FLiquidationOrdersInfo stores data of futures liquidation orders @@ -274,7 +276,7 @@ type FLiquidationOrdersInfo struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FIndexKlineData stores index kline data for futures @@ -290,7 +292,7 @@ type FIndexKlineData struct { Open float64 `json:"open"` Amount float64 `json:"amount"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FBasisData stores basis data for futures @@ -303,7 +305,7 @@ type FBasisData struct { ID int64 `json:"id"` IndexPrice float64 `json:"index_price,string"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FUserAccountData stores user account data info for futures @@ -323,7 +325,7 @@ type FUserAccountData struct { AdjustFactor float64 `json:"adjust_factor"` MarginStatic float64 `json:"margin_static"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FUsersPositionsInfo stores positions data for futures @@ -345,12 +347,12 @@ type FUsersPositionsInfo struct { Direction string `json:"direction"` LastPrice float64 `json:"last_price"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FSubAccountAssetsInfo gets subaccounts asset data type FSubAccountAssetsInfo struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data []struct { SubUID int64 `json:"sub_uid"` List []struct { @@ -379,7 +381,7 @@ type FSingleSubAccountAssetsInfo struct { LeverageRate float64 `json:"lever_rate"` MarginStatic float64 `json:"margin_static"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FSingleSubAccountPositionsInfo stores futures positions' info for a single subaccount @@ -401,24 +403,24 @@ type FSingleSubAccountPositionsInfo struct { Direction string `json:"direction"` LastPrice float64 `json:"last_price"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FFinancialRecords stores financial records data for futures type FFinancialRecords struct { Data struct { FinancialRecord []struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - RecordType int64 `json:"type"` - Amount float64 `json:"amount"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + RecordType int64 `json:"type"` + Amount float64 `json:"amount"` } `json:"financial_record"` TotalPage int64 `json:"total_page"` CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FSettlementRecords stores user's futures settlement records @@ -452,7 +454,7 @@ type FSettlementRecords struct { TotalPage int64 `json:"total_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FContractInfoOnOrderLimit stores contract info on futures order limit @@ -468,7 +470,7 @@ type FContractInfoOnOrderLimit struct { } `json:"types"` } `json:"list"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FContractTradingFeeData stores contract trading fee data @@ -482,7 +484,7 @@ type FContractTradingFeeData struct { DeliveryFee float64 `json:"delivery_fee,string"` FeeAsset string `json:"fee_asset"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTransferLimitData stores transfer limit data for futures @@ -498,7 +500,7 @@ type FTransferLimitData struct { NetTransferInMaxDaily float64 `json:"net_transfer_in_max_daily"` NetTransferOutMaxDaily float64 `json:"net_transfer_out_max_daily"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FPositionLimitData stores information on futures positions limit @@ -511,7 +513,7 @@ type FPositionLimitData struct { SellLimit float64 `json:"sell_limit"` } `json:"list"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FAssetsAndPositionsData stores assets and positions data for futures @@ -531,8 +533,8 @@ type FAssetsAndPositionsData struct { // FAccountTransferData stores internal transfer data for futures type FAccountTransferData struct { - Status string `json:"status"` - Timestamp int64 `json:"ts"` + Status string `json:"status"` + Timestamp types.Time `json:"ts"` Data struct { OrderID string `json:"order_id"` } `json:"data"` @@ -540,16 +542,16 @@ type FAccountTransferData struct { // FTransferRecords gets transfer records data type FTransferRecords struct { - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Data struct { TransferRecord []struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - SubUID int64 `json:"sub_uid"` - SubAccountName string `json:"sub_account_name"` - TransferType int64 `json:"transfer_type"` - Amount float64 `json:"amount"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + SubUID int64 `json:"sub_uid"` + SubAccountName string `json:"sub_account_name"` + TransferType int64 `json:"transfer_type"` + Amount float64 `json:"amount"` } `json:"transfer_record"` TotalPage int64 `json:"total_page"` CurrentPage int64 `json:"current_page"` @@ -563,7 +565,7 @@ type FAvailableLeverageData struct { Symbol string `json:"symbol"` AvailableLeverageRate string `json:"available_level_rate"` } `json:"data"` - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` } // FOrderData stores order data for futures @@ -573,7 +575,7 @@ type FOrderData struct { OrderIDStr string `json:"order_id_str"` ClientOrderID int64 `json:"client_order_id"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } type fBatchOrderData struct { @@ -604,7 +606,7 @@ type FCancelOrderData struct { } `json:"errors"` Successes string `json:"successes"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FOrderInfo stores order info @@ -636,7 +638,7 @@ type FOrderInfo struct { Volume float64 `json:"volume"` LiquidationType int64 `json:"liquidation_type"` } `json:"data"` - Timestamp int64 `json:"timestamp"` + Timestamp types.Time `json:"timestamp"` } // FOrderDetailsData stores order details for futures orders @@ -682,7 +684,7 @@ type FOrderDetailsData struct { TotalSize int64 `json:"total_size"` CurrentPage int64 `json:"current_page"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FOpenOrdersData stores open orders data for futures @@ -716,7 +718,7 @@ type FOpenOrdersData struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FOrderHistoryData stores order history data @@ -751,7 +753,7 @@ type FOrderHistoryData struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTradeHistoryData stores trade history data for futures @@ -781,7 +783,7 @@ type FTradeHistoryData struct { FeeAsset string `json:"fee_asset"` } `json:"trades"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTriggerOrderData stores trigger order data @@ -790,7 +792,7 @@ type FTriggerOrderData struct { OrderID int64 `json:"order_id"` OrderIDStr string `json:"order_id_str"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTriggerOpenOrders stores trigger open orders data @@ -819,7 +821,7 @@ type FTriggerOpenOrders struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // FTriggerOrderHistoryData stores trigger order history for futures @@ -855,5 +857,5 @@ type FTriggerOrderHistoryData struct { CurrentPage int64 `json:"current_page"` TotalSize int64 `json:"total_size"` } `json:"data"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } diff --git a/exchanges/huobi/huobi_types.go b/exchanges/huobi/huobi_types.go index 99fd712168d..b460f912ed9 100644 --- a/exchanges/huobi/huobi_types.go +++ b/exchanges/huobi/huobi_types.go @@ -12,7 +12,7 @@ type errorCapture struct { ErrMsgType1 string `json:"err-msg"` CodeType2 interface{} `json:"err_code"` ErrMsgType2 string `json:"err_msg"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` } // MarketSummary24Hr stores past 24hr market summary data of a given symbol @@ -61,8 +61,8 @@ type CurrenciesChainData struct { // WsKlineData stores kline data for futures and swap websocket type WsKlineData struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` MRID int64 `json:"mrid"` @@ -78,14 +78,14 @@ type WsKlineData struct { // WsMarketDepth stores market depth data for futures and swap websocket type WsMarketDepth struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { MRID int64 `json:"mrid"` ID int64 `json:"id"` Bids [][2]float64 `json:"bids"` Asks [][2]float64 `json:"asks"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:"version"` Channel string `json:"ch"` } `json:"tick"` @@ -93,14 +93,14 @@ type WsMarketDepth struct { // WsIncrementalMarketDepth stores incremental market depth data for swap and futures websocket type WsIncrementalMarketDepth struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { MRID int64 `json:"mrid"` ID int64 `json:"id"` Bids [][2]float64 `json:"bids"` Asks [][2]float64 `json:"asks"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:"version"` Channel string `json:"ch"` Event string `json:"event"` @@ -109,8 +109,8 @@ type WsIncrementalMarketDepth struct { // WsMarketDetail stores market detail data for futures and swap websocket type WsMarketDetail struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` MRID int64 `json:"mrid"` @@ -126,32 +126,32 @@ type WsMarketDetail struct { // WsMarketBBOData stores BBO data for futures and swap websocket type WsMarketBBOData struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { Channel string `json:"ch"` MRID int64 `json:"mrid"` ID int64 `json:"id"` Bid [2]float64 `json:"bid"` Ask [2]float64 `json:"ask"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:":version"` } `json:"tick"` } // WsSubTradeDetail stores trade detail data for futures websocket type WsSubTradeDetail struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` Data []struct { - Amount float64 `json:"amount"` - Timestamp int64 `json:"ts"` - ID int64 `json:"id"` - Price float64 `json:"price"` - Direction string `json:"direction"` + Amount float64 `json:"amount"` + Timestamp types.Time `json:"ts"` + ID int64 `json:"id"` + Price float64 `json:"price"` + Direction string `json:"direction"` } `json:"data"` } `json:"tick"` } @@ -179,22 +179,22 @@ type FWsRequestKline struct { // FWsReqTradeDetail stores requested trade detail data for futures websocket type FWsReqTradeDetail struct { - Rep string `json:"rep"` - ID string `json:"id"` - Timestamp int64 `json:"ts"` + Rep string `json:"rep"` + ID string `json:"id"` + Timestamp types.Time `json:"ts"` Data []struct { - ID int64 `json:"id"` - Price float64 `json:"price"` - Amount float64 `json:"amount"` - Direction string `json:"direction"` - Timestamp int64 `json:"ts"` + ID int64 `json:"id"` + Price float64 `json:"price"` + Amount float64 `json:"amount"` + Direction string `json:"direction"` + Timestamp types.Time `json:"ts"` } `json:"data"` } // FWsSubKlineIndex stores subscribed kline index data for futures websocket type FWsSubKlineIndex struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID string `json:"id"` Open float64 `json:"open,string"` @@ -209,10 +209,10 @@ type FWsSubKlineIndex struct { // FWsReqKlineIndex stores requested kline index data for futures websocket type FWsReqKlineIndex struct { - ID string `json:"id"` - Rep string `json:"rep"` - WsID int64 `json:"wsid"` - Timestamp int64 `json:"ts"` + ID string `json:"id"` + Rep string `json:"rep"` + WsID int64 `json:"wsid"` + Timestamp types.Time `json:"ts"` Data []struct { ID int64 `json:"id"` Open float64 `json:"open"` @@ -227,8 +227,8 @@ type FWsReqKlineIndex struct { // FWsSubBasisData stores subscribed basis data for futures websocket type FWsSubBasisData struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` IndexPrice float64 `json:"index_price,string"` @@ -240,10 +240,10 @@ type FWsSubBasisData struct { // FWsReqBasisData stores requested basis data for futures websocket type FWsReqBasisData struct { - ID string `json:"id"` - Rep string `json:"rep"` - Timestamp int64 `json:"ts"` - WsID int64 `json:"wsid"` + ID string `json:"id"` + Rep string `json:"rep"` + Timestamp types.Time `json:"ts"` + WsID int64 `json:"wsid"` Tick struct { ID int64 `json:"id"` IndexPrice float64 `json:"index_price,string"` @@ -255,34 +255,34 @@ type FWsReqBasisData struct { // FWsSubOrderData stores subscribed order data for futures websocket type FWsSubOrderData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - ContractType string `json:"contract_type"` - ContractCode string `json:"contract_code"` - Volume float64 `json:"volume"` - Price float64 `json:"price"` - OrderPriceType string `json:"order_price_type"` - Direction string `json:"direction"` - Offset string `json:"offset"` - Status int64 `json:"status"` - LeverageRate int64 `json:"lever_rate"` - OrderID int64 `json:"order_id"` - OrderIDString string `json:"order_id_string"` - ClientOrderID int64 `json:"client_order_id"` - OrderSource string `json:"order_source"` - OrderType int64 `json:"order_type"` - CreatedAt int64 `json:"created_at"` - TradeVolume float64 `json:"trade_volume"` - TradeTurnover float64 `json:"trade_turnover"` - Fee float64 `json:"fee"` - TradeAvgPrice float64 `json:"trade_avg_price"` - MarginFrozen float64 `json:"margin_frozen"` - Profit float64 `json:"profit"` - FeeAsset string `json:"fee_asset"` - CancelledAt int64 `json:"canceled_at"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + ContractType string `json:"contract_type"` + ContractCode string `json:"contract_code"` + Volume float64 `json:"volume"` + Price float64 `json:"price"` + OrderPriceType string `json:"order_price_type"` + Direction string `json:"direction"` + Offset string `json:"offset"` + Status int64 `json:"status"` + LeverageRate int64 `json:"lever_rate"` + OrderID int64 `json:"order_id"` + OrderIDString string `json:"order_id_string"` + ClientOrderID int64 `json:"client_order_id"` + OrderSource string `json:"order_source"` + OrderType int64 `json:"order_type"` + CreatedAt int64 `json:"created_at"` + TradeVolume float64 `json:"trade_volume"` + TradeTurnover float64 `json:"trade_turnover"` + Fee float64 `json:"fee"` + TradeAvgPrice float64 `json:"trade_avg_price"` + MarginFrozen float64 `json:"margin_frozen"` + Profit float64 `json:"profit"` + FeeAsset string `json:"fee_asset"` + CancelledAt int64 `json:"canceled_at"` Trade []struct { ID string `json:"id"` TradeID int64 `json:"trade_id"` @@ -298,20 +298,20 @@ type FWsSubOrderData struct { // FWsSubMatchOrderData stores subscribed match order data for futures websocket type FWsSubMatchOrderData struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Symbol string `json:"symbol"` - ContractType string `json:"contract_type"` - ContractCode string `json:"contract_code"` - Status int64 `json:"status"` - OrderID int64 `json:"order_id"` - OrderIDString string `json:"order_id_string"` - OrderType string `json:"order_type"` - Volume float64 `json:"volume"` - TradeVolume float64 `json:"trade_volume"` - ClientOrderID int64 `json:"client_order_id"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Symbol string `json:"symbol"` + ContractType string `json:"contract_type"` + ContractCode string `json:"contract_code"` + Status int64 `json:"status"` + OrderID int64 `json:"order_id"` + OrderIDString string `json:"order_id_string"` + OrderType string `json:"order_type"` + Volume float64 `json:"volume"` + TradeVolume float64 `json:"trade_volume"` + ClientOrderID int64 `json:"client_order_id"` Trade []struct { ID string `json:"id"` TradeID int64 `json:"trade_id"` @@ -325,11 +325,11 @@ type FWsSubMatchOrderData struct { // FWsSubEquityUpdates stores account equity updates data for futures websocket type FWsSubEquityUpdates struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Event string `json:"event"` Data []struct { Symbol string `json:"symbol"` MarginBalance float64 `json:"margin_balance"` @@ -349,11 +349,11 @@ type FWsSubEquityUpdates struct { // FWsSubPositionUpdates stores subscribed position updates data for futures websocket type FWsSubPositionUpdates struct { - Operation string `json:"op"` - Topic string `json:"topic"` - UID string `json:"uid"` - Timestamp int64 `json:"ts"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + UID string `json:"uid"` + Timestamp types.Time `json:"ts"` + Event string `json:"event"` PositionsData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -375,9 +375,9 @@ type FWsSubPositionUpdates struct { // FWsSubLiquidationOrders stores subscribed liquidation orders data for futures websocket type FWsSubLiquidationOrders struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` OrdersData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -391,10 +391,10 @@ type FWsSubLiquidationOrders struct { // FWsSubContractInfo stores contract info data for futures websocket type FWsSubContractInfo struct { - Operation string `json:"op"` - Topic string `json:"topic"` - Timestamp int64 `json:"ts"` - Event string `json:"event"` + Operation string `json:"op"` + Topic string `json:"topic"` + Timestamp types.Time `json:"ts"` + Event string `json:"event"` ContractData []struct { Symbol string `json:"symbol"` ContractCode string `json:"contract_code"` @@ -445,11 +445,11 @@ type FWsSubTriggerOrderUpdates struct { // Response stores the Huobi response information type Response struct { - Status string `json:"status"` - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` - ErrorCode string `json:"err-code"` - ErrorMessage string `json:"err-msg"` + Status string `json:"status"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` + ErrorCode string `json:"err-code"` + ErrorMessage string `json:"err-msg"` } // MarginRatesData stores margin rates data @@ -487,14 +487,14 @@ type SwapMarketsData struct { // KlineItem stores a kline item type KlineItem struct { - IDTimestamp int64 `json:"id"` - Open float64 `json:"open"` - Close float64 `json:"close"` - Low float64 `json:"low"` - High float64 `json:"high"` - Amount float64 `json:"amount"` - Volume float64 `json:"vol"` - Count int `json:"count"` + IDTimestamp types.Time `json:"id"` + Open float64 `json:"open"` + Close float64 `json:"close"` + Low float64 `json:"low"` + High float64 `json:"high"` + Amount float64 `json:"amount"` + Volume float64 `json:"vol"` + Count int `json:"count"` } // CancelOpenOrdersBatch stores open order batch response data @@ -524,7 +524,7 @@ type Tickers struct { // FuturesBatchTicker holds ticker data type FuturesBatchTicker struct { ID float64 `json:"id"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Ask [2]float64 `json:"ask"` Bid [2]float64 `json:"bid"` BusinessType string `json:"business_type"` @@ -587,31 +587,31 @@ type Orderbook struct { // Trade stores the trade data type Trade struct { - TradeID float64 `json:"trade-id"` - Price float64 `json:"price"` - Amount float64 `json:"amount"` - Direction string `json:"direction"` - Timestamp int64 `json:"ts"` + TradeID float64 `json:"trade-id"` + Price float64 `json:"price"` + Amount float64 `json:"amount"` + Direction string `json:"direction"` + Timestamp types.Time `json:"ts"` } // TradeHistory stores the trade history data type TradeHistory struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` - Trades []Trade `json:"data"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` + Trades []Trade `json:"data"` } // Detail stores the ticker detail data type Detail struct { - Amount float64 `json:"amount"` - Open float64 `json:"open"` - Close float64 `json:"close"` - High float64 `json:"high"` - Timestamp int64 `json:"timestamp"` - ID int64 `json:"id"` - Count int `json:"count"` - Low float64 `json:"low"` - Volume float64 `json:"vol"` + Amount float64 `json:"amount"` + Open float64 `json:"open"` + Close float64 `json:"close"` + High float64 `json:"high"` + Timestamp types.Time `json:"timestamp"` + ID int64 `json:"id"` + Count int `json:"count"` + Low float64 `json:"low"` + Volume float64 `json:"vol"` } // Symbol stores the symbol data @@ -821,20 +821,20 @@ type WsHeartBeat struct { // WsDepth defines market depth websocket response type WsDepth struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { Bids [][]interface{} `json:"bids"` Asks [][]interface{} `json:"asks"` - Timestamp int64 `json:"ts"` + Timestamp types.Time `json:"ts"` Version int64 `json:"version"` } `json:"tick"` } // WsKline defines market kline websocket response type WsKline struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { ID int64 `json:"id"` Open float64 `json:"open"` @@ -849,35 +849,35 @@ type WsKline struct { // WsTick stores websocket ticker data type WsTick struct { - Channel string `json:"ch"` - Rep string `json:"rep"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Rep string `json:"rep"` + Timestamp types.Time `json:"ts"` Tick struct { - Amount float64 `json:"amount"` - Close float64 `json:"close"` - Count float64 `json:"count"` - High float64 `json:"high"` - ID float64 `json:"id"` - Low float64 `json:"low"` - Open float64 `json:"open"` - Timestamp float64 `json:"ts"` - Volume float64 `json:"vol"` + Amount float64 `json:"amount"` + Close float64 `json:"close"` + Count float64 `json:"count"` + High float64 `json:"high"` + ID float64 `json:"id"` + Low float64 `json:"low"` + Open float64 `json:"open"` + Timestamp types.Time `json:"ts"` + Volume float64 `json:"vol"` } `json:"tick"` } // WsTrade defines market trade websocket response type WsTrade struct { - Channel string `json:"ch"` - Timestamp int64 `json:"ts"` + Channel string `json:"ch"` + Timestamp types.Time `json:"ts"` Tick struct { - ID int64 `json:"id"` - Timestamp int64 `json:"ts"` + ID int64 `json:"id"` + Timestamp types.Time `json:"ts"` Data []struct { - Amount float64 `json:"amount"` - Timestamp int64 `json:"ts"` - TradeID float64 `json:"tradeId"` - Price float64 `json:"price"` - Direction string `json:"direction"` + Amount float64 `json:"amount"` + Timestamp types.Time `json:"ts"` + TradeID float64 `json:"tradeId"` + Price float64 `json:"price"` + Direction string `json:"direction"` } `json:"data"` } } diff --git a/exchanges/huobi/huobi_websocket.go b/exchanges/huobi/huobi_websocket.go index f70ae4c70cf..f18c2cf05fc 100644 --- a/exchanges/huobi/huobi_websocket.go +++ b/exchanges/huobi/huobi_websocket.go @@ -224,7 +224,7 @@ func (h *HUOBI) wsHandleCandleMsg(s *subscription.Subscription, respRaw []byte) return err } h.Websocket.DataHandler <- stream.KlineData{ - Timestamp: time.UnixMilli(c.Timestamp), + Timestamp: c.Timestamp.Time(), Exchange: h.Name, AssetType: s.Asset, Pair: s.Pairs[0], @@ -259,7 +259,7 @@ func (h *HUOBI) wsHandleAllTradesMsg(s *subscription.Subscription, respRaw []byt Exchange: h.Name, AssetType: s.Asset, CurrencyPair: s.Pairs[0], - Timestamp: time.UnixMilli(t.Tick.Data[i].Timestamp), + Timestamp: t.Tick.Data[i].Timestamp.Time(), Amount: t.Tick.Data[i].Amount, Price: t.Tick.Data[i].Price, Side: side, @@ -285,7 +285,7 @@ func (h *HUOBI) wsHandleTickerMsg(s *subscription.Subscription, respRaw []byte) QuoteVolume: wsTicker.Tick.Volume, High: wsTicker.Tick.High, Low: wsTicker.Tick.Low, - LastUpdated: time.UnixMilli(wsTicker.Timestamp), + LastUpdated: wsTicker.Timestamp.Time(), AssetType: s.Asset, Pair: s.Pairs[0], } @@ -339,7 +339,7 @@ func (h *HUOBI) wsHandleOrderbookMsg(s *subscription.Subscription, respRaw []byt newOrderBook.Asset = asset.Spot newOrderBook.Exchange = h.Name newOrderBook.VerifyOrderbook = h.CanVerifyOrderbook - newOrderBook.LastUpdated = time.UnixMilli(update.Timestamp) + newOrderBook.LastUpdated = update.Timestamp.Time() return h.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index 4de8f9ae110..d60dd1d3939 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -397,7 +397,7 @@ func (h *HUOBI) UpdateTickers(ctx context.Context, a asset.Item) error { } continue } - tt := time.UnixMilli(ticks[i].Timestamp) + tt := ticks[i].Timestamp.Time() err = ticker.ProcessTicker(&ticker.Price{ High: ticks[i].High.Float64(), Low: ticks[i].Low.Float64(), @@ -465,7 +465,7 @@ func (h *HUOBI) UpdateTickers(ctx context.Context, a asset.Item) error { Pair: cp, ExchangeName: h.Name, AssetType: a, - LastUpdated: time.UnixMilli(ticks[i].Timestamp), + LastUpdated: ticks[i].Timestamp.Time(), }) if err != nil { errs = common.AppendError(errs, err) @@ -920,7 +920,7 @@ func (h *HUOBI) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.It Side: side, Price: sTrades[i].Trades[j].Price, Amount: sTrades[i].Trades[j].Amount, - Timestamp: time.UnixMilli(sTrades[i].Timestamp), + Timestamp: sTrades[i].Timestamp.Time(), }) } } @@ -947,7 +947,7 @@ func (h *HUOBI) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.It Side: side, Price: fTrades.Data[i].Data[j].Price, Amount: fTrades.Data[i].Data[j].Amount, - Timestamp: time.UnixMilli(fTrades.Data[i].Data[j].Timestamp), + Timestamp: fTrades.Data[i].Data[j].Timestamp.Time(), }) } } @@ -973,7 +973,7 @@ func (h *HUOBI) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.It Side: side, Price: cTrades.Data[i].Price, Amount: cTrades.Data[i].Amount, - Timestamp: time.UnixMilli(cTrades.Data[i].Timestamp), + Timestamp: cTrades.Data[i].Timestamp.Time(), }) } } @@ -1866,7 +1866,7 @@ func (h *HUOBI) GetHistoricCandles(ctx context.Context, pair currency.Pair, a as } for x := range candles { - timestamp := time.Unix(candles[x].IDTimestamp, 0) + timestamp := candles[x].IDTimestamp.Time() if timestamp.Before(req.Start) || timestamp.After(req.End) { continue } @@ -1887,7 +1887,7 @@ func (h *HUOBI) GetHistoricCandles(ctx context.Context, pair currency.Pair, a as return nil, err } for x := range candles.Data { - timestamp := time.Unix(candles.Data[x].IDTimestamp, 0) + timestamp := candles.Data[x].IDTimestamp.Time() if timestamp.Before(req.Start) || timestamp.After(req.End) { continue } @@ -1908,7 +1908,7 @@ func (h *HUOBI) GetHistoricCandles(ctx context.Context, pair currency.Pair, a as return nil, err } for x := range candles.Data { - timestamp := time.Unix(candles.Data[x].IDTimestamp, 0) + timestamp := candles.Data[x].IDTimestamp.Time() if timestamp.Before(req.Start) || timestamp.After(req.End) { continue } @@ -1948,7 +1948,7 @@ func (h *HUOBI) GetHistoricCandlesExtended(ctx context.Context, pair currency.Pa } for x := range candles.Data { // align response data - timestamp := time.Unix(candles.Data[x].IDTimestamp, 0).UTC() + timestamp := candles.Data[x].IDTimestamp.Time() if timestamp.Before(req.Start) || timestamp.After(req.End) { continue } @@ -1973,7 +1973,7 @@ func (h *HUOBI) GetHistoricCandlesExtended(ctx context.Context, pair currency.Pa } for x := range candles.Data { // align response data - timestamp := time.Unix(candles.Data[x].IDTimestamp, 0) + timestamp := candles.Data[x].IDTimestamp.Time() if timestamp.Before(req.Start) || timestamp.After(req.End) { continue } @@ -2128,10 +2128,10 @@ func (h *HUOBI) GetFuturesContractDetails(ctx context.Context, item asset.Item) if err != nil { return nil, err } - if result.Data[x].DeliveryTime > 0 { - e = time.UnixMilli(result.Data[x].DeliveryTime) + if result.Data[x].DeliveryTime.Time().IsZero() { + e = result.Data[x].DeliveryTime.Time() } else { - e = time.UnixMilli(result.Data[x].SettlementTime) + e = result.Data[x].SettlementTime.Time() } contractLength := e.Sub(s) var ct futures.ContractType