From 8b8d96c61255eea670d9282c4a4cb7d2508cc553 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Mon, 18 Sep 2023 17:15:27 +1000 Subject: [PATCH] gate.io: Enforce the use of 'convert.StringToFloat64' and permit its use in outbound requests (#1308) Co-authored-by: Ryan O'Hara-Reid --- common/convert/convert.go | 9 + common/convert/convert_test.go | 18 + exchanges/gateio/gateio.go | 4 +- exchanges/gateio/gateio_test.go | 11 + exchanges/gateio/gateio_types.go | 1941 +++++++++++++------------ exchanges/gateio/gateio_websocket.go | 50 +- exchanges/gateio/gateio_wrapper.go | 149 +- exchanges/gateio/gateio_ws_futures.go | 34 +- exchanges/gateio/gateio_ws_option.go | 24 +- 9 files changed, 1140 insertions(+), 1100 deletions(-) diff --git a/common/convert/convert.go b/common/convert/convert.go index ec0153f0..949e368d 100644 --- a/common/convert/convert.go +++ b/common/convert/convert.go @@ -222,6 +222,15 @@ func (f *StringToFloat64) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaler interface. +func (f StringToFloat64) MarshalJSON() ([]byte, error) { + if f == 0 { + return []byte(jsonStringIdent + jsonStringIdent), nil + } + val := strconv.FormatFloat(float64(f), 'f', -1, 64) + return []byte(jsonStringIdent + val + jsonStringIdent), nil +} + // Float64 returns the float64 value of the FloatString. func (f *StringToFloat64) Float64() float64 { return float64(*f) diff --git a/common/convert/convert_test.go b/common/convert/convert_test.go index b1781f34..c84318ac 100644 --- a/common/convert/convert_test.go +++ b/common/convert/convert_test.go @@ -353,6 +353,24 @@ func TestStringToFloat64(t *testing.T) { if err == nil { t.Fatal("error cannot be nil") } + + data, err := json.Marshal(StringToFloat64(0)) + if err != nil { + t.Fatal(err) + } + + if string(data) != `""` { + t.Fatalf("expected empty string, got %v", string(data)) + } + + data, err = json.Marshal(StringToFloat64(1337.1337)) + if err != nil { + t.Fatal(err) + } + + if string(data) != `"1337.1337"` { + t.Fatalf("expected \"1337.1337\" string, got %v", string(data)) + } } func TestStringToFloat64Decimal(t *testing.T) { diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index c4f6f1dd..0e4baa19 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -3796,11 +3796,11 @@ func (g *Gateio) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (f return 0, err } if feeBuilder.IsMaker { - fee = calculateTradingFee(feePairs.MakerFee, + fee = calculateTradingFee(feePairs.MakerFee.Float64(), feeBuilder.PurchasePrice, feeBuilder.Amount) } else { - fee = calculateTradingFee(feePairs.TakerFee, + fee = calculateTradingFee(feePairs.TakerFee.Float64(), feeBuilder.PurchasePrice, feeBuilder.Amount) } diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index 814e12b7..f35e40bb 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -3386,3 +3386,14 @@ func TestUpdateOrderExecutionLimits(t *testing.T) { } } } + +func TestForceFileStandard(t *testing.T) { + t.Parallel() + err := sharedtestvalues.ForceFileStandard(t, sharedtestvalues.EmptyStringPotentialPattern) + if err != nil { + t.Error(err) + } + if t.Failed() { + t.Fatal("Please use convert.StringToFloat64 type instead of `float64` and remove `,string` as strings can be empty in unmarshal process. Then call the Float64() method.") + } +} diff --git a/exchanges/gateio/gateio_types.go b/exchanges/gateio/gateio_types.go index b07bff72..a476cd7e 100644 --- a/exchanges/gateio/gateio_types.go +++ b/exchanges/gateio/gateio_types.go @@ -5,6 +5,7 @@ import ( "strconv" "time" + "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) @@ -479,14 +480,14 @@ var WithdrawalFees = map[currency.Code]float64{ // CurrencyInfo represents currency details with permission. type CurrencyInfo struct { - Currency string `json:"currency"` - Delisted bool `json:"delisted"` - WithdrawDisabled bool `json:"withdraw_disabled"` - WithdrawDelayed bool `json:"withdraw_delayed"` - DepositDisabled bool `json:"deposit_disabled"` - TradeDisabled bool `json:"trade_disabled"` - FixedFeeRate float64 `json:"fixed_rate,omitempty,string"` - Chain string `json:"chain"` + Currency string `json:"currency"` + Delisted bool `json:"delisted"` + WithdrawDisabled bool `json:"withdraw_disabled"` + WithdrawDelayed bool `json:"withdraw_delayed"` + DepositDisabled bool `json:"deposit_disabled"` + TradeDisabled bool `json:"trade_disabled"` + FixedFeeRate convert.StringToFloat64 `json:"fixed_rate,omitempty"` + Chain string `json:"chain"` } // CurrencyPairDetail represents a single currency pair detail. @@ -589,18 +590,18 @@ type Orderbook struct { // Trade represents market trade. type Trade struct { - ID int64 `json:"id,string"` - TradingTime gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - OrderID string `json:"order_id"` - Side string `json:"side"` - Role string `json:"role"` - Amount float64 `json:"amount,string"` - Price float64 `json:"price,string"` - Fee float64 `json:"fee,string"` - FeeCurrency string `json:"fee_currency"` - PointFee string `json:"point_fee"` - GtFee string `json:"gt_fee"` + ID int64 `json:"id,string"` + TradingTime gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + OrderID string `json:"order_id"` + Side string `json:"side"` + Role string `json:"role"` + Amount convert.StringToFloat64 `json:"amount"` + Price convert.StringToFloat64 `json:"price"` + Fee convert.StringToFloat64 `json:"fee"` + FeeCurrency string `json:"fee_currency"` + PointFee string `json:"point_fee"` + GtFee string `json:"gt_fee"` } // Candlestick represents candlestick data point detail. @@ -626,87 +627,87 @@ type CurrencyChain struct { // MarginCurrencyPairInfo represents margin currency pair detailed info. type MarginCurrencyPairInfo struct { - ID string `json:"id"` - Base string `json:"base"` - Quote string `json:"quote"` - Leverage float64 `json:"leverage"` - MinBaseAmount float64 `json:"min_base_amount,string"` - MinQuoteAmount float64 `json:"min_quote_amount,string"` - MaxQuoteAmount float64 `json:"max_quote_amount,string"` - Status int32 `json:"status"` + ID string `json:"id"` + Base string `json:"base"` + Quote string `json:"quote"` + Leverage float64 `json:"leverage"` + MinBaseAmount convert.StringToFloat64 `json:"min_base_amount"` + MinQuoteAmount convert.StringToFloat64 `json:"min_quote_amount"` + MaxQuoteAmount convert.StringToFloat64 `json:"max_quote_amount"` + Status int32 `json:"status"` } // OrderbookOfLendingLoan represents order book of lending loans type OrderbookOfLendingLoan struct { - Rate float64 `json:"rate,string"` - Amount float64 `json:"amount,string"` - Days int64 `json:"days"` + Rate convert.StringToFloat64 `json:"rate"` + Amount convert.StringToFloat64 `json:"amount"` + Days int64 `json:"days"` } // FuturesContract represents futures contract detailed data. type FuturesContract struct { - Name string `json:"name"` - Type string `json:"type"` - QuantoMultiplier float64 `json:"quanto_multiplier,string"` - RefDiscountRate float64 `json:"ref_discount_rate,string"` - OrderPriceDeviate string `json:"order_price_deviate"` - MaintenanceRate float64 `json:"maintenance_rate,string"` - MarkType string `json:"mark_type"` - LastPrice float64 `json:"last_price,string"` - MarkPrice float64 `json:"mark_price,string"` - IndexPrice float64 `json:"index_price,string"` - FundingRateIndicative string `json:"funding_rate_indicative"` - MarkPriceRound string `json:"mark_price_round"` - FundingOffset int64 `json:"funding_offset"` - InDelisting bool `json:"in_delisting"` - RiskLimitBase string `json:"risk_limit_base"` - InterestRate string `json:"interest_rate"` - OrderPriceRound string `json:"order_price_round"` - OrderSizeMin int64 `json:"order_size_min"` - RefRebateRate string `json:"ref_rebate_rate"` - FundingInterval int64 `json:"funding_interval"` - RiskLimitStep string `json:"risk_limit_step"` - LeverageMin string `json:"leverage_min"` - LeverageMax string `json:"leverage_max"` - RiskLimitMax string `json:"risk_limit_max"` - MakerFeeRate float64 `json:"maker_fee_rate,string"` - TakerFeeRate float64 `json:"taker_fee_rate,string"` - FundingRate float64 `json:"funding_rate,string"` - OrderSizeMax int64 `json:"order_size_max"` - FundingNextApply gateioTime `json:"funding_next_apply"` - ConfigChangeTime gateioTime `json:"config_change_time"` - ShortUsers int64 `json:"short_users"` - TradeSize int64 `json:"trade_size"` - PositionSize int64 `json:"position_size"` - LongUsers int64 `json:"long_users"` - FundingImpactValue string `json:"funding_impact_value"` - OrdersLimit int64 `json:"orders_limit"` - TradeID int64 `json:"trade_id"` - OrderbookID int64 `json:"orderbook_id"` + Name string `json:"name"` + Type string `json:"type"` + QuantoMultiplier convert.StringToFloat64 `json:"quanto_multiplier"` + RefDiscountRate convert.StringToFloat64 `json:"ref_discount_rate"` + OrderPriceDeviate string `json:"order_price_deviate"` + MaintenanceRate convert.StringToFloat64 `json:"maintenance_rate"` + MarkType string `json:"mark_type"` + LastPrice convert.StringToFloat64 `json:"last_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + IndexPrice convert.StringToFloat64 `json:"index_price"` + FundingRateIndicative string `json:"funding_rate_indicative"` + MarkPriceRound string `json:"mark_price_round"` + FundingOffset int64 `json:"funding_offset"` + InDelisting bool `json:"in_delisting"` + RiskLimitBase string `json:"risk_limit_base"` + InterestRate string `json:"interest_rate"` + OrderPriceRound string `json:"order_price_round"` + OrderSizeMin int64 `json:"order_size_min"` + RefRebateRate string `json:"ref_rebate_rate"` + FundingInterval int64 `json:"funding_interval"` + RiskLimitStep string `json:"risk_limit_step"` + LeverageMin string `json:"leverage_min"` + LeverageMax string `json:"leverage_max"` + RiskLimitMax string `json:"risk_limit_max"` + MakerFeeRate convert.StringToFloat64 `json:"maker_fee_rate"` + TakerFeeRate convert.StringToFloat64 `json:"taker_fee_rate"` + FundingRate convert.StringToFloat64 `json:"funding_rate"` + OrderSizeMax int64 `json:"order_size_max"` + FundingNextApply gateioTime `json:"funding_next_apply"` + ConfigChangeTime gateioTime `json:"config_change_time"` + ShortUsers int64 `json:"short_users"` + TradeSize int64 `json:"trade_size"` + PositionSize int64 `json:"position_size"` + LongUsers int64 `json:"long_users"` + FundingImpactValue string `json:"funding_impact_value"` + OrdersLimit int64 `json:"orders_limit"` + TradeID int64 `json:"trade_id"` + OrderbookID int64 `json:"orderbook_id"` } // TradingHistoryItem represents futures trading history item. type TradingHistoryItem struct { - ID int64 `json:"id"` - CreateTime gateioTime `json:"create_time"` - Contract string `json:"contract"` - Text string `json:"text"` - Size float64 `json:"size"` - Price float64 `json:"price,string"` + ID int64 `json:"id"` + CreateTime gateioTime `json:"create_time"` + Contract string `json:"contract"` + Text string `json:"text"` + Size float64 `json:"size"` + Price convert.StringToFloat64 `json:"price"` // Added for Derived market trade history datas. - Fee float64 `json:"fee,string"` - PointFee float64 `json:"point_fee,string"` - Role string `json:"role"` + Fee convert.StringToFloat64 `json:"fee"` + PointFee convert.StringToFloat64 `json:"point_fee"` + Role string `json:"role"` } // FuturesCandlestick represents futures candlestick data type FuturesCandlestick struct { - Timestamp gateioTime `json:"t"` - Volume float64 `json:"v"` - ClosePrice float64 `json:"c,string"` - HighestPrice float64 `json:"h,string"` - LowestPrice float64 `json:"l,string"` - OpenPrice float64 `json:"o,string"` + Timestamp gateioTime `json:"t"` + Volume float64 `json:"v"` + ClosePrice convert.StringToFloat64 `json:"c"` + HighestPrice convert.StringToFloat64 `json:"h"` + LowestPrice convert.StringToFloat64 `json:"l"` + OpenPrice convert.StringToFloat64 `json:"o"` // Added for websocket push data Name string `json:"n,omitempty"` @@ -714,31 +715,31 @@ type FuturesCandlestick struct { // FuturesPremiumIndexKLineResponse represents premium index K-Line information. type FuturesPremiumIndexKLineResponse struct { - UnixTimestamp gateioTime `json:"t"` - ClosePrice float64 `json:"c,string"` - HighestPrice float64 `json:"h,string"` - LowestPrice float64 `json:"l,string"` - OpenPrice float64 `json:"o,string"` + UnixTimestamp gateioTime `json:"t"` + ClosePrice convert.StringToFloat64 `json:"c"` + HighestPrice convert.StringToFloat64 `json:"h"` + LowestPrice convert.StringToFloat64 `json:"l"` + OpenPrice convert.StringToFloat64 `json:"o"` } // FuturesTicker represents futures ticker data. type FuturesTicker struct { - Contract string `json:"contract"` - ChangePercentage string `json:"change_percentage"` - Last float64 `json:"last,string"` - Low24H float64 `json:"low_24h,string"` - High24H float64 `json:"high_24h,string"` - TotalSize float64 `json:"total_size,string"` - Volume24H float64 `json:"volume_24h,string"` - Volume24HBtc float64 `json:"volume_24h_btc,string"` - Volume24HUsd float64 `json:"volume_24h_usd,string"` - Volume24HBase float64 `json:"volume_24h_base,string"` - Volume24HQuote float64 `json:"volume_24h_quote,string"` - Volume24HSettle float64 `json:"volume_24h_settle,string"` - MarkPrice float64 `json:"mark_price,string"` - FundingRate float64 `json:"funding_rate,string"` - FundingRateIndicative string `json:"funding_rate_indicative"` - IndexPrice float64 `json:"index_price,string"` + Contract string `json:"contract"` + ChangePercentage string `json:"change_percentage"` + Last convert.StringToFloat64 `json:"last"` + Low24H convert.StringToFloat64 `json:"low_24h"` + High24H convert.StringToFloat64 `json:"high_24h"` + TotalSize convert.StringToFloat64 `json:"total_size"` + Volume24H convert.StringToFloat64 `json:"volume_24h"` + Volume24HBtc convert.StringToFloat64 `json:"volume_24h_btc"` + Volume24HUsd convert.StringToFloat64 `json:"volume_24h_usd"` + Volume24HBase convert.StringToFloat64 `json:"volume_24h_base"` + Volume24HQuote convert.StringToFloat64 `json:"volume_24h_quote"` + Volume24HSettle convert.StringToFloat64 `json:"volume_24h_settle"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + FundingRate convert.StringToFloat64 `json:"funding_rate"` + FundingRateIndicative string `json:"funding_rate_indicative"` + IndexPrice convert.StringToFloat64 `json:"index_price"` } // FuturesFundingRate represents futures funding rate response. @@ -782,159 +783,159 @@ type IndexConstituent struct { // LiquidationHistory represents liquidation history for a specifies settle. type LiquidationHistory struct { - Time gateioTime `json:"time"` - Contract string `json:"contract"` - Size int64 `json:"size"` - Leverage string `json:"leverage"` - Margin string `json:"margin"` - EntryPrice float64 `json:"entry_price,string"` - LiquidationPrice gateioNumericalValue `json:"liq_price"` - MarkPrice float64 `json:"mark_price,string"` - OrderID int64 `json:"order_id"` - OrderPrice float64 `json:"order_price,string"` - FillPrice float64 `json:"fill_price,string"` - Left int64 `json:"left"` + Time gateioTime `json:"time"` + Contract string `json:"contract"` + Size int64 `json:"size"` + Leverage string `json:"leverage"` + Margin string `json:"margin"` + EntryPrice convert.StringToFloat64 `json:"entry_price"` + LiquidationPrice gateioNumericalValue `json:"liq_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + OrderID int64 `json:"order_id"` + OrderPrice convert.StringToFloat64 `json:"order_price"` + FillPrice convert.StringToFloat64 `json:"fill_price"` + Left int64 `json:"left"` } // DeliveryContract represents a delivery contract instance detail. type DeliveryContract struct { - Name string `json:"name"` - Underlying string `json:"underlying"` - Cycle string `json:"cycle"` - Type string `json:"type"` - QuantoMultiplier string `json:"quanto_multiplier"` - MarkType string `json:"mark_type"` - LastPrice float64 `json:"last_price,string"` - MarkPrice float64 `json:"mark_price,string"` - IndexPrice float64 `json:"index_price,string"` - BasisRate string `json:"basis_rate"` - BasisValue string `json:"basis_value"` - BasisImpactValue string `json:"basis_impact_value"` - SettlePrice float64 `json:"settle_price,string"` - SettlePriceInterval int64 `json:"settle_price_interval"` - SettlePriceDuration int64 `json:"settle_price_duration"` - SettleFeeRate string `json:"settle_fee_rate"` - OrderPriceRound string `json:"order_price_round"` - MarkPriceRound string `json:"mark_price_round"` - LeverageMin string `json:"leverage_min"` - LeverageMax string `json:"leverage_max"` - MaintenanceRate string `json:"maintenance_rate"` - RiskLimitBase string `json:"risk_limit_base"` - RiskLimitStep string `json:"risk_limit_step"` - RiskLimitMax string `json:"risk_limit_max"` - MakerFeeRate string `json:"maker_fee_rate"` - TakerFeeRate string `json:"taker_fee_rate"` - RefDiscountRate string `json:"ref_discount_rate"` - RefRebateRate string `json:"ref_rebate_rate"` - OrderPriceDeviate string `json:"order_price_deviate"` - OrderSizeMin int64 `json:"order_size_min"` - OrderSizeMax int64 `json:"order_size_max"` - OrdersLimit int64 `json:"orders_limit"` - OrderbookID int64 `json:"orderbook_id"` - TradeID int64 `json:"trade_id"` - TradeSize int64 `json:"trade_size"` - PositionSize int64 `json:"position_size"` - ExpireTime gateioTime `json:"expire_time"` - ConfigChangeTime gateioTime `json:"config_change_time"` - InDelisting bool `json:"in_delisting"` + Name string `json:"name"` + Underlying string `json:"underlying"` + Cycle string `json:"cycle"` + Type string `json:"type"` + QuantoMultiplier string `json:"quanto_multiplier"` + MarkType string `json:"mark_type"` + LastPrice convert.StringToFloat64 `json:"last_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + IndexPrice convert.StringToFloat64 `json:"index_price"` + BasisRate string `json:"basis_rate"` + BasisValue string `json:"basis_value"` + BasisImpactValue string `json:"basis_impact_value"` + SettlePrice convert.StringToFloat64 `json:"settle_price"` + SettlePriceInterval int64 `json:"settle_price_interval"` + SettlePriceDuration int64 `json:"settle_price_duration"` + SettleFeeRate string `json:"settle_fee_rate"` + OrderPriceRound string `json:"order_price_round"` + MarkPriceRound string `json:"mark_price_round"` + LeverageMin string `json:"leverage_min"` + LeverageMax string `json:"leverage_max"` + MaintenanceRate string `json:"maintenance_rate"` + RiskLimitBase string `json:"risk_limit_base"` + RiskLimitStep string `json:"risk_limit_step"` + RiskLimitMax string `json:"risk_limit_max"` + MakerFeeRate string `json:"maker_fee_rate"` + TakerFeeRate string `json:"taker_fee_rate"` + RefDiscountRate string `json:"ref_discount_rate"` + RefRebateRate string `json:"ref_rebate_rate"` + OrderPriceDeviate string `json:"order_price_deviate"` + OrderSizeMin int64 `json:"order_size_min"` + OrderSizeMax int64 `json:"order_size_max"` + OrdersLimit int64 `json:"orders_limit"` + OrderbookID int64 `json:"orderbook_id"` + TradeID int64 `json:"trade_id"` + TradeSize int64 `json:"trade_size"` + PositionSize int64 `json:"position_size"` + ExpireTime gateioTime `json:"expire_time"` + ConfigChangeTime gateioTime `json:"config_change_time"` + InDelisting bool `json:"in_delisting"` } // DeliveryTradingHistory represents futures trading history type DeliveryTradingHistory struct { - ID int64 `json:"id"` - CreateTime gateioTime `json:"create_time"` - Contract string `json:"contract"` - Size float64 `json:"size"` - Price float64 `json:"price,string"` + ID int64 `json:"id"` + CreateTime gateioTime `json:"create_time"` + Contract string `json:"contract"` + Size float64 `json:"size"` + Price convert.StringToFloat64 `json:"price"` } // OptionUnderlying represents option underlying and it's index price. type OptionUnderlying struct { - Name string `json:"name"` - IndexPrice float64 `json:"index_price,string"` - IndexTime gateioTime `json:"index_time"` + Name string `json:"name"` + IndexPrice convert.StringToFloat64 `json:"index_price"` + IndexTime gateioTime `json:"index_time"` } // OptionContract represents an option contract detail. type OptionContract struct { - Name string `json:"name"` - Tag string `json:"tag"` - IsCall bool `json:"is_call"` - StrikePrice float64 `json:"strike_price,string"` - LastPrice float64 `json:"last_price,string"` - MarkPrice float64 `json:"mark_price,string"` - OrderbookID int64 `json:"orderbook_id"` - TradeID int64 `json:"trade_id"` - TradeSize int64 `json:"trade_size"` - PositionSize int64 `json:"position_size"` - Underlying string `json:"underlying"` - UnderlyingPrice float64 `json:"underlying_price,string"` - Multiplier string `json:"multiplier"` - OrderPriceRound string `json:"order_price_round"` - MarkPriceRound string `json:"mark_price_round"` - MakerFeeRate string `json:"maker_fee_rate"` - TakerFeeRate string `json:"taker_fee_rate"` - PriceLimitFeeRate string `json:"price_limit_fee_rate"` - RefDiscountRate string `json:"ref_discount_rate"` - RefRebateRate string `json:"ref_rebate_rate"` - OrderPriceDeviate string `json:"order_price_deviate"` - OrderSizeMin int64 `json:"order_size_min"` - OrderSizeMax int64 `json:"order_size_max"` - OrdersLimit int64 `json:"orders_limit"` - CreateTime gateioTime `json:"create_time"` - ExpirationTime gateioTime `json:"expiration_time"` + Name string `json:"name"` + Tag string `json:"tag"` + IsCall bool `json:"is_call"` + StrikePrice convert.StringToFloat64 `json:"strike_price"` + LastPrice convert.StringToFloat64 `json:"last_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + OrderbookID int64 `json:"orderbook_id"` + TradeID int64 `json:"trade_id"` + TradeSize int64 `json:"trade_size"` + PositionSize int64 `json:"position_size"` + Underlying string `json:"underlying"` + UnderlyingPrice convert.StringToFloat64 `json:"underlying_price"` + Multiplier string `json:"multiplier"` + OrderPriceRound string `json:"order_price_round"` + MarkPriceRound string `json:"mark_price_round"` + MakerFeeRate string `json:"maker_fee_rate"` + TakerFeeRate string `json:"taker_fee_rate"` + PriceLimitFeeRate string `json:"price_limit_fee_rate"` + RefDiscountRate string `json:"ref_discount_rate"` + RefRebateRate string `json:"ref_rebate_rate"` + OrderPriceDeviate string `json:"order_price_deviate"` + OrderSizeMin int64 `json:"order_size_min"` + OrderSizeMax int64 `json:"order_size_max"` + OrdersLimit int64 `json:"orders_limit"` + CreateTime gateioTime `json:"create_time"` + ExpirationTime gateioTime `json:"expiration_time"` } // OptionSettlement list settlement history type OptionSettlement struct { - Timestamp gateioTime `json:"time"` - Profit gateioNumericalValue `json:"profit"` - Fee gateioNumericalValue `json:"fee"` - SettlePrice float64 `json:"settle_price,string"` - Contract string `json:"contract"` - StrikePrice float64 `json:"strike_price,string"` + Timestamp gateioTime `json:"time"` + Profit gateioNumericalValue `json:"profit"` + Fee gateioNumericalValue `json:"fee"` + SettlePrice convert.StringToFloat64 `json:"settle_price"` + Contract string `json:"contract"` + StrikePrice convert.StringToFloat64 `json:"strike_price"` } // SwapCurrencies represents Flash Swap supported currencies type SwapCurrencies struct { - Currency string `json:"currency"` - MinAmount float64 `json:"min_amount,string"` - MaxAmount float64 `json:"max_amount,string"` - Swappable []string `json:"swappable"` + Currency string `json:"currency"` + MinAmount convert.StringToFloat64 `json:"min_amount"` + MaxAmount convert.StringToFloat64 `json:"max_amount"` + Swappable []string `json:"swappable"` } // MyOptionSettlement represents option private settlement type MyOptionSettlement struct { - Size float64 `json:"size"` - SettleProfit float64 `json:"settle_profit,string"` - Contract string `json:"contract"` - StrikePrice float64 `json:"strike_price,string"` - Time gateioTime `json:"time"` - SettlePrice float64 `json:"settle_price,string"` - Underlying string `json:"underlying"` - RealisedPnl string `json:"realised_pnl"` - Fee float64 `json:"fee,string"` + Size float64 `json:"size"` + SettleProfit convert.StringToFloat64 `json:"settle_profit"` + Contract string `json:"contract"` + StrikePrice convert.StringToFloat64 `json:"strike_price"` + Time gateioTime `json:"time"` + SettlePrice convert.StringToFloat64 `json:"settle_price"` + Underlying string `json:"underlying"` + RealisedPnl string `json:"realised_pnl"` + Fee convert.StringToFloat64 `json:"fee"` } // OptionsTicker represents tickers of options contracts type OptionsTicker struct { - Name currency.Pair `json:"name"` - LastPrice gateioNumericalValue `json:"last_price"` - MarkPrice gateioNumericalValue `json:"mark_price"` - PositionSize float64 `json:"position_size"` - Ask1Size float64 `json:"ask1_size"` - Ask1Price float64 `json:"ask1_price,string"` - Bid1Size float64 `json:"bid1_size"` - Bid1Price float64 `json:"bid1_price,string"` - Vega string `json:"vega"` - Theta string `json:"theta"` - Rho string `json:"rho"` - Gamma string `json:"gamma"` - Delta string `json:"delta"` - MarkImpliedVolatility gateioNumericalValue `json:"mark_iv"` - BidImpliedVolatility gateioNumericalValue `json:"bid_iv"` - AskImpliedVolatility gateioNumericalValue `json:"ask_iv"` - Leverage gateioNumericalValue `json:"leverage"` + Name currency.Pair `json:"name"` + LastPrice gateioNumericalValue `json:"last_price"` + MarkPrice gateioNumericalValue `json:"mark_price"` + PositionSize float64 `json:"position_size"` + Ask1Size float64 `json:"ask1_size"` + Ask1Price convert.StringToFloat64 `json:"ask1_price"` + Bid1Size float64 `json:"bid1_size"` + Bid1Price convert.StringToFloat64 `json:"bid1_price"` + Vega string `json:"vega"` + Theta string `json:"theta"` + Rho string `json:"rho"` + Gamma string `json:"gamma"` + Delta string `json:"delta"` + MarkImpliedVolatility gateioNumericalValue `json:"mark_iv"` + BidImpliedVolatility gateioNumericalValue `json:"bid_iv"` + AskImpliedVolatility gateioNumericalValue `json:"ask_iv"` + Leverage gateioNumericalValue `json:"leverage"` // Added fields for the websocket IndexPrice gateioNumericalValue `json:"index_price"` @@ -942,69 +943,69 @@ type OptionsTicker struct { // OptionsUnderlyingTicker represents underlying ticker type OptionsUnderlyingTicker struct { - TradePut float64 `json:"trade_put"` - TradeCall float64 `json:"trade_call"` - IndexPrice float64 `json:"index_price,string"` + TradePut float64 `json:"trade_put"` + TradeCall float64 `json:"trade_call"` + IndexPrice convert.StringToFloat64 `json:"index_price"` } // OptionAccount represents option account. type OptionAccount struct { - User int64 `json:"user"` - Currency string `json:"currency"` - ShortEnabled bool `json:"short_enabled"` - Total float64 `json:"total,string"` - UnrealisedPnl string `json:"unrealised_pnl"` - InitMargin string `json:"init_margin"` - MaintMargin string `json:"maint_margin"` - OrderMargin string `json:"order_margin"` - Available float64 `json:"available,string"` - Point string `json:"point"` + User int64 `json:"user"` + Currency string `json:"currency"` + ShortEnabled bool `json:"short_enabled"` + Total convert.StringToFloat64 `json:"total"` + UnrealisedPnl string `json:"unrealised_pnl"` + InitMargin string `json:"init_margin"` + MaintMargin string `json:"maint_margin"` + OrderMargin string `json:"order_margin"` + Available convert.StringToFloat64 `json:"available"` + Point string `json:"point"` } // AccountBook represents account changing history item type AccountBook struct { - ChangeTime gateioTime `json:"time"` - AccountChange float64 `json:"change,string"` - Balance float64 `json:"balance,string"` - CustomText string `json:"text"` - ChangingType string `json:"type"` + ChangeTime gateioTime `json:"time"` + AccountChange convert.StringToFloat64 `json:"change"` + Balance convert.StringToFloat64 `json:"balance"` + CustomText string `json:"text"` + ChangingType string `json:"type"` } // UsersPositionForUnderlying represents user's position for specified underlying. type UsersPositionForUnderlying struct { - User int64 `json:"user"` - Contract string `json:"contract"` - Size int64 `json:"size"` - EntryPrice float64 `json:"entry_price,string"` - RealisedPnl float64 `json:"realised_pnl,string"` - MarkPrice float64 `json:"mark_price,string"` - UnrealisedPnl float64 `json:"unrealised_pnl,string"` - PendingOrders int64 `json:"pending_orders"` + User int64 `json:"user"` + Contract string `json:"contract"` + Size int64 `json:"size"` + EntryPrice convert.StringToFloat64 `json:"entry_price"` + RealisedPnl convert.StringToFloat64 `json:"realised_pnl"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + UnrealisedPnl convert.StringToFloat64 `json:"unrealised_pnl"` + PendingOrders int64 `json:"pending_orders"` CloseOrder struct { - ID int64 `json:"id"` - Price float64 `json:"price,string"` - IsLiq bool `json:"is_liq"` + ID int64 `json:"id"` + Price convert.StringToFloat64 `json:"price"` + IsLiq bool `json:"is_liq"` } `json:"close_order"` } // ContractClosePosition represents user's liquidation history type ContractClosePosition struct { - PositionCloseTime gateioTime `json:"time"` - Pnl float64 `json:"pnl,string"` - SettleSize string `json:"settle_size"` - Side string `json:"side"` // Position side, long or short - FuturesContract string `json:"contract"` - CloseOrderText string `json:"text"` + PositionCloseTime gateioTime `json:"time"` + Pnl convert.StringToFloat64 `json:"pnl"` + SettleSize string `json:"settle_size"` + Side string `json:"side"` // Position side, long or short + FuturesContract string `json:"contract"` + CloseOrderText string `json:"text"` } // OptionOrderParam represents option order request body type OptionOrderParam struct { - OrderSize float64 `json:"size"` // Order size. Specify positive number to make a bid, and negative number to ask - Iceberg float64 `json:"iceberg,omitempty"` // Display size for iceberg order. 0 for non-iceberg. Note that you will have to pay the taker fee for the hidden size - Contract string `json:"contract"` - Text string `json:"text,omitempty"` - TimeInForce string `json:"tif,omitempty"` - Price float64 `json:"price,string,omitempty"` + OrderSize float64 `json:"size"` // Order size. Specify positive number to make a bid, and negative number to ask + Iceberg float64 `json:"iceberg,omitempty"` // Display size for iceberg order. 0 for non-iceberg. Note that you will have to pay the taker fee for the hidden size + Contract string `json:"contract"` + Text string `json:"text,omitempty"` + TimeInForce string `json:"tif,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` // Close Set as true to close the position, with size set to 0 Close bool `json:"close,omitempty"` ReduceOnly bool `json:"reduce_only,omitempty"` @@ -1012,59 +1013,59 @@ type OptionOrderParam struct { // OptionOrderResponse represents option order response detail type OptionOrderResponse struct { - Status string `json:"status"` - Size float64 `json:"size"` - OptionOrderID int64 `json:"id"` - Iceberg int64 `json:"iceberg"` - IsOrderLiquidation bool `json:"is_liq"` - IsOrderPositionClose bool `json:"is_close"` - Contract string `json:"contract"` - Text string `json:"text"` - FillPrice float64 `json:"fill_price,string"` - FinishAs string `json:"finish_as"` // finish_as filled, cancelled, liquidated, ioc, auto_deleveraged, reduce_only, position_closed, reduce_out - Left float64 `json:"left"` - TimeInForce string `json:"tif"` - IsReduceOnly bool `json:"is_reduce_only"` - CreateTime gateioTime `json:"create_time"` - FinishTime gateioTime `json:"finish_time"` - Price float64 `json:"price,string"` + Status string `json:"status"` + Size float64 `json:"size"` + OptionOrderID int64 `json:"id"` + Iceberg int64 `json:"iceberg"` + IsOrderLiquidation bool `json:"is_liq"` + IsOrderPositionClose bool `json:"is_close"` + Contract string `json:"contract"` + Text string `json:"text"` + FillPrice convert.StringToFloat64 `json:"fill_price"` + FinishAs string `json:"finish_as"` // finish_as filled, cancelled, liquidated, ioc, auto_deleveraged, reduce_only, position_closed, reduce_out + Left float64 `json:"left"` + TimeInForce string `json:"tif"` + IsReduceOnly bool `json:"is_reduce_only"` + CreateTime gateioTime `json:"create_time"` + FinishTime gateioTime `json:"finish_time"` + Price convert.StringToFloat64 `json:"price"` - TakerFee float64 `json:"tkrf,omitempty,string"` - MakerFee float64 `json:"mkrf,omitempty,string"` - ReferenceUserID string `json:"refu"` + TakerFee convert.StringToFloat64 `json:"tkrf"` + MakerFee convert.StringToFloat64 `json:"mkrf"` + ReferenceUserID string `json:"refu"` } // OptionTradingHistory list personal trading history type OptionTradingHistory struct { - ID int64 `json:"id"` - UnderlyingPrice float64 `json:"underlying_price,string"` - Size float64 `json:"size"` - Contract string `json:"contract"` - TradeRole string `json:"role"` - CreateTime gateioTime `json:"create_time"` - OrderID int64 `json:"order_id"` - Price float64 `json:"price,string"` + ID int64 `json:"id"` + UnderlyingPrice convert.StringToFloat64 `json:"underlying_price"` + Size float64 `json:"size"` + Contract string `json:"contract"` + TradeRole string `json:"role"` + CreateTime gateioTime `json:"create_time"` + OrderID int64 `json:"order_id"` + Price convert.StringToFloat64 `json:"price"` } // WithdrawalResponse represents withdrawal response type WithdrawalResponse struct { - ID string `json:"id"` - Timestamp gateioTime `json:"timestamp"` - Currency string `json:"currency"` - WithdrawalAddress string `json:"address"` - TransactionID string `json:"txid"` - Amount float64 `json:"amount,string"` - Memo string `json:"memo"` - Status string `json:"status"` - Chain string `json:"chain"` - Fee float64 `json:"fee,string"` + ID string `json:"id"` + Timestamp gateioTime `json:"timestamp"` + Currency string `json:"currency"` + WithdrawalAddress string `json:"address"` + TransactionID string `json:"txid"` + Amount convert.StringToFloat64 `json:"amount"` + Memo string `json:"memo"` + Status string `json:"status"` + Chain string `json:"chain"` + Fee convert.StringToFloat64 `json:"fee"` } // WithdrawalRequestParam represents currency withdrawal request param. type WithdrawalRequestParam struct { - Currency currency.Code `json:"currency"` - Amount float64 `json:"amount,string"` - Chain string `json:"chain,omitempty"` + Currency currency.Code `json:"currency"` + Amount convert.StringToFloat64 `json:"amount"` + Chain string `json:"chain,omitempty"` // Optional parameters Address string `json:"address,omitempty"` @@ -1089,26 +1090,26 @@ type MultiChainAddressItem struct { // DepositRecord represents deposit record item type DepositRecord struct { - ID string `json:"id"` - Timestamp gateioTime `json:"timestamp"` - Currency string `json:"currency"` - Address string `json:"address"` - TransactionID string `json:"txid"` - Amount float64 `json:"amount,string"` - Memo string `json:"memo"` - Status string `json:"status"` - Chain string `json:"chain"` - Fee float64 `json:"fee,string"` + ID string `json:"id"` + Timestamp gateioTime `json:"timestamp"` + Currency string `json:"currency"` + Address string `json:"address"` + TransactionID string `json:"txid"` + Amount convert.StringToFloat64 `json:"amount"` + Memo string `json:"memo"` + Status string `json:"status"` + Chain string `json:"chain"` + Fee convert.StringToFloat64 `json:"fee"` } // TransferCurrencyParam represents currency transfer. type TransferCurrencyParam struct { - Currency currency.Code `json:"currency"` - From string `json:"from"` - To string `json:"to"` - Amount float64 `json:"amount,string"` - CurrencyPair currency.Pair `json:"currency_pair"` - Settle string `json:"settle"` + Currency currency.Code `json:"currency"` + From string `json:"from"` + To string `json:"to"` + Amount convert.StringToFloat64 `json:"amount"` + CurrencyPair currency.Pair `json:"currency_pair"` + Settle string `json:"settle"` } // TransactionIDResponse represents transaction ID @@ -1118,68 +1119,68 @@ type TransactionIDResponse struct { // SubAccountTransferParam represents currency subaccount transfer request param type SubAccountTransferParam struct { - Currency currency.Code `json:"currency"` - SubAccount string `json:"sub_account"` - Direction string `json:"direction"` - Amount float64 `json:"amount,string"` - SubAccountType string `json:"sub_account_type"` + Currency currency.Code `json:"currency"` + SubAccount string `json:"sub_account"` + Direction string `json:"direction"` + Amount convert.StringToFloat64 `json:"amount"` + SubAccountType string `json:"sub_account_type"` } // SubAccountTransferResponse represents transfer records between main and sub accounts type SubAccountTransferResponse struct { - MainAccountUserID string `json:"uid"` - Timestamp gateioTime `json:"timest"` - Source string `json:"source"` - Currency string `json:"currency"` - SubAccount string `json:"sub_account"` - TransferDirection string `json:"direction"` - Amount float64 `json:"amount,string"` - SubAccountType string `json:"sub_account_type"` + MainAccountUserID string `json:"uid"` + Timestamp gateioTime `json:"timest"` + Source string `json:"source"` + Currency string `json:"currency"` + SubAccount string `json:"sub_account"` + TransferDirection string `json:"direction"` + Amount convert.StringToFloat64 `json:"amount"` + SubAccountType string `json:"sub_account_type"` } // WithdrawalStatus represents currency withdrawal status type WithdrawalStatus struct { - Currency string `json:"currency"` - CurrencyName string `json:"name"` - CurrencyNameChinese string `json:"name_cn"` - Deposit float64 `json:"deposit,string"` - WithdrawPercent string `json:"withdraw_percent"` - FixedWithdrawalFee float64 `json:"withdraw_fix,string"` - WithdrawDayLimit float64 `json:"withdraw_day_limit,string"` - WithdrawDayLimitRemain float64 `json:"withdraw_day_limit_remain,string"` - WithdrawAmountMini float64 `json:"withdraw_amount_mini,string"` - WithdrawEachTimeLimit float64 `json:"withdraw_eachtime_limit,string"` - WithdrawFixOnChains map[string]string `json:"withdraw_fix_on_chains"` - AdditionalProperties string `json:"additionalProperties"` + Currency string `json:"currency"` + CurrencyName string `json:"name"` + CurrencyNameChinese string `json:"name_cn"` + Deposit convert.StringToFloat64 `json:"deposit"` + WithdrawPercent string `json:"withdraw_percent"` + FixedWithdrawalFee convert.StringToFloat64 `json:"withdraw_fix"` + WithdrawDayLimit convert.StringToFloat64 `json:"withdraw_day_limit"` + WithdrawDayLimitRemain convert.StringToFloat64 `json:"withdraw_day_limit_remain"` + WithdrawAmountMini convert.StringToFloat64 `json:"withdraw_amount_mini"` + WithdrawEachTimeLimit convert.StringToFloat64 `json:"withdraw_eachtime_limit"` + WithdrawFixOnChains map[string]string `json:"withdraw_fix_on_chains"` + AdditionalProperties string `json:"additionalProperties"` } // FuturesSubAccountBalance represents sub account balance for specific sub account and several currencies type FuturesSubAccountBalance struct { UserID int64 `json:"uid,string"` Available struct { - Total float64 `json:"total,string"` - UnrealisedProfitAndLoss string `json:"unrealised_pnl"` - PositionMargin string `json:"position_margin"` - OrderMargin string `json:"order_margin"` - TotalAvailable float64 `json:"available,string"` - PointAmount float64 `json:"point"` - SettleCurrency string `json:"currency"` - InDualMode bool `json:"in_dual_mode"` - EnableCredit bool `json:"enable_credit"` - PositionInitialMargin string `json:"position_initial_margin"` // applicable to the portfolio margin account model - MaintenanceMarginPosition string `json:"maintenance_margin"` - PerpetualContractBonus string `json:"bonus"` + Total convert.StringToFloat64 `json:"total"` + UnrealisedProfitAndLoss string `json:"unrealised_pnl"` + PositionMargin string `json:"position_margin"` + OrderMargin string `json:"order_margin"` + TotalAvailable convert.StringToFloat64 `json:"available"` + PointAmount float64 `json:"point"` + SettleCurrency string `json:"currency"` + InDualMode bool `json:"in_dual_mode"` + EnableCredit bool `json:"enable_credit"` + PositionInitialMargin string `json:"position_initial_margin"` // applicable to the portfolio margin account model + MaintenanceMarginPosition string `json:"maintenance_margin"` + PerpetualContractBonus string `json:"bonus"` StatisticalData struct { - TotalDNW float64 `json:"dnw,string"` // total amount of deposit and withdraw - ProfitAndLoss float64 `json:"pnl,string"` // total amount of trading profit and loss - TotalAmountOfFee float64 `json:"fee,string"` - ReferrerRebates float64 `json:"refr,string"` // total amount of referrer rebates - Fund float64 `json:"fund,string"` // total amount of funding costs - PointDNW float64 `json:"point_dnw,string"` - PoointFee float64 `json:"point_fee,string"` - PointRefr float64 `json:"point_refr,string"` - BonusDNW float64 `json:"bonus_dnw,string"` - BonusOffset float64 `json:"bonus_offset,string"` + TotalDNW convert.StringToFloat64 `json:"dnw"` // total amount of deposit and withdraw + ProfitAndLoss convert.StringToFloat64 `json:"pnl"` // total amount of trading profit and loss + TotalAmountOfFee convert.StringToFloat64 `json:"fee"` + ReferrerRebates convert.StringToFloat64 `json:"refr"` // total amount of referrer rebates + Fund convert.StringToFloat64 `json:"fund"` // total amount of funding costs + PointDNW convert.StringToFloat64 `json:"point_dnw"` + PoointFee convert.StringToFloat64 `json:"point_fee"` + PointRefr convert.StringToFloat64 `json:"point_refr"` + BonusDNW convert.StringToFloat64 `json:"bonus_dnw"` + BonusOffset convert.StringToFloat64 `json:"bonus_offset"` } `json:"history"` } `json:"available"` } @@ -1198,11 +1199,11 @@ type SubAccountMarginBalance struct { // MarginCurrencyBalance represents a currency balance detail information. type MarginCurrencyBalance struct { - Currency string `json:"currency"` - Available float64 `json:"available,string"` - Locked float64 `json:"locked,string"` - BorrowedAmount float64 `json:"borrowed,string"` - UnpairInterest float64 `json:"interest,string"` + Currency string `json:"currency"` + Available convert.StringToFloat64 `json:"available"` + Locked convert.StringToFloat64 `json:"locked"` + BorrowedAmount convert.StringToFloat64 `json:"borrowed"` + UnpairInterest convert.StringToFloat64 `json:"interest"` } // MarginAccountItem margin account item @@ -1216,11 +1217,11 @@ type MarginAccountItem struct { // AccountBalanceInformation represents currency account balace information. type AccountBalanceInformation struct { - Available float64 `json:"available,string"` - Borrowed float64 `json:"borrowed,string"` - Interest float64 `json:"interest,string"` - Currency string `json:"currency"` - LockedAmount float64 `json:"locked,string"` + Available convert.StringToFloat64 `json:"available"` + Borrowed convert.StringToFloat64 `json:"borrowed"` + Interest convert.StringToFloat64 `json:"interest"` + Currency string `json:"currency"` + LockedAmount convert.StringToFloat64 `json:"locked"` } // MarginAccountBalanceChangeInfo represents margin account balance @@ -1236,47 +1237,47 @@ type MarginAccountBalanceChangeInfo struct { // MarginFundingAccountItem represents funding account list item. type MarginFundingAccountItem struct { - Currency string `json:"currency"` - Available float64 `json:"available,string"` - LockedAmount float64 `json:"locked,string"` - Lent string `json:"lent"` // Outstanding loan amount yet to be repaid - TotalLent string `json:"total_lent"` // Amount used for lending. total_lent = lent + locked + Currency string `json:"currency"` + Available convert.StringToFloat64 `json:"available"` + LockedAmount convert.StringToFloat64 `json:"locked"` + Lent string `json:"lent"` // Outstanding loan amount yet to be repaid + TotalLent string `json:"total_lent"` // Amount used for lending. total_lent = lent + locked } // MarginLoanRequestParam represents margin lend or borrow request param type MarginLoanRequestParam struct { - Side string `json:"side"` - Currency currency.Code `json:"currency"` - Rate float64 `json:"rate,string,omitempty"` - Amount float64 `json:"amount,string"` - Days int64 `json:"days,omitempty"` - AutoRenew bool `json:"auto_renew,omitempty"` - CurrencyPair currency.Pair `json:"currency_pair,omitempty"` - FeeRate float64 `json:"fee_rate,string,omitempty"` - OrigID string `json:"orig_id,omitempty"` - Text string `json:"text,omitempty"` + Side string `json:"side"` + Currency currency.Code `json:"currency"` + Rate convert.StringToFloat64 `json:"rate,omitempty"` + Amount convert.StringToFloat64 `json:"amount,omitempty"` + Days int64 `json:"days,omitempty"` + AutoRenew bool `json:"auto_renew,omitempty"` + CurrencyPair currency.Pair `json:"currency_pair,omitempty"` + FeeRate convert.StringToFloat64 `json:"fee_rate,omitempty"` + OrigID string `json:"orig_id,omitempty"` + Text string `json:"text,omitempty"` } // MarginLoanResponse represents lending or borrow response. type MarginLoanResponse struct { - ID string `json:"id"` - OrigID string `json:"orig_id,omitempty"` - Side string `json:"side"` - Currency string `json:"currency"` - Amount float64 `json:"amount,string"` - Rate float64 `json:"rate,string"` - Days int64 `json:"days,omitempty"` - AutoRenew bool `json:"auto_renew,omitempty"` - CurrencyPair string `json:"currency_pair,omitempty"` - FeeRate float64 `json:"fee_rate,string"` - Text string `json:"text,omitempty"` - CreateTime gateioTime `json:"create_time"` - ExpireTime gateioTime `json:"expire_time"` - Status string `json:"status"` - Left float64 `json:"left,string"` - Repaid float64 `json:"repaid,string"` - PaidInterest float64 `json:"paid_interest,string"` - UnpaidInterest float64 `json:"unpaid_interest,string"` + ID string `json:"id"` + OrigID string `json:"orig_id,omitempty"` + Side string `json:"side"` + Currency string `json:"currency"` + Amount convert.StringToFloat64 `json:"amount"` + Rate convert.StringToFloat64 `json:"rate"` + Days int64 `json:"days,omitempty"` + AutoRenew bool `json:"auto_renew,omitempty"` + CurrencyPair string `json:"currency_pair,omitempty"` + FeeRate convert.StringToFloat64 `json:"fee_rate"` + Text string `json:"text,omitempty"` + CreateTime gateioTime `json:"create_time"` + ExpireTime gateioTime `json:"expire_time"` + Status string `json:"status"` + Left convert.StringToFloat64 `json:"left"` + Repaid convert.StringToFloat64 `json:"repaid"` + PaidInterest convert.StringToFloat64 `json:"paid_interest"` + UnpaidInterest convert.StringToFloat64 `json:"unpaid_interest"` } // SubAccountCrossMarginInfo represents subaccount's cross_margin account info @@ -1285,34 +1286,34 @@ type SubAccountCrossMarginInfo struct { Available struct { UserID int64 `json:"user_id"` Locked bool `json:"locked"` - Total float64 `json:"total,string"` - Borrowed float64 `json:"borrowed,string"` - Interest float64 `json:"interest,string"` // Total unpaid interests in USDT, i.e., the sum of all currencies' interest*price*discount + Total convert.StringToFloat64 `json:"total"` + Borrowed convert.StringToFloat64 `json:"borrowed"` + Interest convert.StringToFloat64 `json:"interest"` // Total unpaid interests in USDT, i.e., the sum of all currencies' interest*price*discount BorrowedNet string `json:"borrowed_net"` - TotalNetAssets float64 `json:"net,string"` - Leverage float64 `json:"leverage,string"` + TotalNetAssets convert.StringToFloat64 `json:"net"` + Leverage convert.StringToFloat64 `json:"leverage"` Risk string `json:"risk"` - TotalInitialMargin float64 `json:"total_initial_margin,string"` - TotalMarginBalance float64 `json:"total_margin_balance,string"` - TotalMaintenanceMargin float64 `json:"total_maintenance_margin,string"` - TotalInitialMarginRate float64 `json:"total_initial_margin_rate,string"` - TotalMaintenanceMarginRate float64 `json:"total_maintenance_margin_rate,string"` - TotalAvailableMargin float64 `json:"total_available_margin,string"` + TotalInitialMargin convert.StringToFloat64 `json:"total_initial_margin"` + TotalMarginBalance convert.StringToFloat64 `json:"total_margin_balance"` + TotalMaintenanceMargin convert.StringToFloat64 `json:"total_maintenance_margin"` + TotalInitialMarginRate convert.StringToFloat64 `json:"total_initial_margin_rate"` + TotalMaintenanceMarginRate convert.StringToFloat64 `json:"total_maintenance_margin_rate"` + TotalAvailableMargin convert.StringToFloat64 `json:"total_available_margin"` CurrencyBalances map[string]CrossMarginBalance `json:"balances"` } `json:"available"` } // CrossMarginBalance represents cross-margin currency balance detail type CrossMarginBalance struct { - Available float64 `json:"available,string"` - Freeze float64 `json:"freeze,string"` - Borrowed float64 `json:"borrowed,string"` - Interest float64 `json:"interest,string"` - Total string `json:"total"` - BorrowedNet string `json:"borrowed_net"` - TotalNetAssetInUSDT string `json:"net"` - PositionLeverage string `json:"leverage"` - Risk string `json:"risk"` // Risk rate. When it belows 110%, liquidation will be triggered. Calculation formula: total / (borrowed+interest) + Available convert.StringToFloat64 `json:"available"` + Freeze convert.StringToFloat64 `json:"freeze"` + Borrowed convert.StringToFloat64 `json:"borrowed"` + Interest convert.StringToFloat64 `json:"interest"` + Total string `json:"total"` + BorrowedNet string `json:"borrowed_net"` + TotalNetAssetInUSDT string `json:"net"` + PositionLeverage string `json:"leverage"` + Risk string `json:"risk"` // Risk rate. When it belows 110%, liquidation will be triggered. Calculation formula: total / (borrowed+interest) } // WalletSavedAddress represents currency saved address @@ -1327,16 +1328,16 @@ type WalletSavedAddress struct { // PersonalTradingFee represents personal trading fee for specific currency pair type PersonalTradingFee struct { - UserID int64 `json:"user_id"` - TakerFee float64 `json:"taker_fee,string"` - MakerFee float64 `json:"maker_fee,string"` - GtDiscount bool `json:"gt_discount"` - GtTakerFee float64 `json:"gt_taker_fee,string"` - GtMakerFee float64 `json:"gt_maker_fee,string"` - LoanFee float64 `json:"loan_fee,string"` - PointType string `json:"point_type"` - FuturesTakerFee float64 `json:"futures_taker_fee,string"` - FuturesMakerFee float64 `json:"futures_maker_fee,string"` + UserID int64 `json:"user_id"` + TakerFee convert.StringToFloat64 `json:"taker_fee"` + MakerFee convert.StringToFloat64 `json:"maker_fee"` + GtDiscount bool `json:"gt_discount"` + GtTakerFee convert.StringToFloat64 `json:"gt_taker_fee"` + GtMakerFee convert.StringToFloat64 `json:"gt_maker_fee"` + LoanFee convert.StringToFloat64 `json:"loan_fee"` + PointType string `json:"point_type"` + FuturesTakerFee convert.StringToFloat64 `json:"futures_taker_fee"` + FuturesMakerFee convert.StringToFloat64 `json:"futures_maker_fee"` } // UsersAllAccountBalance represents user all account balances. @@ -1353,74 +1354,74 @@ type CurrencyBalanceAmount struct { // SpotTradingFeeRate user trading fee rates type SpotTradingFeeRate struct { - UserID int64 `json:"user_id"` - TakerFee float64 `json:"taker_fee,string"` - MakerFee float64 `json:"maker_fee,string"` - GtDiscount bool `json:"gt_discount"` - GtTakerFee float64 `json:"gt_taker_fee,string"` - GtMakerFee float64 `json:"gt_maker_fee,string"` - FuturesTakerFee float64 `json:"futures_taker_fee,string"` - FuturesMakerFee float64 `json:"futures_maker_fee,string"` - LoanFee float64 `json:"loan_fee,string"` - PointType string `json:"point_type"` + UserID int64 `json:"user_id"` + TakerFee convert.StringToFloat64 `json:"taker_fee"` + MakerFee convert.StringToFloat64 `json:"maker_fee"` + GtDiscount bool `json:"gt_discount"` + GtTakerFee convert.StringToFloat64 `json:"gt_taker_fee"` + GtMakerFee convert.StringToFloat64 `json:"gt_maker_fee"` + FuturesTakerFee convert.StringToFloat64 `json:"futures_taker_fee"` + FuturesMakerFee convert.StringToFloat64 `json:"futures_maker_fee"` + LoanFee convert.StringToFloat64 `json:"loan_fee"` + PointType string `json:"point_type"` } // SpotAccount represents spot account type SpotAccount struct { - Currency string `json:"currency"` - Available float64 `json:"available,string"` - Locked float64 `json:"locked,string"` + Currency string `json:"currency"` + Available convert.StringToFloat64 `json:"available"` + Locked convert.StringToFloat64 `json:"locked"` } // CreateOrderRequestData represents a single order creation param. type CreateOrderRequestData struct { - Text string `json:"text,omitempty"` - CurrencyPair currency.Pair `json:"currency_pair,omitempty"` - Type string `json:"type,omitempty"` - Account string `json:"account,omitempty"` - Side string `json:"side,omitempty"` - Iceberg string `json:"iceberg,omitempty"` - Amount float64 `json:"amount,string,omitempty"` - Price float64 `json:"price,string,omitempty"` - TimeInForce string `json:"time_in_force,omitempty"` - AutoBorrow bool `json:"auto_borrow,omitempty"` + Text string `json:"text,omitempty"` + CurrencyPair currency.Pair `json:"currency_pair,omitempty"` + Type string `json:"type,omitempty"` + Account string `json:"account,omitempty"` + Side string `json:"side,omitempty"` + Iceberg string `json:"iceberg,omitempty"` + Amount convert.StringToFloat64 `json:"amount,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` + TimeInForce string `json:"time_in_force,omitempty"` + AutoBorrow bool `json:"auto_borrow,omitempty"` } // SpotOrder represents create order response. type SpotOrder struct { - OrderID string `json:"id,omitempty"` - Text string `json:"text,omitempty"` - Succeeded bool `json:"succeeded"` - ErrorLabel string `json:"label,omitempty"` - Message string `json:"message,omitempty"` - CreateTime gateioTime `json:"create_time,omitempty"` - CreateTimeMs gateioTime `json:"create_time_ms,omitempty"` - UpdateTime gateioTime `json:"update_time,omitempty"` - UpdateTimeMs gateioTime `json:"update_time_ms,omitempty"` - CurrencyPair string `json:"currency_pair,omitempty"` - Status string `json:"status,omitempty"` - Type string `json:"type,omitempty"` - Account string `json:"account,omitempty"` - Side string `json:"side,omitempty"` - Amount float64 `json:"amount,omitempty,string"` - Price float64 `json:"price,omitempty,string"` - TimeInForce string `json:"time_in_force,omitempty"` - Iceberg string `json:"iceberg,omitempty"` - AutoRepay bool `json:"auto_repay"` - AutoBorrow bool `json:"auto_borrow"` - Left gateioNumericalValue `json:"left"` - AverageFillPrice float64 `json:"avg_deal_price,string"` - FeeDeducted float64 `json:"fee,string"` - FeeCurrency string `json:"fee_currency"` - FillPrice float64 `json:"fill_price,string"` // Total filled in quote currency. Deprecated in favor of filled_total - FilledTotal float64 `json:"filled_total,string"` // Total filled in quote currency - PointFee float64 `json:"point_fee,string"` - GtFee string `json:"gt_fee,omitempty"` - GtDiscount bool `json:"gt_discount"` - GtMakerFee float64 `json:"gt_maker_fee,string"` - GtTakerFee float64 `json:"gt_taker_fee,string"` - RebatedFee float64 `json:"rebated_fee,string"` - RebatedFeeCurrency string `json:"rebated_fee_currency"` + OrderID string `json:"id,omitempty"` + Text string `json:"text,omitempty"` + Succeeded bool `json:"succeeded"` + ErrorLabel string `json:"label,omitempty"` + Message string `json:"message,omitempty"` + CreateTime gateioTime `json:"create_time,omitempty"` + CreateTimeMs gateioTime `json:"create_time_ms,omitempty"` + UpdateTime gateioTime `json:"update_time,omitempty"` + UpdateTimeMs gateioTime `json:"update_time_ms,omitempty"` + CurrencyPair string `json:"currency_pair,omitempty"` + Status string `json:"status,omitempty"` + Type string `json:"type,omitempty"` + Account string `json:"account,omitempty"` + Side string `json:"side,omitempty"` + Amount convert.StringToFloat64 `json:"amount,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` + TimeInForce string `json:"time_in_force,omitempty"` + Iceberg string `json:"iceberg,omitempty"` + AutoRepay bool `json:"auto_repay"` + AutoBorrow bool `json:"auto_borrow"` + Left gateioNumericalValue `json:"left"` + AverageFillPrice convert.StringToFloat64 `json:"avg_deal_price"` + FeeDeducted convert.StringToFloat64 `json:"fee"` + FeeCurrency string `json:"fee_currency"` + FillPrice convert.StringToFloat64 `json:"fill_price"` // Total filled in quote currency. Deprecated in favor of filled_total + FilledTotal convert.StringToFloat64 `json:"filled_total"` // Total filled in quote currency + PointFee convert.StringToFloat64 `json:"point_fee"` + GtFee string `json:"gt_fee,omitempty"` + GtDiscount bool `json:"gt_discount"` + GtMakerFee convert.StringToFloat64 `json:"gt_maker_fee"` + GtTakerFee convert.StringToFloat64 `json:"gt_taker_fee"` + RebatedFee convert.StringToFloat64 `json:"rebated_fee"` + RebatedFeeCurrency string `json:"rebated_fee_currency"` } // SpotOrdersDetail represents list of orders for specific currency pair @@ -1432,10 +1433,10 @@ type SpotOrdersDetail struct { // ClosePositionRequestParam represents close position when cross currency is disable. type ClosePositionRequestParam struct { - Text string `json:"text"` - CurrencyPair currency.Pair `json:"currency_pair"` - Amount float64 `json:"amount,string"` - Price float64 `json:"price,string"` + Text string `json:"text"` + CurrencyPair currency.Pair `json:"currency_pair"` + Amount convert.StringToFloat64 `json:"amount"` + Price convert.StringToFloat64 `json:"price"` } // CancelOrderByIDParam represents cancel order by id request param. @@ -1456,19 +1457,19 @@ type CancelOrderByIDResponse struct { // SpotPersonalTradeHistory represents personal trading history. type SpotPersonalTradeHistory struct { - TradeID string `json:"id"` - CreateTime gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - CurrencyPair string `json:"currency_pair"` - OrderID string `json:"order_id"` - Side string `json:"side"` - Role string `json:"role"` - Amount float64 `json:"amount,string"` - Price float64 `json:"price,string"` - Fee float64 `json:"fee,string"` - FeeCurrency string `json:"fee_currency"` - PointFee string `json:"point_fee"` - GtFee string `json:"gt_fee"` + TradeID string `json:"id"` + CreateTime gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + CurrencyPair string `json:"currency_pair"` + OrderID string `json:"order_id"` + Side string `json:"side"` + Role string `json:"role"` + Amount convert.StringToFloat64 `json:"amount"` + Price convert.StringToFloat64 `json:"price"` + Fee convert.StringToFloat64 `json:"fee"` + FeeCurrency string `json:"fee_currency"` + PointFee string `json:"point_fee"` + GtFee string `json:"gt_fee"` } // CountdownCancelOrderParam represents countdown cancel order params @@ -1491,19 +1492,19 @@ type PriceTriggeredOrderParam struct { // TriggerPriceInfo represents a trigger price and related information for Price triggered order type TriggerPriceInfo struct { - Price float64 `json:"price,string"` - Rule string `json:"rule"` - Expiration int64 `json:"expiration"` + Price convert.StringToFloat64 `json:"price"` + Rule string `json:"rule"` + Expiration int64 `json:"expiration"` } // PutOrderData represents order detail for price triggered order request type PutOrderData struct { - Type string `json:"type"` - Side string `json:"side"` - Price float64 `json:"price,string"` - Amount float64 `json:"amount,string"` - Account string `json:"account"` - TimeInForce string `json:"time_in_force,omitempty"` + Type string `json:"type"` + Side string `json:"side"` + Price convert.StringToFloat64 `json:"price"` + Amount convert.StringToFloat64 `json:"amount"` + Account string `json:"account"` + TimeInForce string `json:"time_in_force,omitempty"` } // OrderID represents order creation ID response. @@ -1536,10 +1537,10 @@ type ModifyLoanRequestParam struct { // RepayLoanRequestParam represents loan repay request parameters type RepayLoanRequestParam struct { - CurrencyPair currency.Pair `json:"currency_pair"` - Currency currency.Code `json:"currency"` - Mode string `json:"mode"` - Amount float64 `json:"amount,string"` + CurrencyPair currency.Pair `json:"currency_pair"` + Currency currency.Code `json:"currency"` + Mode string `json:"mode"` + Amount convert.StringToFloat64 `json:"amount"` } // LoanRepaymentRecord represents loan repayment history record item. @@ -1552,20 +1553,20 @@ type LoanRepaymentRecord struct { // LoanRecord represents loan repayment specific record type LoanRecord struct { - ID string `json:"id"` - LoanID string `json:"loan_id"` - CreateTime gateioTime `json:"create_time"` - ExpireTime gateioTime `json:"expire_time"` - Status string `json:"status"` - BorrowUserID string `json:"borrow_user_id"` - Currency string `json:"currency"` - Rate float64 `json:"rate,string"` - Amount float64 `json:"amount,string"` - Days int64 `json:"days"` - AutoRenew bool `json:"auto_renew"` - Repaid float64 `json:"repaid,string"` - PaidInterest float64 `json:"paid_interest,string"` - UnpaidInterest float64 `json:"unpaid_interest,string"` + ID string `json:"id"` + LoanID string `json:"loan_id"` + CreateTime gateioTime `json:"create_time"` + ExpireTime gateioTime `json:"expire_time"` + Status string `json:"status"` + BorrowUserID string `json:"borrow_user_id"` + Currency string `json:"currency"` + Rate convert.StringToFloat64 `json:"rate"` + Amount convert.StringToFloat64 `json:"amount"` + Days int64 `json:"days"` + AutoRenew bool `json:"auto_renew"` + Repaid convert.StringToFloat64 `json:"repaid"` + PaidInterest convert.StringToFloat64 `json:"paid_interest"` + UnpaidInterest convert.StringToFloat64 `json:"unpaid_interest"` } // OnOffStatus represents on or off status response status @@ -1575,30 +1576,30 @@ type OnOffStatus struct { // MaxTransferAndLoanAmount represents the maximum amount to transfer, borrow, or lend for specific currency and currency pair type MaxTransferAndLoanAmount struct { - Currency string `json:"currency"` - CurrencyPair string `json:"currency_pair"` - Amount float64 `json:"amount,string"` + Currency string `json:"currency"` + CurrencyPair string `json:"currency_pair"` + Amount convert.StringToFloat64 `json:"amount"` } // CrossMarginCurrencies represents a currency supported by cross margin type CrossMarginCurrencies struct { - Name string `json:"name"` - Rate float64 `json:"rate,string"` - CurrencyPrecision float64 `json:"prec,string"` - Discount string `json:"discount"` - MinBorrowAmount float64 `json:"min_borrow_amount,string"` - UserMaxBorrowAmount float64 `json:"user_max_borrow_amount,string"` - TotalMaxBorrowAmount float64 `json:"total_max_borrow_amount,string"` - Price float64 `json:"price,string"` // Price change between this currency and USDT - Status int64 `json:"status"` + Name string `json:"name"` + Rate convert.StringToFloat64 `json:"rate"` + CurrencyPrecision convert.StringToFloat64 `json:"prec"` + Discount string `json:"discount"` + MinBorrowAmount convert.StringToFloat64 `json:"min_borrow_amount"` + UserMaxBorrowAmount convert.StringToFloat64 `json:"user_max_borrow_amount"` + TotalMaxBorrowAmount convert.StringToFloat64 `json:"total_max_borrow_amount"` + Price convert.StringToFloat64 `json:"price"` // Price change between this currency and USDT + Status int64 `json:"status"` } // CrossMarginCurrencyBalance represents the currency detailed balance information for cross margin type CrossMarginCurrencyBalance struct { - Available float64 `json:"available,string"` - Freeze float64 `json:"freeze,string"` - Borrowed float64 `json:"borrowed,string"` - Interest float64 `json:"interest,string"` + Available convert.StringToFloat64 `json:"available"` + Freeze convert.StringToFloat64 `json:"freeze"` + Borrowed convert.StringToFloat64 `json:"borrowed"` + Interest convert.StringToFloat64 `json:"interest"` } // CrossMarginAccount represents the account detail for cross margin account balance @@ -1606,160 +1607,160 @@ type CrossMarginAccount struct { UserID int64 `json:"user_id"` Locked bool `json:"locked"` Balances map[string]CrossMarginCurrencyBalance `json:"balances"` - Total float64 `json:"total,string"` - Borrowed float64 `json:"borrowed,string"` - Interest float64 `json:"interest,string"` - Risk float64 `json:"risk,string"` + Total convert.StringToFloat64 `json:"total"` + Borrowed convert.StringToFloat64 `json:"borrowed"` + Interest convert.StringToFloat64 `json:"interest"` + Risk convert.StringToFloat64 `json:"risk"` TotalInitialMargin string `json:"total_initial_margin"` - TotalMarginBalance float64 `json:"total_margin_balance,string"` - TotalMaintenanceMargin float64 `json:"total_maintenance_margin,string"` - TotalInitialMarginRate float64 `json:"total_initial_margin_rate,string"` - TotalMaintenanceMarginRate float64 `json:"total_maintenance_margin_rate,string"` - TotalAvailableMargin float64 `json:"total_available_margin,string"` - TotalPortfolioMarginAccount float64 `json:"portfolio_margin_total,string"` + TotalMarginBalance convert.StringToFloat64 `json:"total_margin_balance"` + TotalMaintenanceMargin convert.StringToFloat64 `json:"total_maintenance_margin"` + TotalInitialMarginRate convert.StringToFloat64 `json:"total_initial_margin_rate"` + TotalMaintenanceMarginRate convert.StringToFloat64 `json:"total_maintenance_margin_rate"` + TotalAvailableMargin convert.StringToFloat64 `json:"total_available_margin"` + TotalPortfolioMarginAccount convert.StringToFloat64 `json:"portfolio_margin_total"` } // CrossMarginAccountHistoryItem represents a cross margin account change history item type CrossMarginAccountHistoryItem struct { - ID string `json:"id"` - Time gateioTime `json:"time"` - Currency string `json:"currency"` // Currency changed - Change string `json:"change"` - Balance float64 `json:"balance,string"` - Type string `json:"type"` + ID string `json:"id"` + Time gateioTime `json:"time"` + Currency string `json:"currency"` // Currency changed + Change string `json:"change"` + Balance convert.StringToFloat64 `json:"balance"` + Type string `json:"type"` } // CrossMarginBorrowLoanParams represents a cross margin borrow loan parameters type CrossMarginBorrowLoanParams struct { - Currency currency.Code `json:"currency"` - Amount float64 `json:"amount,string"` - Text string `json:"text"` + Currency currency.Code `json:"currency"` + Amount convert.StringToFloat64 `json:"amount"` + Text string `json:"text"` } // CrossMarginLoanResponse represents a cross margin borrow loan response type CrossMarginLoanResponse struct { - ID string `json:"id"` - CreateTime gateioTime `json:"create_time"` - UpdateTime gateioTime `json:"update_time"` - Currency string `json:"currency"` - Amount float64 `json:"amount,string"` - Text string `json:"text"` - Status int64 `json:"status"` - Repaid string `json:"repaid"` - RepaidInterest float64 `json:"repaid_interest,string"` - UnpaidInterest float64 `json:"unpaid_interest,string"` + ID string `json:"id"` + CreateTime gateioTime `json:"create_time"` + UpdateTime gateioTime `json:"update_time"` + Currency string `json:"currency"` + Amount convert.StringToFloat64 `json:"amount"` + Text string `json:"text"` + Status int64 `json:"status"` + Repaid string `json:"repaid"` + RepaidInterest convert.StringToFloat64 `json:"repaid_interest"` + UnpaidInterest convert.StringToFloat64 `json:"unpaid_interest"` } // CurrencyAndAmount represents request parameters for repayment type CurrencyAndAmount struct { - Currency currency.Code `json:"currency"` - Amount float64 `json:"amount,string"` + Currency currency.Code `json:"currency"` + Amount convert.StringToFloat64 `json:"amount"` } // RepaymentHistoryItem represents an item in a repayment history. type RepaymentHistoryItem struct { - ID string `json:"id"` - CreateTime gateioTime `json:"create_time"` - LoanID string `json:"loan_id"` - Currency string `json:"currency"` - Principal float32 `json:"principal,string"` - Interest float32 `json:"interest,string"` + ID string `json:"id"` + CreateTime gateioTime `json:"create_time"` + LoanID string `json:"loan_id"` + Currency string `json:"currency"` + Principal convert.StringToFloat64 `json:"principal"` + Interest convert.StringToFloat64 `json:"interest"` } // FlashSwapOrderParams represents create flash swap order request parameters. type FlashSwapOrderParams struct { - PreviewID string `json:"preview_id"` - SellCurrency currency.Code `json:"sell_currency"` - SellAmount float64 `json:"sell_amount,string,omitempty"` - BuyCurrency currency.Code `json:"buy_currency"` - BuyAmount float64 `json:"buy_amount,string,omitempty"` + PreviewID string `json:"preview_id"` + SellCurrency currency.Code `json:"sell_currency"` + SellAmount convert.StringToFloat64 `json:"sell_amount,omitempty"` + BuyCurrency currency.Code `json:"buy_currency"` + BuyAmount convert.StringToFloat64 `json:"buy_amount,omitempty"` } // FlashSwapOrderResponse represents create flash swap order response type FlashSwapOrderResponse struct { - ID int64 `json:"id"` - CreateTime gateioTime `json:"create_time"` - UpdateTime gateioTime `json:"update_time"` - UserID int64 `json:"user_id"` - SellCurrency string `json:"sell_currency"` - SellAmount float64 `json:"sell_amount,string"` - BuyCurrency string `json:"buy_currency"` - BuyAmount float64 `json:"buy_amount,string"` - Price float64 `json:"price,string"` - Status int64 `json:"status"` + ID int64 `json:"id"` + CreateTime gateioTime `json:"create_time"` + UpdateTime gateioTime `json:"update_time"` + UserID int64 `json:"user_id"` + SellCurrency string `json:"sell_currency"` + SellAmount convert.StringToFloat64 `json:"sell_amount"` + BuyCurrency string `json:"buy_currency"` + BuyAmount convert.StringToFloat64 `json:"buy_amount"` + Price convert.StringToFloat64 `json:"price"` + Status int64 `json:"status"` } // InitFlashSwapOrderPreviewResponse represents the order preview for flash order type InitFlashSwapOrderPreviewResponse struct { - PreviewID string `json:"preview_id"` - SellCurrency string `json:"sell_currency"` - SellAmount float64 `json:"sell_amount,string"` - BuyCurrency string `json:"buy_currency"` - BuyAmount float64 `json:"buy_amount,string"` - Price float64 `json:"price,string"` + PreviewID string `json:"preview_id"` + SellCurrency string `json:"sell_currency"` + SellAmount convert.StringToFloat64 `json:"sell_amount"` + BuyCurrency string `json:"buy_currency"` + BuyAmount convert.StringToFloat64 `json:"buy_amount"` + Price convert.StringToFloat64 `json:"price"` } // FuturesAccount represents futures account detail type FuturesAccount struct { - User int64 `json:"user"` - Currency string `json:"currency"` - Total float64 `json:"total,string"` // total = position_margin + order_margin + available - UnrealisedPnl string `json:"unrealised_pnl"` - PositionMargin string `json:"position_margin"` - OrderMargin string `json:"order_margin"` // Order margin of unfinished orders - Available float64 `json:"available,string"` // The available balance for transferring or trading - Point string `json:"point"` - Bonus string `json:"bonus"` - InDualMode bool `json:"in_dual_mode"` // Whether dual mode is enabled + User int64 `json:"user"` + Currency string `json:"currency"` + Total convert.StringToFloat64 `json:"total"` // total = position_margin + order_margin + available + UnrealisedPnl string `json:"unrealised_pnl"` + PositionMargin string `json:"position_margin"` + OrderMargin string `json:"order_margin"` // Order margin of unfinished orders + Available convert.StringToFloat64 `json:"available"` // The available balance for transferring or trading + Point string `json:"point"` + Bonus string `json:"bonus"` + InDualMode bool `json:"in_dual_mode"` // Whether dual mode is enabled History struct { - DepositAndWithdrawal string `json:"dnw"` // total amount of deposit and withdraw - ProfitAndLoss float64 `json:"pnl,string"` // total amount of trading profit and loss - Fee string `json:"fee"` // total amount of fee - Refr string `json:"refr"` // total amount of referrer rebates - Fund string `json:"fund"` - PointDnw string `json:"point_dnw"` // total amount of point deposit and withdraw - PointFee string `json:"point_fee"` // total amount of point fee - PointRefr string `json:"point_refr"` - BonusDnw string `json:"bonus_dnw"` // total amount of perpetual contract bonus transfer - BonusOffset string `json:"bonus_offset"` // total amount of perpetual contract bonus deduction + DepositAndWithdrawal string `json:"dnw"` // total amount of deposit and withdraw + ProfitAndLoss convert.StringToFloat64 `json:"pnl"` // total amount of trading profit and loss + Fee string `json:"fee"` // total amount of fee + Refr string `json:"refr"` // total amount of referrer rebates + Fund string `json:"fund"` + PointDnw string `json:"point_dnw"` // total amount of point deposit and withdraw + PointFee string `json:"point_fee"` // total amount of point fee + PointRefr string `json:"point_refr"` + BonusDnw string `json:"bonus_dnw"` // total amount of perpetual contract bonus transfer + BonusOffset string `json:"bonus_offset"` // total amount of perpetual contract bonus deduction } `json:"history"` } // AccountBookItem represents account book item type AccountBookItem struct { - Time gateioTime `json:"time"` - Change float64 `json:"change,string"` - Balance float64 `json:"balance,string"` - Text string `json:"text"` - Type string `json:"type"` + Time gateioTime `json:"time"` + Change convert.StringToFloat64 `json:"change"` + Balance convert.StringToFloat64 `json:"balance"` + Text string `json:"text"` + Type string `json:"type"` } // Position represents futures position type Position struct { - User int64 `json:"user"` - Contract string `json:"contract"` - Size int64 `json:"size"` - Leverage float64 `json:"leverage,string"` - RiskLimit float64 `json:"risk_limit,string"` - LeverageMax string `json:"leverage_max"` - MaintenanceRate float64 `json:"maintenance_rate,string"` - Value float64 `json:"value,string"` - Margin float64 `json:"margin,string"` - EntryPrice float64 `json:"entry_price,string"` - LiqPrice float64 `json:"liq_price,string"` - MarkPrice float64 `json:"mark_price,string"` - UnrealisedPnl string `json:"unrealised_pnl"` - RealisedPnl string `json:"realised_pnl"` - HistoryPnl string `json:"history_pnl"` - LastClosePnl string `json:"last_close_pnl"` - RealisedPoint string `json:"realised_point"` - HistoryPoint string `json:"history_point"` - AdlRanking int64 `json:"adl_ranking"` - PendingOrders int64 `json:"pending_orders"` + User int64 `json:"user"` + Contract string `json:"contract"` + Size int64 `json:"size"` + Leverage convert.StringToFloat64 `json:"leverage"` + RiskLimit convert.StringToFloat64 `json:"risk_limit"` + LeverageMax string `json:"leverage_max"` + MaintenanceRate convert.StringToFloat64 `json:"maintenance_rate"` + Value convert.StringToFloat64 `json:"value"` + Margin convert.StringToFloat64 `json:"margin"` + EntryPrice convert.StringToFloat64 `json:"entry_price"` + LiqPrice convert.StringToFloat64 `json:"liq_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + UnrealisedPnl string `json:"unrealised_pnl"` + RealisedPnl string `json:"realised_pnl"` + HistoryPnl string `json:"history_pnl"` + LastClosePnl string `json:"last_close_pnl"` + RealisedPoint string `json:"realised_point"` + HistoryPoint string `json:"history_point"` + AdlRanking int64 `json:"adl_ranking"` + PendingOrders int64 `json:"pending_orders"` CloseOrder struct { - ID int64 `json:"id"` - Price float64 `json:"price,string"` - IsLiq bool `json:"is_liq"` + ID int64 `json:"id"` + Price convert.StringToFloat64 `json:"price"` + IsLiq bool `json:"is_liq"` } `json:"close_order"` Mode string `json:"mode"` CrossLeverageLimit string `json:"cross_leverage_limit"` @@ -1767,38 +1768,38 @@ type Position struct { // DualModeResponse represents dual mode enable or disable type DualModeResponse struct { - User int64 `json:"user"` - Currency string `json:"currency"` - Total string `json:"total"` - UnrealisedPnl float64 `json:"unrealised_pnl,string"` - PositionMargin float64 `json:"position_margin,string"` - OrderMargin string `json:"order_margin"` - Available string `json:"available"` - Point string `json:"point"` - Bonus string `json:"bonus"` - InDualMode bool `json:"in_dual_mode"` + User int64 `json:"user"` + Currency string `json:"currency"` + Total string `json:"total"` + UnrealisedPnl convert.StringToFloat64 `json:"unrealised_pnl"` + PositionMargin convert.StringToFloat64 `json:"position_margin"` + OrderMargin string `json:"order_margin"` + Available string `json:"available"` + Point string `json:"point"` + Bonus string `json:"bonus"` + InDualMode bool `json:"in_dual_mode"` History struct { - DepositAndWithdrawal float64 `json:"dnw,string"` // total amount of deposit and withdraw - ProfitAndLoss float64 `json:"pnl,string"` // total amount of trading profit and loss - Fee float64 `json:"fee,string"` - Refr float64 `json:"refr,string"` - Fund float64 `json:"fund,string"` - PointDnw float64 `json:"point_dnw,string"` - PointFee float64 `json:"point_fee,string"` - PointRefr float64 `json:"point_refr,string"` - BonusDnw float64 `json:"bonus_dnw,string"` - BonusOffset float64 `json:"bonus_offset,string"` + DepositAndWithdrawal convert.StringToFloat64 `json:"dnw"` // total amount of deposit and withdraw + ProfitAndLoss convert.StringToFloat64 `json:"pnl"` // total amount of trading profit and loss + Fee convert.StringToFloat64 `json:"fee"` + Refr convert.StringToFloat64 `json:"refr"` + Fund convert.StringToFloat64 `json:"fund"` + PointDnw convert.StringToFloat64 `json:"point_dnw"` + PointFee convert.StringToFloat64 `json:"point_fee"` + PointRefr convert.StringToFloat64 `json:"point_refr"` + BonusDnw convert.StringToFloat64 `json:"bonus_dnw"` + BonusOffset convert.StringToFloat64 `json:"bonus_offset"` } `json:"history"` } // OrderCreateParams represents future order creation parameters type OrderCreateParams struct { - Contract currency.Pair `json:"contract"` - Size float64 `json:"size"` - Iceberg int64 `json:"iceberg"` - Price float64 `json:"price,string"` - TimeInForce string `json:"tif"` - Text string `json:"text"` + Contract currency.Pair `json:"contract"` + Size float64 `json:"size"` + Iceberg int64 `json:"iceberg"` + Price convert.StringToFloat64 `json:"price"` + TimeInForce string `json:"tif"` + Text string `json:"text"` // Optional Parameters ClosePosition bool `json:"close,omitempty"` @@ -1809,57 +1810,57 @@ type OrderCreateParams struct { // Order represents future order response type Order struct { - ID int64 `json:"id"` - User int64 `json:"user"` - Contract string `json:"contract"` - CreateTime gateioTime `json:"create_time"` - Size float64 `json:"size"` - Iceberg int64 `json:"iceberg"` - RemainingAmount float64 `json:"left"` // Size left to be traded - OrderPrice float64 `json:"price,string"` - FillPrice float64 `json:"fill_price,string"` // Fill price of the order. total filled in quote currency. - MakerFee string `json:"mkfr"` - TakerFee string `json:"tkfr"` - TimeInForce string `json:"tif"` - ReferenceUserID int64 `json:"refu"` - IsReduceOnly bool `json:"is_reduce_only"` - IsClose bool `json:"is_close"` - IsOrderForLiquidation bool `json:"is_liq"` - Text string `json:"text"` - Status string `json:"status"` - FinishTime gateioTime `json:"finish_time"` - FinishAs string `json:"finish_as"` + ID int64 `json:"id"` + User int64 `json:"user"` + Contract string `json:"contract"` + CreateTime gateioTime `json:"create_time"` + Size float64 `json:"size"` + Iceberg int64 `json:"iceberg"` + RemainingAmount float64 `json:"left"` // Size left to be traded + OrderPrice convert.StringToFloat64 `json:"price"` + FillPrice convert.StringToFloat64 `json:"fill_price"` // Fill price of the order. total filled in quote currency. + MakerFee string `json:"mkfr"` + TakerFee string `json:"tkfr"` + TimeInForce string `json:"tif"` + ReferenceUserID int64 `json:"refu"` + IsReduceOnly bool `json:"is_reduce_only"` + IsClose bool `json:"is_close"` + IsOrderForLiquidation bool `json:"is_liq"` + Text string `json:"text"` + Status string `json:"status"` + FinishTime gateioTime `json:"finish_time"` + FinishAs string `json:"finish_as"` } // AmendFuturesOrderParam represents amend futures order parameter type AmendFuturesOrderParam struct { - Size float64 `json:"size,string"` - Price float64 `json:"price,string"` + Size convert.StringToFloat64 `json:"size"` + Price convert.StringToFloat64 `json:"price"` } // PositionCloseHistoryResponse represents a close position history detail type PositionCloseHistoryResponse struct { - Time gateioTime `json:"time"` - ProfitAndLoss float64 `json:"pnl,string"` - Side string `json:"side"` - Contract string `json:"contract"` - Text string `json:"text"` + Time gateioTime `json:"time"` + ProfitAndLoss convert.StringToFloat64 `json:"pnl"` + Side string `json:"side"` + Contract string `json:"contract"` + Text string `json:"text"` } // LiquidationHistoryItem liquidation history item type LiquidationHistoryItem struct { - Time gateioTime `json:"time"` - Contract string `json:"contract"` - Size int64 `json:"size"` - Leverage float64 `json:"leverage,string"` - Margin string `json:"margin"` - EntryPrice float64 `json:"entry_price,string"` - MarkPrice float64 `json:"mark_price,string"` - OrderPrice float64 `json:"order_price,string"` - FillPrice float64 `json:"fill_price,string"` - LiqPrice float64 `json:"liq_price,string"` - OrderID int64 `json:"order_id"` - Left int64 `json:"left"` + Time gateioTime `json:"time"` + Contract string `json:"contract"` + Size int64 `json:"size"` + Leverage convert.StringToFloat64 `json:"leverage"` + Margin string `json:"margin"` + EntryPrice convert.StringToFloat64 `json:"entry_price"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + OrderPrice convert.StringToFloat64 `json:"order_price"` + FillPrice convert.StringToFloat64 `json:"fill_price"` + LiqPrice convert.StringToFloat64 `json:"liq_price"` + OrderID int64 `json:"order_id"` + Left int64 `json:"left"` } // CountdownParams represents query parameters for countdown cancel order @@ -1877,39 +1878,39 @@ type FuturesPriceTriggeredOrderParam struct { // FuturesInitial represents a price triggered order initial parameters type FuturesInitial struct { - Contract currency.Pair `json:"contract"` - Size int64 `json:"size"` // Order size. Positive size means to buy, while negative one means to sell. Set to 0 to close the position - Price float64 `json:"price,string"` // Order price. Set to 0 to use market price - Close bool `json:"close,omitempty"` - TimeInForce string `json:"tif,omitempty"` - Text string `json:"text,omitempty"` - ReduceOnly bool `json:"reduce_only,omitempty"` - AutoSize string `json:"auto_size,omitempty"` + Contract currency.Pair `json:"contract"` + Size int64 `json:"size"` // Order size. Positive size means to buy, while negative one means to sell. Set to 0 to close the position + Price convert.StringToFloat64 `json:"price"` // Order price. Set to 0 to use market price + Close bool `json:"close,omitempty"` + TimeInForce string `json:"tif,omitempty"` + Text string `json:"text,omitempty"` + ReduceOnly bool `json:"reduce_only,omitempty"` + AutoSize string `json:"auto_size,omitempty"` } // FuturesTrigger represents a price triggered order trigger parameter type FuturesTrigger struct { - StrategyType int64 `json:"strategy_type,omitempty"` // How the order will be triggered 0: by price, which means the order will be triggered if price condition is satisfied 1: by price gap, which means the order will be triggered if gap of recent two prices of specified price_type are satisfied. Only 0 is supported currently - PriceType int64 `json:"price_type,omitempty"` - Price float64 `json:"price,omitempty,string"` - Rule int64 `json:"rule,omitempty"` - Expiration int64 `json:"expiration,omitempty"` // how long(in seconds) to wait for the condition to be triggered before cancelling the order - OrderType string `json:"order_type,omitempty"` + StrategyType int64 `json:"strategy_type,omitempty"` // How the order will be triggered 0: by price, which means the order will be triggered if price condition is satisfied 1: by price gap, which means the order will be triggered if gap of recent two prices of specified price_type are satisfied. Only 0 is supported currently + PriceType int64 `json:"price_type,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` + Rule int64 `json:"rule,omitempty"` + Expiration int64 `json:"expiration,omitempty"` // how long(in seconds) to wait for the condition to be triggered before cancelling the order + OrderType string `json:"order_type,omitempty"` } // PriceTriggeredOrder represents a future triggered price order response type PriceTriggeredOrder struct { Initial struct { - Contract string `json:"contract"` - Size float64 `json:"size"` - Price float64 `json:"price,string"` + Contract string `json:"contract"` + Size float64 `json:"size"` + Price convert.StringToFloat64 `json:"price"` } `json:"initial"` Trigger struct { - StrategyType int64 `json:"strategy_type"` - PriceType int64 `json:"price_type"` - Price float64 `json:"price,string"` - Rule int64 `json:"rule"` - Expiration int64 `json:"expiration"` + StrategyType int64 `json:"strategy_type"` + PriceType int64 `json:"price_type"` + Price convert.StringToFloat64 `json:"price"` + Rule int64 `json:"rule"` + Expiration int64 `json:"expiration"` } `json:"trigger"` ID int64 `json:"id"` User int64 `json:"user"` @@ -1924,15 +1925,15 @@ type PriceTriggeredOrder struct { // SettlementHistoryItem represents a settlement history item type SettlementHistoryItem struct { - Time gateioTime `json:"time"` - Contract string `json:"contract"` - Size int64 `json:"size"` - Leverage string `json:"leverage"` - Margin string `json:"margin"` - EntryPrice float64 `json:"entry_price,string"` - SettlePrice float64 `json:"settle_price,string"` - Profit float64 `json:"profit,string"` - Fee float64 `json:"fee,string"` + Time gateioTime `json:"time"` + Contract string `json:"contract"` + Size int64 `json:"size"` + Leverage string `json:"leverage"` + Margin string `json:"margin"` + EntryPrice convert.StringToFloat64 `json:"entry_price"` + SettlePrice convert.StringToFloat64 `json:"settle_price"` + Profit convert.StringToFloat64 `json:"profit"` + Fee convert.StringToFloat64 `json:"fee"` } // SubAccountParams represents subaccount creation parameters @@ -1999,48 +2000,48 @@ type WsResponse struct { // WsTicker websocket ticker information. type WsTicker struct { - CurrencyPair currency.Pair `json:"currency_pair"` - Last float64 `json:"last,string"` - LowestAsk float64 `json:"lowest_ask,string"` - HighestBid float64 `json:"highest_bid,string"` - ChangePercentage float64 `json:"change_percentage,string"` - BaseVolume float64 `json:"base_volume,string"` - QuoteVolume float64 `json:"quote_volume,string"` - High24H float64 `json:"high_24h,string"` - Low24H float64 `json:"low_24h,string"` + CurrencyPair currency.Pair `json:"currency_pair"` + Last convert.StringToFloat64 `json:"last"` + LowestAsk convert.StringToFloat64 `json:"lowest_ask"` + HighestBid convert.StringToFloat64 `json:"highest_bid"` + ChangePercentage convert.StringToFloat64 `json:"change_percentage"` + BaseVolume convert.StringToFloat64 `json:"base_volume"` + QuoteVolume convert.StringToFloat64 `json:"quote_volume"` + High24H convert.StringToFloat64 `json:"high_24h"` + Low24H convert.StringToFloat64 `json:"low_24h"` } // WsTrade represents a websocket push data response for a trade type WsTrade struct { - ID int64 `json:"id"` - CreateTime gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - Side string `json:"side"` - CurrencyPair currency.Pair `json:"currency_pair"` - Amount float64 `json:"amount,string"` - Price float64 `json:"price,string"` + ID int64 `json:"id"` + CreateTime gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + Side string `json:"side"` + CurrencyPair currency.Pair `json:"currency_pair"` + Amount convert.StringToFloat64 `json:"amount"` + Price convert.StringToFloat64 `json:"price"` } // WsCandlesticks represents the candlestick data for spot, margin and cross margin trades pushed through the websocket channel. type WsCandlesticks struct { - Timestamp int64 `json:"t,string"` - TotalVolume float64 `json:"v,string"` - ClosePrice float64 `json:"c,string"` - HighestPrice float64 `json:"h,string"` - LowestPrice float64 `json:"l,string"` - OpenPrice float64 `json:"o,string"` - NameOfSubscription string `json:"n"` + Timestamp int64 `json:"t,string"` + TotalVolume convert.StringToFloat64 `json:"v"` + ClosePrice convert.StringToFloat64 `json:"c"` + HighestPrice convert.StringToFloat64 `json:"h"` + LowestPrice convert.StringToFloat64 `json:"l"` + OpenPrice convert.StringToFloat64 `json:"o"` + NameOfSubscription string `json:"n"` } // WsOrderbookTickerData represents the websocket orderbook best bid or best ask push data type WsOrderbookTickerData struct { - UpdateTimeMS int64 `json:"t"` - UpdateOrderID int64 `json:"u"` - CurrencyPair currency.Pair `json:"s"` - BestBidPrice float64 `json:"b,string"` - BestBidAmount float64 `json:"B,string"` - BestAskPrice float64 `json:"a,string"` - BestAskAmount float64 `json:"A,string"` + UpdateTimeMS int64 `json:"t"` + UpdateOrderID int64 `json:"u"` + CurrencyPair currency.Pair `json:"s"` + BestBidPrice convert.StringToFloat64 `json:"b"` + BestBidAmount convert.StringToFloat64 `json:"B"` + BestAskPrice convert.StringToFloat64 `json:"a"` + BestAskAmount convert.StringToFloat64 `json:"A"` } // WsOrderbookUpdate represents websocket orderbook update push data @@ -2066,153 +2067,153 @@ type WsOrderbookSnapshot struct { // WsSpotOrder represents an order push data through the websocket channel. type WsSpotOrder struct { - ID string `json:"id,omitempty"` - User int64 `json:"user"` - Text string `json:"text,omitempty"` - Succeeded bool `json:"succeeded,omitempty"` - Label string `json:"label,omitempty"` - Message string `json:"message,omitempty"` - CurrencyPair currency.Pair `json:"currency_pair,omitempty"` - Type string `json:"type,omitempty"` - Account string `json:"account,omitempty"` - Side string `json:"side,omitempty"` - Amount float64 `json:"amount,omitempty,string"` - Price float64 `json:"price,omitempty,string"` - TimeInForce string `json:"time_in_force,omitempty"` - Iceberg string `json:"iceberg,omitempty"` - Left gateioNumericalValue `json:"left,omitempty"` - FilledTotal float64 `json:"filled_total,omitempty,string"` - Fee float64 `json:"fee,omitempty,string"` - FeeCurrency string `json:"fee_currency,omitempty"` - PointFee string `json:"point_fee,omitempty"` - GtFee string `json:"gt_fee,omitempty"` - GtDiscount bool `json:"gt_discount,omitempty"` - RebatedFee string `json:"rebated_fee,omitempty"` - RebatedFeeCurrency string `json:"rebated_fee_currency,omitempty"` - Event string `json:"event"` - CreateTime gateioTime `json:"create_time,omitempty"` - CreateTimeMs gateioTime `json:"create_time_ms,omitempty"` - UpdateTime gateioTime `json:"update_time,omitempty"` - UpdateTimeMs gateioTime `json:"update_time_ms,omitempty"` + ID string `json:"id,omitempty"` + User int64 `json:"user"` + Text string `json:"text,omitempty"` + Succeeded bool `json:"succeeded,omitempty"` + Label string `json:"label,omitempty"` + Message string `json:"message,omitempty"` + CurrencyPair currency.Pair `json:"currency_pair,omitempty"` + Type string `json:"type,omitempty"` + Account string `json:"account,omitempty"` + Side string `json:"side,omitempty"` + Amount convert.StringToFloat64 `json:"amount,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` + TimeInForce string `json:"time_in_force,omitempty"` + Iceberg string `json:"iceberg,omitempty"` + Left gateioNumericalValue `json:"left,omitempty"` + FilledTotal convert.StringToFloat64 `json:"filled_total,omitempty"` + Fee convert.StringToFloat64 `json:"fee,omitempty"` + FeeCurrency string `json:"fee_currency,omitempty"` + PointFee string `json:"point_fee,omitempty"` + GtFee string `json:"gt_fee,omitempty"` + GtDiscount bool `json:"gt_discount,omitempty"` + RebatedFee string `json:"rebated_fee,omitempty"` + RebatedFeeCurrency string `json:"rebated_fee_currency,omitempty"` + Event string `json:"event"` + CreateTime gateioTime `json:"create_time,omitempty"` + CreateTimeMs gateioTime `json:"create_time_ms,omitempty"` + UpdateTime gateioTime `json:"update_time,omitempty"` + UpdateTimeMs gateioTime `json:"update_time_ms,omitempty"` } // WsUserPersonalTrade represents a user's personal trade pushed through the websocket connection. type WsUserPersonalTrade struct { - ID int64 `json:"id"` - UserID int64 `json:"user_id"` - OrderID string `json:"order_id"` - CurrencyPair currency.Pair `json:"currency_pair"` - CreateTime int64 `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - Side string `json:"side"` - Amount float64 `json:"amount,string"` - Role string `json:"role"` - Price float64 `json:"price,string"` - Fee float64 `json:"fee,string"` - PointFee float64 `json:"point_fee,string"` - GtFee string `json:"gt_fee"` - Text string `json:"text"` + ID int64 `json:"id"` + UserID int64 `json:"user_id"` + OrderID string `json:"order_id"` + CurrencyPair currency.Pair `json:"currency_pair"` + CreateTime int64 `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + Side string `json:"side"` + Amount convert.StringToFloat64 `json:"amount"` + Role string `json:"role"` + Price convert.StringToFloat64 `json:"price"` + Fee convert.StringToFloat64 `json:"fee"` + PointFee convert.StringToFloat64 `json:"point_fee"` + GtFee string `json:"gt_fee"` + Text string `json:"text"` } // WsSpotBalance represents a spot balance. type WsSpotBalance struct { - Timestamp float64 `json:"timestamp,string"` - TimestampMs float64 `json:"timestamp_ms,string"` - User string `json:"user"` - Currency string `json:"currency"` - Change float64 `json:"change,string"` - Total float64 `json:"total,string"` - Available float64 `json:"available,string"` + Timestamp convert.StringToFloat64 `json:"timestamp"` + TimestampMs convert.StringToFloat64 `json:"timestamp_ms"` + User string `json:"user"` + Currency string `json:"currency"` + Change convert.StringToFloat64 `json:"change"` + Total convert.StringToFloat64 `json:"total"` + Available convert.StringToFloat64 `json:"available"` } // WsMarginBalance represents margin account balance push data type WsMarginBalance struct { - Timestamp float64 `json:"timestamp,string"` - TimestampMs float64 `json:"timestamp_ms,string"` - User string `json:"user"` - CurrencyPair string `json:"currency_pair"` - Currency string `json:"currency"` - Change float64 `json:"change,string"` - Available float64 `json:"available,string"` - Freeze float64 `json:"freeze,string"` - Borrowed string `json:"borrowed"` - Interest string `json:"interest"` + Timestamp convert.StringToFloat64 `json:"timestamp"` + TimestampMs convert.StringToFloat64 `json:"timestamp_ms"` + User string `json:"user"` + CurrencyPair string `json:"currency_pair"` + Currency string `json:"currency"` + Change convert.StringToFloat64 `json:"change"` + Available convert.StringToFloat64 `json:"available"` + Freeze convert.StringToFloat64 `json:"freeze"` + Borrowed string `json:"borrowed"` + Interest string `json:"interest"` } // WsFundingBalance represents funding balance push data. type WsFundingBalance struct { - Timestamp int64 `json:"timestamp,string"` - TimestampMs float64 `json:"timestamp_ms,string"` - User string `json:"user"` - Currency string `json:"currency"` - Change string `json:"change"` - Freeze string `json:"freeze"` - Lent string `json:"lent"` + Timestamp int64 `json:"timestamp,string"` + TimestampMs convert.StringToFloat64 `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 int64 `json:"timestamp,string"` - TimestampMs float64 `json:"timestamp_ms,string"` - User string `json:"user"` - Currency string `json:"currency"` - Change string `json:"change"` - Total float64 `json:"total,string"` - Available float64 `json:"available,string"` + Timestamp int64 `json:"timestamp,string"` + TimestampMs convert.StringToFloat64 `json:"timestamp_ms"` + User string `json:"user"` + Currency string `json:"currency"` + Change string `json:"change"` + Total convert.StringToFloat64 `json:"total"` + Available convert.StringToFloat64 `json:"available"` } // WsCrossMarginLoan represents a cross margin loan push data type WsCrossMarginLoan struct { - Timestamp gateioTime `json:"timestamp"` - User string `json:"user"` - Currency string `json:"currency"` - Change string `json:"change"` - Total float64 `json:"total,string"` - Available float64 `json:"available,string"` - Borrowed string `json:"borrowed"` - Interest string `json:"interest"` + Timestamp gateioTime `json:"timestamp"` + User string `json:"user"` + Currency string `json:"currency"` + Change string `json:"change"` + Total convert.StringToFloat64 `json:"total"` + Available convert.StringToFloat64 `json:"available"` + Borrowed string `json:"borrowed"` + Interest string `json:"interest"` } // WsFutureTicker represents a futures push data. type WsFutureTicker struct { - Contract currency.Pair `json:"contract"` - Last float64 `json:"last,string"` - ChangePercentage string `json:"change_percentage"` - FundingRate string `json:"funding_rate"` - FundingRateIndicative string `json:"funding_rate_indicative"` - MarkPrice float64 `json:"mark_price,string"` - IndexPrice float64 `json:"index_price,string"` - TotalSize float64 `json:"total_size,string"` - Volume24H float64 `json:"volume_24h,string"` - Volume24HBtc float64 `json:"volume_24h_btc,string"` - Volume24HUsd float64 `json:"volume_24h_usd,string"` - QuantoBaseRate string `json:"quanto_base_rate"` - Volume24HQuote float64 `json:"volume_24h_quote,string"` - Volume24HSettle string `json:"volume_24h_settle"` - Volume24HBase float64 `json:"volume_24h_base,string"` - Low24H float64 `json:"low_24h,string"` - High24H float64 `json:"high_24h,string"` + Contract currency.Pair `json:"contract"` + Last convert.StringToFloat64 `json:"last"` + ChangePercentage string `json:"change_percentage"` + FundingRate string `json:"funding_rate"` + FundingRateIndicative string `json:"funding_rate_indicative"` + MarkPrice convert.StringToFloat64 `json:"mark_price"` + IndexPrice convert.StringToFloat64 `json:"index_price"` + TotalSize convert.StringToFloat64 `json:"total_size"` + Volume24H convert.StringToFloat64 `json:"volume_24h"` + Volume24HBtc convert.StringToFloat64 `json:"volume_24h_btc"` + Volume24HUsd convert.StringToFloat64 `json:"volume_24h_usd"` + QuantoBaseRate string `json:"quanto_base_rate"` + Volume24HQuote convert.StringToFloat64 `json:"volume_24h_quote"` + Volume24HSettle string `json:"volume_24h_settle"` + Volume24HBase convert.StringToFloat64 `json:"volume_24h_base"` + Low24H convert.StringToFloat64 `json:"low_24h"` + High24H convert.StringToFloat64 `json:"high_24h"` } // WsFuturesTrades represents a list of trades push data type WsFuturesTrades struct { - Size float64 `json:"size"` - ID int64 `json:"id"` - CreateTime gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - Price float64 `json:"price,string"` - Contract currency.Pair `json:"contract"` + Size float64 `json:"size"` + ID int64 `json:"id"` + CreateTime gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + Price convert.StringToFloat64 `json:"price"` + Contract currency.Pair `json:"contract"` } // WsFuturesOrderbookTicker represents the orderbook ticker push data type WsFuturesOrderbookTicker struct { - TimestampMs gateioTime `json:"t"` - UpdateID int64 `json:"u"` - CurrencyPair string `json:"s"` - BestBidPrice float64 `json:"b,string"` - BestBidAmount float64 `json:"B"` - BestAskPrice float64 `json:"a,string"` - BestAskAmount float64 `json:"A"` + TimestampMs gateioTime `json:"t"` + UpdateID int64 `json:"u"` + CurrencyPair string `json:"s"` + BestBidPrice convert.StringToFloat64 `json:"b"` + BestBidAmount float64 `json:"B"` + BestAskPrice convert.StringToFloat64 `json:"a"` + BestAskAmount float64 `json:"A"` } // WsFuturesAndOptionsOrderbookUpdate represents futures and options account orderbook update push data @@ -2222,12 +2223,12 @@ type WsFuturesAndOptionsOrderbookUpdate struct { FirstUpdatedID int64 `json:"U"` LastUpdatedID int64 `json:"u"` Bids []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"b"` Asks []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"a"` } @@ -2237,21 +2238,21 @@ type WsFuturesOrderbookSnapshot struct { Contract currency.Pair `json:"contract"` OrderbookID int64 `json:"id"` Asks []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"asks"` Bids []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"bids"` } // WsFuturesOrderbookUpdateEvent represents futures orderbook push data with the event 'update' type WsFuturesOrderbookUpdateEvent struct { - Price float64 `json:"p,string"` - Amount float64 `json:"s"` - CurrencyPair string `json:"c"` - ID int64 `json:"id"` + Price convert.StringToFloat64 `json:"p"` + Amount float64 `json:"s"` + CurrencyPair string `json:"c"` + ID int64 `json:"id"` } // WsFuturesOrder represents futures order @@ -2283,17 +2284,17 @@ type WsFuturesOrder struct { // WsFuturesUserTrade represents a futures account user trade push data type WsFuturesUserTrade struct { - ID string `json:"id"` - CreateTime gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - Contract currency.Pair `json:"contract"` - OrderID string `json:"order_id"` - Size float64 `json:"size"` - Price float64 `json:"price,string"` - Role string `json:"role"` - Text string `json:"text"` - Fee float64 `json:"fee"` - PointFee int64 `json:"point_fee"` + ID string `json:"id"` + CreateTime gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + Contract currency.Pair `json:"contract"` + OrderID string `json:"order_id"` + Size float64 `json:"size"` + Price convert.StringToFloat64 `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 @@ -2399,14 +2400,14 @@ type WsFuturesAutoOrder struct { Expiration int64 `json:"expiration"` } `json:"trigger"` Initial struct { - Contract string `json:"contract"` - Size int64 `json:"size"` - Price float64 `json:"price,string"` - TimeInForce string `json:"tif"` - Text string `json:"text"` - Iceberg int64 `json:"iceberg"` - IsClose bool `json:"is_close"` - IsReduceOnly bool `json:"is_reduce_only"` + Contract string `json:"contract"` + Size int64 `json:"size"` + Price convert.StringToFloat64 `json:"price"` + TimeInForce string `json:"tif"` + Text string `json:"text"` + Iceberg int64 `json:"iceberg"` + IsClose bool `json:"is_close"` + IsReduceOnly bool `json:"is_reduce_only"` } `json:"initial"` ID int64 `json:"id"` TradeID int64 `json:"trade_id"` @@ -2507,25 +2508,25 @@ type WsOptionsContract struct { // WsOptionsContractCandlestick represents an options contract candlestick push data. type WsOptionsContractCandlestick struct { - Timestamp int64 `json:"t"` - TotalVolume float64 `json:"v"` - ClosePrice float64 `json:"c,string"` - HighestPrice float64 `json:"h,string"` - LowestPrice float64 `json:"l,string"` - OpenPrice float64 `json:"o,string"` - Amount float64 `json:"a,string"` - NameOfSubscription string `json:"n"` // the format of _ + Timestamp int64 `json:"t"` + TotalVolume float64 `json:"v"` + ClosePrice convert.StringToFloat64 `json:"c"` + HighestPrice convert.StringToFloat64 `json:"h"` + LowestPrice convert.StringToFloat64 `json:"l"` + OpenPrice convert.StringToFloat64 `json:"o"` + Amount convert.StringToFloat64 `json:"a"` + NameOfSubscription string `json:"n"` // the format of _ } // WsOptionsOrderbookTicker represents options orderbook ticker push data. type WsOptionsOrderbookTicker struct { - UpdateTimestamp gateioTime `json:"t"` - UpdateID int64 `json:"u"` - ContractName string `json:"s"` - BidPrice float64 `json:"b,string"` - BidSize float64 `json:"B"` - AskPrice float64 `json:"a,string"` - AskSize float64 `json:"A"` + UpdateTimestamp gateioTime `json:"t"` + UpdateID int64 `json:"u"` + ContractName string `json:"s"` + BidPrice convert.StringToFloat64 `json:"b"` + BidSize float64 `json:"B"` + AskPrice convert.StringToFloat64 `json:"a"` + AskSize float64 `json:"A"` } // WsOptionsOrderbookSnapshot represents the options orderbook snapshot push data. @@ -2534,12 +2535,12 @@ type WsOptionsOrderbookSnapshot struct { Contract currency.Pair `json:"contract"` ID int64 `json:"id"` Asks []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"asks"` Bids []struct { - Price float64 `json:"p,string"` - Size float64 `json:"s"` + Price convert.StringToFloat64 `json:"p"` + Size float64 `json:"s"` } `json:"bids"` } @@ -2572,15 +2573,15 @@ type WsOptionsOrder struct { // 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 gateioTime `json:"create_time"` - CreateTimeMs gateioTime `json:"create_time_ms"` - Price float64 `json:"price,string"` - 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 gateioTime `json:"create_time"` + CreateTimeMs gateioTime `json:"create_time_ms"` + Price convert.StringToFloat64 `json:"price"` + Role string `json:"role"` + Size float64 `json:"size"` } // WsOptionsLiquidates represents the liquidates push data of option account. @@ -2620,13 +2621,13 @@ type WsOptionsPosition struct { // InterSubAccountTransferParams represents parameters to transfer funds between sub-accounts. type InterSubAccountTransferParams struct { - Currency currency.Code `json:"currency"` // Required - SubAccountType string `json:"sub_account_type"` - SubAccountFromUserID string `json:"sub_account_from"` // Required - SubAccountFromAssetType asset.Item `json:"sub_account_from_type"` // Required - SubAccountToUserID string `json:"sub_account_to"` // Required - SubAccountToAssetType asset.Item `json:"sub_account_to_type"` // Required - Amount float64 `json:"amount,string"` // Required + Currency currency.Code `json:"currency"` // Required + SubAccountType string `json:"sub_account_type"` + SubAccountFromUserID string `json:"sub_account_from"` // Required + SubAccountFromAssetType asset.Item `json:"sub_account_from_type"` // Required + SubAccountToUserID string `json:"sub_account_to"` // Required + SubAccountToAssetType asset.Item `json:"sub_account_to_type"` // Required + Amount convert.StringToFloat64 `json:"amount"` // Required } // CreateAPIKeySubAccountParams represents subaccount new API key creation parameters. @@ -2664,6 +2665,6 @@ type CreateAPIKeyResponse struct { // PriceAndAmount used in updating an order type PriceAndAmount struct { - Amount float64 `json:"amount,string,omitempty"` - Price float64 `json:"price,string,omitempty"` + Amount convert.StringToFloat64 `json:"amount,omitempty"` + Price convert.StringToFloat64 `json:"price,omitempty"` } diff --git a/exchanges/gateio/gateio_websocket.go b/exchanges/gateio/gateio_websocket.go index 0afa6d21..bed341a6 100644 --- a/exchanges/gateio/gateio_websocket.go +++ b/exchanges/gateio/gateio_websocket.go @@ -167,13 +167,13 @@ func (g *Gateio) processTicker(incoming []byte, pushTime int64) error { } tickerPrice := ticker.Price{ ExchangeName: g.Name, - Volume: data.BaseVolume, - QuoteVolume: data.QuoteVolume, - High: data.High24H, - Low: data.Low24H, - Last: data.Last, - Bid: data.HighestBid, - Ask: data.LowestAsk, + Volume: data.BaseVolume.Float64(), + QuoteVolume: data.QuoteVolume.Float64(), + High: data.High24H.Float64(), + Low: data.Low24H.Float64(), + Last: data.Last.Float64(), + Bid: data.HighestBid.Float64(), + Ask: data.LowestAsk.Float64(), AssetType: asset.Spot, Pair: data.CurrencyPair, LastUpdated: time.Unix(pushTime, 0), @@ -216,8 +216,8 @@ func (g *Gateio) processTrades(incoming []byte) error { CurrencyPair: data.CurrencyPair, AssetType: asset.Spot, Exchange: g.Name, - Price: data.Price, - Amount: data.Amount, + Price: data.Price.Float64(), + Amount: data.Amount.Float64(), Side: side, TID: strconv.FormatInt(data.ID, 10), } @@ -254,11 +254,11 @@ func (g *Gateio) processCandlestick(incoming []byte) error { Exchange: g.Name, StartTime: time.Unix(data.Timestamp, 0), Interval: icp[0], - OpenPrice: data.OpenPrice, - ClosePrice: data.ClosePrice, - HighPrice: data.HighestPrice, - LowPrice: data.LowestPrice, - Volume: data.TotalVolume, + OpenPrice: data.OpenPrice.Float64(), + ClosePrice: data.ClosePrice.Float64(), + HighPrice: data.HighestPrice.Float64(), + LowPrice: data.LowestPrice.Float64(), + Volume: data.TotalVolume.Float64(), } assetPairEnabled := g.listOfAssetsCurrencyPairEnabledFor(currencyPair) if assetPairEnabled[asset.Spot] { @@ -289,8 +289,8 @@ func (g *Gateio) processOrderbookTicker(incoming []byte) error { Pair: data.CurrencyPair, Asset: asset.Spot, LastUpdated: time.UnixMilli(data.UpdateTimeMS), - Bids: []orderbook.Item{{Price: data.BestBidPrice, Amount: data.BestBidAmount}}, - Asks: []orderbook.Item{{Price: data.BestAskPrice, Amount: data.BestAskAmount}}, + Bids: []orderbook.Item{{Price: data.BestBidPrice.Float64(), Amount: data.BestBidAmount.Float64()}}, + Asks: []orderbook.Item{{Price: data.BestAskPrice.Float64(), Amount: data.BestAskAmount.Float64()}}, }) } @@ -464,16 +464,16 @@ func (g *Gateio) processSpotOrders(data []byte) error { return err } details[x] = order.Detail{ - Amount: resp.Result[x].Amount, + Amount: resp.Result[x].Amount.Float64(), Exchange: g.Name, OrderID: resp.Result[x].ID, Side: side, Type: orderType, Pair: resp.Result[x].CurrencyPair, - Cost: resp.Result[x].Fee, + Cost: resp.Result[x].Fee.Float64(), AssetType: a, - Price: resp.Result[x].Price, - ExecutedAmount: resp.Result[x].Amount - resp.Result[x].Left.Float64(), + 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(), } @@ -510,8 +510,8 @@ func (g *Gateio) processUserPersonalTrades(data []byte) error { Side: side, OrderID: resp.Result[x].OrderID, TradeID: strconv.FormatInt(resp.Result[x].ID, 10), - Price: resp.Result[x].Price, - Amount: resp.Result[x].Amount, + Price: resp.Result[x].Price.Float64(), + Amount: resp.Result[x].Amount.Float64(), } } return g.Websocket.Fills.Update(fills...) @@ -535,7 +535,7 @@ func (g *Gateio) processSpotBalances(data []byte) error { Exchange: g.Name, Currency: code, Asset: asset.Spot, - Amount: resp.Result[x].Available, + Amount: resp.Result[x].Available.Float64(), } } g.Websocket.DataHandler <- accountChanges @@ -560,7 +560,7 @@ func (g *Gateio) processMarginBalances(data []byte) error { Exchange: g.Name, Currency: code, Asset: asset.Margin, - Amount: resp.Result[x].Available, + Amount: resp.Result[x].Available.Float64(), } } g.Websocket.DataHandler <- accountChange @@ -600,7 +600,7 @@ func (g *Gateio) processCrossMarginBalance(data []byte) error { Exchange: g.Name, Currency: code, Asset: asset.Margin, - Amount: resp.Result[x].Available, + Amount: resp.Result[x].Available.Float64(), Account: resp.Result[x].User, } } diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index d3c0d82a..01a35d8e 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -12,6 +12,7 @@ import ( "time" "github.com/thrasher-corp/gocryptotrader/common" + "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" @@ -312,11 +313,11 @@ func (g *Gateio) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item } tickerData = &ticker.Price{ Pair: fPair, - Low: tick.Low24H, - High: tick.High24H, - Last: tick.Last, - Volume: tick.Volume24HBase, - QuoteVolume: tick.Volume24HQuote, + Low: tick.Low24H.Float64(), + High: tick.High24H.Float64(), + Last: tick.Last.Float64(), + Volume: tick.Volume24HBase.Float64(), + QuoteVolume: tick.Volume24HQuote.Float64(), ExchangeName: g.Name, AssetType: a, } @@ -343,8 +344,8 @@ func (g *Gateio) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item tickerData = &ticker.Price{ Pair: tickers[x].Name, Last: tickers[x].LastPrice.Float64(), - Bid: tickers[x].Bid1Price, - Ask: tickers[x].Ask1Price, + Bid: tickers[x].Bid1Price.Float64(), + Ask: tickers[x].Ask1Price.Float64(), AskSize: tickers[x].Ask1Size, BidSize: tickers[x].Bid1Size, ExchangeName: g.Name, @@ -371,11 +372,11 @@ func (g *Gateio) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item if tickers[x].Contract == fPair.Upper().String() { tickerData = &ticker.Price{ Pair: fPair, - Last: tickers[x].Last, - High: tickers[x].High24H, - Low: tickers[x].Low24H, - Volume: tickers[x].Volume24H, - QuoteVolume: tickers[x].Volume24HQuote, + Last: tickers[x].Last.Float64(), + High: tickers[x].High24H.Float64(), + Low: tickers[x].Low24H.Float64(), + Volume: tickers[x].Volume24H.Float64(), + QuoteVolume: tickers[x].Volume24HQuote.Float64(), ExchangeName: g.Name, AssetType: a, } @@ -613,11 +614,11 @@ func (g *Gateio) UpdateTickers(ctx context.Context, a asset.Item) error { return err } err = ticker.ProcessTicker(&ticker.Price{ - Last: tickers[x].Last, - High: tickers[x].High24H, - Low: tickers[x].Low24H, - Volume: tickers[x].Volume24H, - QuoteVolume: tickers[x].Volume24HQuote, + Last: tickers[x].Last.Float64(), + High: tickers[x].High24H.Float64(), + Low: tickers[x].Low24H.Float64(), + Volume: tickers[x].Volume24H.Float64(), + QuoteVolume: tickers[x].Volume24HQuote.Float64(), ExchangeName: g.Name, Pair: currencyPair, AssetType: a, @@ -643,9 +644,9 @@ func (g *Gateio) UpdateTickers(ctx context.Context, a asset.Item) error { for x := range tickers { err = ticker.ProcessTicker(&ticker.Price{ Last: tickers[x].LastPrice.Float64(), - Ask: tickers[x].Ask1Price, + Ask: tickers[x].Ask1Price.Float64(), AskSize: tickers[x].Ask1Size, - Bid: tickers[x].Bid1Price, + Bid: tickers[x].Bid1Price.Float64(), BidSize: tickers[x].Bid1Size, Pair: tickers[x].Name, ExchangeName: g.Name, @@ -756,9 +757,9 @@ func (g *Gateio) UpdateAccountInfo(ctx context.Context, a asset.Item) (account.H for x := range balances { currencies[x] = account.Balance{ Currency: currency.NewCode(balances[x].Currency), - Total: balances[x].Available - balances[x].Locked, - Hold: balances[x].Locked, - Free: balances[x].Available, + Total: balances[x].Available.Float64() - balances[x].Locked.Float64(), + Hold: balances[x].Locked.Float64(), + Free: balances[x].Available.Float64(), } } info.Accounts = append(info.Accounts, account.SubAccount{ @@ -775,14 +776,14 @@ func (g *Gateio) UpdateAccountInfo(ctx context.Context, a asset.Item) (account.H for x := range balances { currencies = append(currencies, account.Balance{ Currency: currency.NewCode(balances[x].Base.Currency), - Total: balances[x].Base.Available + balances[x].Base.LockedAmount, - Hold: balances[x].Base.LockedAmount, - Free: balances[x].Base.Available, + Total: balances[x].Base.Available.Float64() + balances[x].Base.LockedAmount.Float64(), + Hold: balances[x].Base.LockedAmount.Float64(), + Free: balances[x].Base.Available.Float64(), }, account.Balance{ Currency: currency.NewCode(balances[x].Quote.Currency), - Total: balances[x].Quote.Available + balances[x].Quote.LockedAmount, - Hold: balances[x].Quote.LockedAmount, - Free: balances[x].Quote.Available, + Total: balances[x].Quote.Available.Float64() + balances[x].Quote.LockedAmount.Float64(), + Hold: balances[x].Quote.LockedAmount.Float64(), + Free: balances[x].Quote.Available.Float64(), }) } info.Accounts = append(info.Accounts, account.SubAccount{ @@ -807,9 +808,9 @@ func (g *Gateio) UpdateAccountInfo(ctx context.Context, a asset.Item) (account.H } currencies[x] = account.Balance{ Currency: currency.NewCode(balance.Currency), - Total: balance.Total, - Hold: balance.Total - balance.Available, - Free: balance.Available, + Total: balance.Total.Float64(), + Hold: balance.Total.Float64() - balance.Available.Float64(), + Free: balance.Available.Float64(), } } info.Accounts = append(info.Accounts, account.SubAccount{ @@ -827,9 +828,9 @@ func (g *Gateio) UpdateAccountInfo(ctx context.Context, a asset.Item) (account.H Currencies: []account.Balance{ { Currency: currency.NewCode(balance.Currency), - Total: balance.Total, - Hold: balance.Total - balance.Available, - Free: balance.Available, + Total: balance.Total.Float64(), + Hold: balance.Total.Float64() - balance.Available.Float64(), + Free: balance.Available.Float64(), }, }, }) @@ -878,7 +879,7 @@ func (g *Gateio) GetWithdrawalsHistory(ctx context.Context, c currency.Code, _ a Status: records[x].Status, TransferID: records[x].ID, Currency: records[x].Currency, - Amount: records[x].Amount, + Amount: records[x].Amount.Float64(), CryptoTxID: records[x].TransactionID, CryptoToAddress: records[x].WithdrawalAddress, Timestamp: records[x].Timestamp.Time(), @@ -917,8 +918,8 @@ func (g *Gateio) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.I CurrencyPair: p, AssetType: a, Side: side, - Price: tradeData[i].Price, - Amount: tradeData[i].Amount, + Price: tradeData[i].Price.Float64(), + Amount: tradeData[i].Amount.Float64(), Timestamp: tradeData[i].CreateTimeMs.Time(), } } @@ -940,7 +941,7 @@ func (g *Gateio) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.I Exchange: g.Name, CurrencyPair: p, AssetType: a, - Price: futuresTrades[i].Price, + Price: futuresTrades[i].Price.Float64(), Amount: futuresTrades[i].Size, Timestamp: futuresTrades[i].CreateTime.Time(), } @@ -963,7 +964,7 @@ func (g *Gateio) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.I Exchange: g.Name, CurrencyPair: p, AssetType: a, - Price: deliveryTrades[i].Price, + Price: deliveryTrades[i].Price.Float64(), Amount: deliveryTrades[i].Size, Timestamp: deliveryTrades[i].CreateTime.Time(), } @@ -981,7 +982,7 @@ func (g *Gateio) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.I Exchange: g.Name, CurrencyPair: p, AssetType: a, - Price: trades[i].Price, + Price: trades[i].Price.Float64(), Amount: trades[i].Size, Timestamp: trades[i].CreateTime.Time(), } @@ -1032,8 +1033,8 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi Side: orderTypeFormat, Type: s.Type.Lower(), Account: g.assetTypeToString(s.AssetType), - Amount: s.Amount, - Price: s.Price, + Amount: convert.StringToFloat64(s.Amount), + Price: convert.StringToFloat64(s.Price), CurrencyPair: s.Pair, Text: s.ClientOrderID, }) @@ -1054,7 +1055,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi return nil, err } response.Status = status - response.Fee = sOrder.FeeDeducted + response.Fee = sOrder.FeeDeducted.Float64() response.FeeAsset = currency.NewCode(sOrder.FeeCurrency) response.Pair = s.Pair response.Date = sOrder.CreateTime.Time() @@ -1075,7 +1076,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi fOrder, err := g.PlaceFuturesOrder(ctx, &OrderCreateParams{ Contract: s.Pair, Size: s.Amount, - Price: s.Price, + Price: convert.StringToFloat64(s.Price), Settle: settle, ReduceOnly: s.ReduceOnly, TimeInForce: "gtc", @@ -1112,7 +1113,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi newOrder, err := g.PlaceDeliveryOrder(ctx, &OrderCreateParams{ Contract: s.Pair, Size: s.Amount, - Price: s.Price, + Price: convert.StringToFloat64(s.Price), Settle: settle, ReduceOnly: s.ReduceOnly, TimeInForce: "gtc", @@ -1134,13 +1135,13 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi response.Date = newOrder.CreateTime.Time() response.ClientOrderID = newOrder.Text response.Amount = newOrder.Size - response.Price = newOrder.OrderPrice + response.Price = newOrder.OrderPrice.Float64() return response, nil case asset.Options: optionOrder, err := g.PlaceOptionOrder(ctx, OptionOrderParam{ Contract: s.Pair.String(), OrderSize: s.Amount, - Price: s.Price, + Price: convert.StringToFloat64(s.Price), ReduceOnly: s.ReduceOnly, Text: s.ClientOrderID, }) @@ -1409,17 +1410,17 @@ func (g *Gateio) GetOrderInfo(ctx context.Context, orderID string, pair currency return nil, err } return &order.Detail{ - Amount: spotOrder.Amount, + Amount: spotOrder.Amount.Float64(), Exchange: g.Name, OrderID: spotOrder.OrderID, Side: side, Type: orderType, Pair: pair, - Cost: spotOrder.FeeDeducted, + Cost: spotOrder.FeeDeducted.Float64(), AssetType: a, Status: orderStatus, - Price: spotOrder.Price, - ExecutedAmount: spotOrder.Amount - spotOrder.Left.Float64(), + Price: spotOrder.Price.Float64(), + ExecutedAmount: spotOrder.Amount.Float64() - spotOrder.Left.Float64(), Date: spotOrder.CreateTimeMs.Time(), LastUpdated: spotOrder.UpdateTimeMs.Time(), }, nil @@ -1457,7 +1458,7 @@ func (g *Gateio) GetOrderInfo(ctx context.Context, orderID string, pair currency Exchange: g.Name, OrderID: orderID, Status: orderStatus, - Price: fOrder.OrderPrice, + Price: fOrder.OrderPrice.Float64(), Date: fOrder.CreateTime.Time(), LastUpdated: fOrder.FinishTime.Time(), Pair: pair, @@ -1482,7 +1483,7 @@ func (g *Gateio) GetOrderInfo(ctx context.Context, orderID string, pair currency Exchange: g.Name, OrderID: orderID, Status: orderStatus, - Price: optionOrder.Price, + Price: optionOrder.Price.Float64(), Date: optionOrder.CreateTime.Time(), LastUpdated: optionOrder.FinishTime.Time(), Pair: pair, @@ -1528,7 +1529,7 @@ func (g *Gateio) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawReques } response, err := g.WithdrawCurrency(ctx, WithdrawalRequestParam{ - Amount: withdrawRequest.Amount, + Amount: convert.StringToFloat64(withdrawRequest.Amount), Currency: withdrawRequest.Currency, Address: withdrawRequest.Crypto.Address, Chain: withdrawRequest.Crypto.Chain, @@ -1614,11 +1615,11 @@ func (g *Gateio) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque Status: status, Pair: symbol, OrderID: spotOrders[x].Orders[y].OrderID, - Amount: spotOrders[x].Orders[y].Amount, - ExecutedAmount: spotOrders[x].Orders[y].Amount - spotOrders[x].Orders[y].Left.Float64(), + Amount: spotOrders[x].Orders[y].Amount.Float64(), + ExecutedAmount: spotOrders[x].Orders[y].Amount.Float64() - spotOrders[x].Orders[y].Left.Float64(), RemainingAmount: spotOrders[x].Orders[y].Left.Float64(), - Price: spotOrders[x].Orders[y].Price, - AverageExecutedPrice: spotOrders[x].Orders[y].AverageFillPrice, + 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(), Exchange: g.Name, @@ -1665,7 +1666,7 @@ func (g *Gateio) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque Amount: futuresOrders[x].Size, Pair: req.Pairs[x], OrderID: strconv.FormatInt(futuresOrders[x].ID, 10), - Price: futuresOrders[x].OrderPrice, + Price: futuresOrders[x].OrderPrice.Float64(), ExecutedAmount: futuresOrders[x].Size - futuresOrders[x].RemainingAmount, RemainingAmount: futuresOrders[x].RemainingAmount, LastUpdated: futuresOrders[x].FinishTime.Time(), @@ -1698,7 +1699,7 @@ func (g *Gateio) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque Amount: optionsOrders[x].Size, Pair: currencyPair, OrderID: strconv.FormatInt(optionsOrders[x].OptionOrderID, 10), - Price: optionsOrders[x].Price, + Price: optionsOrders[x].Price.Float64(), ExecutedAmount: optionsOrders[x].Size - optionsOrders[x].Left, RemainingAmount: optionsOrders[x].Left, LastUpdated: optionsOrders[x].FinishTime.Time(), @@ -1743,15 +1744,15 @@ func (g *Gateio) GetOrderHistory(ctx context.Context, req *order.MultiOrderReque } detail := order.Detail{ OrderID: spotOrders[o].OrderID, - Amount: spotOrders[o].Amount, - ExecutedAmount: spotOrders[o].Amount, - Price: spotOrders[o].Price, + Amount: spotOrders[o].Amount.Float64(), + ExecutedAmount: spotOrders[o].Amount.Float64(), + Price: spotOrders[o].Price.Float64(), Date: spotOrders[o].CreateTime.Time(), Side: side, Exchange: g.Name, Pair: fPair, AssetType: req.AssetType, - Fee: spotOrders[o].Fee, + Fee: spotOrders[o].Fee.Float64(), FeeAsset: currency.NewCode(spotOrders[o].FeeCurrency), } detail.InferCostsAndTimes() @@ -1786,7 +1787,7 @@ func (g *Gateio) GetOrderHistory(ctx context.Context, req *order.MultiOrderReque detail := order.Detail{ OrderID: strconv.FormatInt(futuresOrder[o].ID, 10), Amount: futuresOrder[o].Size, - Price: futuresOrder[o].Price, + Price: futuresOrder[o].Price.Float64(), Date: futuresOrder[o].CreateTime.Time(), Exchange: g.Name, Pair: fPair, @@ -1808,7 +1809,7 @@ func (g *Gateio) GetOrderHistory(ctx context.Context, req *order.MultiOrderReque detail := order.Detail{ OrderID: strconv.FormatInt(optionOrders[o].OrderID, 10), Amount: optionOrders[o].Size, - Price: optionOrders[o].Price, + Price: optionOrders[o].Price.Float64(), Date: optionOrders[o].CreateTime.Time(), Exchange: g.Name, Pair: fPair, @@ -1875,10 +1876,10 @@ func (g *Gateio) GetHistoricCandles(ctx context.Context, pair currency.Pair, a a for x := range candles { listCandlesticks[x] = kline.Candle{ Time: candles[x].Timestamp.Time(), - Open: candles[x].OpenPrice, - High: candles[x].HighestPrice, - Low: candles[x].LowestPrice, - Close: candles[x].ClosePrice, + Open: candles[x].OpenPrice.Float64(), + High: candles[x].HighestPrice.Float64(), + Low: candles[x].LowestPrice.Float64(), + Close: candles[x].ClosePrice.Float64(), Volume: candles[x].Volume, } } @@ -1938,10 +1939,10 @@ func (g *Gateio) GetHistoricCandlesExtended(ctx context.Context, pair currency.P for x := range candles { candlestickItems = append(candlestickItems, kline.Candle{ Time: candles[x].Timestamp.Time(), - Open: candles[x].OpenPrice, - High: candles[x].HighestPrice, - Low: candles[x].LowestPrice, - Close: candles[x].ClosePrice, + Open: candles[x].OpenPrice.Float64(), + High: candles[x].HighestPrice.Float64(), + Low: candles[x].LowestPrice.Float64(), + Close: candles[x].ClosePrice.Float64(), Volume: candles[x].Volume, }) } diff --git a/exchanges/gateio/gateio_ws_futures.go b/exchanges/gateio/gateio_ws_futures.go index 7fa8a653..b0189992 100644 --- a/exchanges/gateio/gateio_ws_futures.go +++ b/exchanges/gateio/gateio_ws_futures.go @@ -425,11 +425,11 @@ func (g *Gateio) processFuturesTickers(data []byte, assetType asset.Item) error for x := range resp.Result { tickerPriceDatas[x] = ticker.Price{ ExchangeName: g.Name, - Volume: resp.Result[x].Volume24HBase, - QuoteVolume: resp.Result[x].Volume24HQuote, - High: resp.Result[x].High24H, - Low: resp.Result[x].Low24H, - Last: resp.Result[x].Last, + Volume: resp.Result[x].Volume24HBase.Float64(), + QuoteVolume: resp.Result[x].Volume24HQuote.Float64(), + High: resp.Result[x].High24H.Float64(), + Low: resp.Result[x].Low24H.Float64(), + Last: resp.Result[x].Last.Float64(), AssetType: assetType, Pair: resp.Result[x].Contract, LastUpdated: time.Unix(resp.Time, 0), @@ -463,7 +463,7 @@ func (g *Gateio) processFuturesTrades(data []byte, assetType asset.Item) error { CurrencyPair: resp.Result[x].Contract, AssetType: assetType, Exchange: g.Name, - Price: resp.Result[x].Price, + Price: resp.Result[x].Price.Float64(), Amount: resp.Result[x].Size, TID: strconv.FormatInt(resp.Result[x].ID, 10), } @@ -498,10 +498,10 @@ func (g *Gateio) processFuturesCandlesticks(data []byte, assetType asset.Item) e Exchange: g.Name, StartTime: resp.Result[x].Timestamp.Time(), Interval: icp[0], - OpenPrice: resp.Result[x].OpenPrice, - ClosePrice: resp.Result[x].ClosePrice, - HighPrice: resp.Result[x].HighestPrice, - LowPrice: resp.Result[x].LowestPrice, + OpenPrice: resp.Result[x].OpenPrice.Float64(), + ClosePrice: resp.Result[x].ClosePrice.Float64(), + HighPrice: resp.Result[x].HighestPrice.Float64(), + LowPrice: resp.Result[x].LowestPrice.Float64(), Volume: resp.Result[x].Volume, } } @@ -552,12 +552,12 @@ func (g *Gateio) processFuturesAndOptionsOrderbookUpdate(incoming []byte, assetT updates.Asks = make([]orderbook.Item, len(data.Asks)) for x := range data.Asks { updates.Asks[x].Amount = data.Asks[x].Size - updates.Asks[x].Price = data.Asks[x].Price + updates.Asks[x].Price = data.Asks[x].Price.Float64() } updates.Bids = make([]orderbook.Item, len(data.Bids)) for x := range data.Bids { updates.Bids[x].Amount = data.Bids[x].Size - updates.Bids[x].Price = data.Bids[x].Price + updates.Bids[x].Price = data.Bids[x].Price.Float64() } if len(updates.Asks) == 0 && len(updates.Bids) == 0 { return errors.New("malformed orderbook data") @@ -582,12 +582,12 @@ func (g *Gateio) processFuturesOrderbookSnapshot(event string, incoming []byte, base.Asks = make([]orderbook.Item, len(data.Asks)) for x := range data.Asks { base.Asks[x].Amount = data.Asks[x].Size - base.Asks[x].Price = data.Asks[x].Price + base.Asks[x].Price = data.Asks[x].Price.Float64() } base.Bids = make([]orderbook.Item, len(data.Bids)) for x := range data.Bids { base.Bids[x].Amount = data.Bids[x].Size - base.Bids[x].Price = data.Bids[x].Price + base.Bids[x].Price = data.Bids[x].Price.Float64() } return g.Websocket.Orderbook.LoadSnapshot(&base) } @@ -604,12 +604,12 @@ func (g *Gateio) processFuturesOrderbookSnapshot(event string, incoming []byte, } if data[x].Amount > 0 { ab[1] = append(ab[1], orderbook.Item{ - Price: data[x].Price, + Price: data[x].Price.Float64(), Amount: data[x].Amount, }) } else { ab[0] = append(ab[0], orderbook.Item{ - Price: data[x].Price, + Price: data[x].Price.Float64(), Amount: -data[x].Amount, }) } @@ -705,7 +705,7 @@ func (g *Gateio) procesFuturesUserTrades(data []byte, assetType asset.Item) erro CurrencyPair: resp.Result[x].Contract, OrderID: resp.Result[x].OrderID, TradeID: resp.Result[x].ID, - Price: resp.Result[x].Price, + Price: resp.Result[x].Price.Float64(), Amount: resp.Result[x].Size, AssetType: assetType, } diff --git a/exchanges/gateio/gateio_ws_option.go b/exchanges/gateio/gateio_ws_option.go index a7b0dca2..26867e77 100644 --- a/exchanges/gateio/gateio_ws_option.go +++ b/exchanges/gateio/gateio_ws_option.go @@ -408,8 +408,8 @@ func (g *Gateio) processOptionsContractTickers(incoming []byte) error { g.Websocket.DataHandler <- &ticker.Price{ Pair: data.Name, Last: data.LastPrice.Float64(), - Bid: data.Bid1Price, - Ask: data.Ask1Price, + Bid: data.Bid1Price.Float64(), + Ask: data.Ask1Price.Float64(), AskSize: data.Ask1Size, BidSize: data.Bid1Size, ExchangeName: g.Name, @@ -526,11 +526,11 @@ func (g *Gateio) processOptionsCandlestickPushData(data []byte) error { Exchange: g.Name, StartTime: time.Unix(resp.Result[x].Timestamp, 0), Interval: icp[0], - OpenPrice: resp.Result[x].OpenPrice, - ClosePrice: resp.Result[x].ClosePrice, - HighPrice: resp.Result[x].HighestPrice, - LowPrice: resp.Result[x].LowestPrice, - Volume: resp.Result[x].Amount, + OpenPrice: resp.Result[x].OpenPrice.Float64(), + ClosePrice: resp.Result[x].ClosePrice.Float64(), + HighPrice: resp.Result[x].HighestPrice.Float64(), + LowPrice: resp.Result[x].LowestPrice.Float64(), + Volume: resp.Result[x].Amount.Float64(), } } g.Websocket.DataHandler <- klineDatas @@ -564,12 +564,12 @@ func (g *Gateio) processOptionsOrderbookSnapshotPushData(event string, incoming base.Asks = make([]orderbook.Item, len(data.Asks)) for x := range data.Asks { base.Asks[x].Amount = data.Asks[x].Size - base.Asks[x].Price = data.Asks[x].Price + base.Asks[x].Price = data.Asks[x].Price.Float64() } base.Bids = make([]orderbook.Item, len(data.Bids)) for x := range data.Bids { base.Bids[x].Amount = data.Bids[x].Size - base.Bids[x].Price = data.Bids[x].Price + base.Bids[x].Price = data.Bids[x].Price.Float64() } return g.Websocket.Orderbook.LoadSnapshot(&base) } @@ -586,11 +586,11 @@ func (g *Gateio) processOptionsOrderbookSnapshotPushData(event string, incoming } if data[x].Amount > 0 { ab[1] = append(ab[1], orderbook.Item{ - Price: data[x].Price, Amount: data[x].Amount, + Price: data[x].Price.Float64(), Amount: data[x].Amount, }) } else { ab[0] = append(ab[0], orderbook.Item{ - Price: data[x].Price, Amount: -data[x].Amount, + Price: data[x].Price.Float64(), Amount: -data[x].Amount, }) } if !ok { @@ -682,7 +682,7 @@ func (g *Gateio) processOptionsUserTradesPushData(data []byte) error { CurrencyPair: resp.Result[x].Contract, OrderID: resp.Result[x].OrderID, TradeID: resp.Result[x].ID, - Price: resp.Result[x].Price, + Price: resp.Result[x].Price.Float64(), Amount: resp.Result[x].Size, } }