mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +00:00
types: Add Time type from Gateio and share across codebase (#1648)
* consolidate type to types package and share across code base * rm convert type and convert codebase * rm irrelavant test cases * Fix tests * glorious nits * Update exchanges/gateio/gateio_types.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * thrasher: nits --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -2028,11 +2028,11 @@ func TestWsKlineUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
pressXToJSON := []byte(`{"stream":"btcusdt@kline_1m","data":{
|
||||
"e": "kline",
|
||||
"E": 123456789,
|
||||
"E": 1234567891,
|
||||
"s": "BTCUSDT",
|
||||
"k": {
|
||||
"t": 123400000,
|
||||
"T": 123460000,
|
||||
"t": 1234000001,
|
||||
"T": 1234600001,
|
||||
"s": "BTCUSDT",
|
||||
"i": "1m",
|
||||
"f": 100,
|
||||
@@ -2061,14 +2061,14 @@ func TestWsTradeUpdate(t *testing.T) {
|
||||
b.SetSaveTradeDataStatus(true)
|
||||
pressXToJSON := []byte(`{"stream":"btcusdt@trade","data":{
|
||||
"e": "trade",
|
||||
"E": 123456789,
|
||||
"E": 1234567891,
|
||||
"s": "BTCUSDT",
|
||||
"t": 12345,
|
||||
"p": "0.001",
|
||||
"q": "100",
|
||||
"b": 88,
|
||||
"a": 50,
|
||||
"T": 123456785,
|
||||
"T": 1234567851,
|
||||
"m": true,
|
||||
"M": true
|
||||
}}`)
|
||||
@@ -2114,7 +2114,7 @@ func TestWsDepthUpdate(t *testing.T) {
|
||||
|
||||
update1 := []byte(`{"stream":"btcusdt@depth","data":{
|
||||
"e": "depthUpdate",
|
||||
"E": 123456788,
|
||||
"E": 1234567881,
|
||||
"s": "BTCUSDT",
|
||||
"U": 157,
|
||||
"u": 160,
|
||||
@@ -2132,7 +2132,7 @@ func TestWsDepthUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
if err := b.wsHandleData(update1); err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
b.obm.state[currency.BTC][currency.USDT][asset.Spot].fetchingBook = false
|
||||
@@ -2154,7 +2154,7 @@ func TestWsDepthUpdate(t *testing.T) {
|
||||
|
||||
update2 := []byte(`{"stream":"btcusdt@depth","data":{
|
||||
"e": "depthUpdate",
|
||||
"E": 123456789,
|
||||
"E": 1234567892,
|
||||
"s": "BTCUSDT",
|
||||
"U": 161,
|
||||
"u": 165,
|
||||
|
||||
@@ -723,18 +723,18 @@ type WithdrawResponse struct {
|
||||
|
||||
// WithdrawStatusResponse defines a withdrawal status response
|
||||
type WithdrawStatusResponse struct {
|
||||
Address string `json:"address"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
ApplyTime binanceTime `json:"applyTime"`
|
||||
Coin string `json:"coin"`
|
||||
ID string `json:"id"`
|
||||
WithdrawOrderID string `json:"withdrawOrderId"`
|
||||
Network string `json:"network"`
|
||||
TransferType uint8 `json:"transferType"`
|
||||
Status int64 `json:"status"`
|
||||
TransactionFee float64 `json:"transactionFee,string"`
|
||||
TransactionID string `json:"txId"`
|
||||
ConfirmNumber int64 `json:"confirmNo"`
|
||||
Address string `json:"address"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
ApplyTime types.Time `json:"applyTime"`
|
||||
Coin string `json:"coin"`
|
||||
ID string `json:"id"`
|
||||
WithdrawOrderID string `json:"withdrawOrderId"`
|
||||
Network string `json:"network"`
|
||||
TransferType uint8 `json:"transferType"`
|
||||
Status int64 `json:"status"`
|
||||
TransactionFee float64 `json:"transactionFee,string"`
|
||||
TransactionID string `json:"txId"`
|
||||
ConfirmNumber int64 `json:"confirmNo"`
|
||||
}
|
||||
|
||||
// DepositAddress stores the deposit address info
|
||||
@@ -921,15 +921,15 @@ type UserMarginInterestHistoryResponse struct {
|
||||
|
||||
// UserMarginInterestHistory user margin interest history row
|
||||
type UserMarginInterestHistory struct {
|
||||
TxID int64 `json:"txId"`
|
||||
InterestAccruedTime binanceTime `json:"interestAccuredTime"` // typo in docs, cannot verify due to API restrictions
|
||||
Asset string `json:"asset"`
|
||||
RawAsset string `json:"rawAsset"`
|
||||
Principal float64 `json:"principal,string"`
|
||||
Interest float64 `json:"interest,string"`
|
||||
InterestRate float64 `json:"interestRate,string"`
|
||||
Type string `json:"type"`
|
||||
IsolatedSymbol string `json:"isolatedSymbol"`
|
||||
TxID int64 `json:"txId"`
|
||||
InterestAccruedTime types.Time `json:"interestAccuredTime"` // typo in docs, cannot verify due to API restrictions
|
||||
Asset string `json:"asset"`
|
||||
RawAsset string `json:"rawAsset"`
|
||||
Principal float64 `json:"principal,string"`
|
||||
Interest float64 `json:"interest,string"`
|
||||
InterestRate float64 `json:"interestRate,string"`
|
||||
Type string `json:"type"`
|
||||
IsolatedSymbol string `json:"isolatedSymbol"`
|
||||
}
|
||||
|
||||
// CryptoLoansIncomeHistory stores crypto loan income history data
|
||||
@@ -959,7 +959,7 @@ type LoanBorrowHistoryItem struct {
|
||||
LoanTerm int64 `json:"loanTerm,string"`
|
||||
CollateralCoin currency.Code `json:"collateralCoin"`
|
||||
InitialCollateralAmount float64 `json:"initialCollateralAmount,string"`
|
||||
BorrowTime binanceTime `json:"borrowTime"`
|
||||
BorrowTime types.Time `json:"borrowTime"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
@@ -978,7 +978,7 @@ type CryptoLoanOngoingOrderItem struct {
|
||||
CollateralCoin currency.Code `json:"collateralCoin"`
|
||||
CollateralAmount float64 `json:"collateralAmount,string"`
|
||||
CurrentLTV float64 `json:"currentLTV,string"`
|
||||
ExpirationTime binanceTime `json:"expirationTime"`
|
||||
ExpirationTime types.Time `json:"expirationTime"`
|
||||
}
|
||||
|
||||
// CryptoLoanOngoingOrder stores crypto loan ongoing order data
|
||||
@@ -1006,7 +1006,7 @@ type CryptoLoanRepayHistoryItem struct {
|
||||
CollateralUsed float64 `json:"collateralUsed,string"`
|
||||
CollateralReturn float64 `json:"collateralReturn,string"`
|
||||
RepayType string `json:"repayType"`
|
||||
RepayTime binanceTime `json:"repayTime"`
|
||||
RepayTime types.Time `json:"repayTime"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ type CryptoLoanLTVAdjustmentItem struct {
|
||||
Amount float64 `json:"amount,string"`
|
||||
PreviousLTV float64 `json:"preLTV,string"`
|
||||
AfterLTV float64 `json:"afterLTV,string"`
|
||||
AdjustTime binanceTime `json:"adjustTime"`
|
||||
AdjustTime types.Time `json:"adjustTime"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ type CustomiseMarginCallItem struct {
|
||||
CollateralCoin currency.Code `json:"collateralCoin"`
|
||||
PreMarginCall float64 `json:"preMarginCall,string"`
|
||||
AfterMarginCall float64 `json:"afterMarginCall,string"`
|
||||
CustomiseTime binanceTime `json:"customizeTime"`
|
||||
CustomiseTime types.Time `json:"customizeTime"`
|
||||
}
|
||||
|
||||
// CustomiseMarginCall stores customise margin call data
|
||||
@@ -1136,7 +1136,7 @@ type FlexibleLoanBorrowHistoryItem struct {
|
||||
InitialLoanAmount float64 `json:"initialLoanAmount,string"`
|
||||
CollateralCoin currency.Code `json:"collateralCoin"`
|
||||
InitialCollateralAmount float64 `json:"initialCollateralAmount,string"`
|
||||
BorrowTime binanceTime `json:"borrowTime"`
|
||||
BorrowTime types.Time `json:"borrowTime"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
@@ -1164,7 +1164,7 @@ type FlexibleLoanRepayHistoryItem struct {
|
||||
CollateralCoin currency.Code `json:"collateralCoin"`
|
||||
CollateralReturn float64 `json:"collateralReturn,string"`
|
||||
RepayStatus string `json:"repayStatus"`
|
||||
RepayTime binanceTime `json:"repayTime"`
|
||||
RepayTime types.Time `json:"repayTime"`
|
||||
}
|
||||
|
||||
// FlexibleLoanRepayHistory stores flexible loan repayment history
|
||||
@@ -1191,7 +1191,7 @@ type FlexibleLoanLTVAdjustmentHistoryItem struct {
|
||||
CollateralAmount float64 `json:"collateralAmount,string"`
|
||||
PreviousLTV float64 `json:"preLTV,string"`
|
||||
AfterLTV float64 `json:"afterLTV,string"`
|
||||
AdjustTime binanceTime `json:"adjustTime"`
|
||||
AdjustTime types.Time `json:"adjustTime"`
|
||||
}
|
||||
|
||||
// FlexibleLoanLTVAdjustmentHistory stores flexible loan LTV adjustment history
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/types"
|
||||
)
|
||||
|
||||
// Response holds basic binance api response data
|
||||
@@ -15,32 +16,32 @@ type Response struct {
|
||||
|
||||
// FuturesPublicTradesData stores recent public trades for futures
|
||||
type FuturesPublicTradesData struct {
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Qty float64 `json:"qty,string"`
|
||||
QuoteQty float64 `json:"quoteQty,string"`
|
||||
Time binanceTime `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Qty float64 `json:"qty,string"`
|
||||
QuoteQty float64 `json:"quoteQty,string"`
|
||||
Time types.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
}
|
||||
|
||||
// CompressedTradesData stores futures trades data in a compressed format
|
||||
type CompressedTradesData struct {
|
||||
TradeID int64 `json:"a"`
|
||||
Price float64 `json:"p"`
|
||||
Quantity float64 `json:"q"`
|
||||
FirstTradeID int64 `json:"f"`
|
||||
LastTradeID int64 `json:"l"`
|
||||
Timestamp binanceTime `json:"t"`
|
||||
BuyerMaker bool `json:"b"`
|
||||
TradeID int64 `json:"a"`
|
||||
Price float64 `json:"p"`
|
||||
Quantity float64 `json:"q"`
|
||||
FirstTradeID int64 `json:"f"`
|
||||
LastTradeID int64 `json:"l"`
|
||||
Timestamp types.Time `json:"t"`
|
||||
BuyerMaker bool `json:"b"`
|
||||
}
|
||||
|
||||
// MarkPriceData stores mark price data for futures
|
||||
type MarkPriceData struct {
|
||||
Symbol string `json:"symbol"`
|
||||
MarkPrice float64 `json:"markPrice"`
|
||||
LastFundingRate float64 `json:"lastFundingRate"`
|
||||
NextFundingTime int64 `json:"nextFundingTime"`
|
||||
Time binanceTime `json:"time"`
|
||||
Symbol string `json:"symbol"`
|
||||
MarkPrice float64 `json:"markPrice"`
|
||||
LastFundingRate float64 `json:"lastFundingRate"`
|
||||
NextFundingTime int64 `json:"nextFundingTime"`
|
||||
Time types.Time `json:"time"`
|
||||
}
|
||||
|
||||
// SymbolPriceTicker stores ticker price stats
|
||||
@@ -445,21 +446,21 @@ type GetPositionMarginChangeHistoryData struct {
|
||||
|
||||
// FuturesPositionInformation stores futures position info
|
||||
type FuturesPositionInformation struct {
|
||||
Symbol string `json:"symbol"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MarkPrice float64 `json:"markPrice,string"`
|
||||
UnRealizedProfit float64 `json:"unRealizedProfit,string"`
|
||||
LiquidationPrice float64 `json:"liquidationPrice,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
MaxQty float64 `json:"maxQty,string"`
|
||||
MarginType string `json:"marginType"`
|
||||
IsolatedMargin float64 `json:"isolatedMargin,string"`
|
||||
IsAutoAddMargin bool `json:"isAutoAddMargin,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
NotionalValue float64 `json:"notionalValue,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Symbol string `json:"symbol"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MarkPrice float64 `json:"markPrice,string"`
|
||||
UnRealizedProfit float64 `json:"unRealizedProfit,string"`
|
||||
LiquidationPrice float64 `json:"liquidationPrice,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
MaxQty float64 `json:"maxQty,string"`
|
||||
MarginType string `json:"marginType"`
|
||||
IsolatedMargin float64 `json:"isolatedMargin,string"`
|
||||
IsAutoAddMargin bool `json:"isAutoAddMargin,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
NotionalValue float64 `json:"notionalValue,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
}
|
||||
|
||||
// FuturesAccountTradeList stores account trade list data
|
||||
@@ -581,25 +582,25 @@ type UFuturesExchangeInfo struct {
|
||||
// UFuturesSymbolInfo contains details of a currency symbol
|
||||
// for a usdt margined future contract
|
||||
type UFuturesSymbolInfo struct {
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
ContractType string `json:"contractType"`
|
||||
DeliveryDate binanceTime `json:"deliveryDate"`
|
||||
OnboardDate binanceTime `json:"onboardDate"`
|
||||
Status string `json:"status"`
|
||||
MaintenanceMarginPercent float64 `json:"maintMarginPercent,string"`
|
||||
RequiredMarginPercent float64 `json:"requiredMarginPercent,string"`
|
||||
BaseAsset string `json:"baseAsset"`
|
||||
QuoteAsset string `json:"quoteAsset"`
|
||||
MarginAsset string `json:"marginAsset"`
|
||||
PricePrecision int64 `json:"pricePrecision"`
|
||||
QuantityPrecision int64 `json:"quantityPrecision"`
|
||||
BaseAssetPrecision int64 `json:"baseAssetPrecision"`
|
||||
QuotePrecision int64 `json:"quotePrecision"`
|
||||
UnderlyingType string `json:"underlyingType"`
|
||||
UnderlyingSubType []string `json:"underlyingSubType"`
|
||||
SettlePlan float64 `json:"settlePlan"`
|
||||
TriggerProtect float64 `json:"triggerProtect,string"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
ContractType string `json:"contractType"`
|
||||
DeliveryDate types.Time `json:"deliveryDate"`
|
||||
OnboardDate types.Time `json:"onboardDate"`
|
||||
Status string `json:"status"`
|
||||
MaintenanceMarginPercent float64 `json:"maintMarginPercent,string"`
|
||||
RequiredMarginPercent float64 `json:"requiredMarginPercent,string"`
|
||||
BaseAsset string `json:"baseAsset"`
|
||||
QuoteAsset string `json:"quoteAsset"`
|
||||
MarginAsset string `json:"marginAsset"`
|
||||
PricePrecision int64 `json:"pricePrecision"`
|
||||
QuantityPrecision int64 `json:"quantityPrecision"`
|
||||
BaseAssetPrecision int64 `json:"baseAssetPrecision"`
|
||||
QuotePrecision int64 `json:"quotePrecision"`
|
||||
UnderlyingType string `json:"underlyingType"`
|
||||
UnderlyingSubType []string `json:"underlyingSubType"`
|
||||
SettlePlan float64 `json:"settlePlan"`
|
||||
TriggerProtect float64 `json:"triggerProtect,string"`
|
||||
Filters []struct {
|
||||
FilterType string `json:"filterType"`
|
||||
MinPrice float64 `json:"minPrice,string"`
|
||||
@@ -644,24 +645,24 @@ type CExchangeInfo struct {
|
||||
MultiplierUp float64 `json:"multiplierUp,string"`
|
||||
MultiplierDecimal float64 `json:"multiplierDecimal,string"`
|
||||
} `json:"filters"`
|
||||
OrderTypes []string `json:"orderType"`
|
||||
TimeInForce []string `json:"timeInForce"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
ContractType string `json:"contractType"`
|
||||
DeliveryDate binanceTime `json:"deliveryDate"`
|
||||
OnboardDate binanceTime `json:"onboardDate"`
|
||||
ContractStatus string `json:"contractStatus"`
|
||||
ContractSize int64 `json:"contractSize"`
|
||||
QuoteAsset string `json:"quoteAsset"`
|
||||
BaseAsset string `json:"baseAsset"`
|
||||
MarginAsset string `json:"marginAsset"`
|
||||
PricePrecision int64 `json:"pricePrecision"`
|
||||
QuantityPrecision int64 `json:"quantityPrecision"`
|
||||
BaseAssetPrecision int64 `json:"baseAssetPrecision"`
|
||||
QuotePrecision int64 `json:"quotePrecision"`
|
||||
MaintMarginPercent float64 `json:"maintMarginPercent,string"`
|
||||
RequiredMarginPercent float64 `json:"requiredMarginPercent,string"`
|
||||
OrderTypes []string `json:"orderType"`
|
||||
TimeInForce []string `json:"timeInForce"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
ContractType string `json:"contractType"`
|
||||
DeliveryDate types.Time `json:"deliveryDate"`
|
||||
OnboardDate types.Time `json:"onboardDate"`
|
||||
ContractStatus string `json:"contractStatus"`
|
||||
ContractSize int64 `json:"contractSize"`
|
||||
QuoteAsset string `json:"quoteAsset"`
|
||||
BaseAsset string `json:"baseAsset"`
|
||||
MarginAsset string `json:"marginAsset"`
|
||||
PricePrecision int64 `json:"pricePrecision"`
|
||||
QuantityPrecision int64 `json:"quantityPrecision"`
|
||||
BaseAssetPrecision int64 `json:"baseAssetPrecision"`
|
||||
QuotePrecision int64 `json:"quotePrecision"`
|
||||
MaintMarginPercent float64 `json:"maintMarginPercent,string"`
|
||||
RequiredMarginPercent float64 `json:"requiredMarginPercent,string"`
|
||||
} `json:"symbols"`
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
||||
|
||||
@@ -2,40 +2,12 @@ package binance
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/types"
|
||||
)
|
||||
|
||||
// binanceTime provides an internal conversion helper
|
||||
type binanceTime time.Time
|
||||
|
||||
func (t *binanceTime) UnmarshalJSON(data []byte) error {
|
||||
var result interface{}
|
||||
if err := json.Unmarshal(data, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch v := result.(type) {
|
||||
case string:
|
||||
timestamp, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = binanceTime(time.UnixMilli(timestamp))
|
||||
case float64:
|
||||
*t = binanceTime(time.UnixMilli(int64(v)))
|
||||
default:
|
||||
return errors.New("invalid time format received")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Time returns a time.Time object
|
||||
func (t binanceTime) Time() time.Time {
|
||||
return time.Time(t)
|
||||
}
|
||||
|
||||
// timeString gets the time as Binance timestamp
|
||||
func timeString(t time.Time) string {
|
||||
return strconv.FormatInt(t.UnixMilli(), 10)
|
||||
@@ -45,7 +17,7 @@ func timeString(t time.Time) string {
|
||||
func (a *ExchangeInfo) UnmarshalJSON(data []byte) error {
|
||||
type Alias ExchangeInfo
|
||||
aux := &struct {
|
||||
Servertime binanceTime `json:"serverTime"`
|
||||
Servertime types.Time `json:"serverTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -61,7 +33,7 @@ func (a *ExchangeInfo) UnmarshalJSON(data []byte) error {
|
||||
func (a *AggregatedTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias AggregatedTrade
|
||||
aux := &struct {
|
||||
TimeStamp binanceTime `json:"T"`
|
||||
TimeStamp types.Time `json:"T"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -77,7 +49,7 @@ func (a *AggregatedTrade) UnmarshalJSON(data []byte) error {
|
||||
func (a *NewOrderResponse) UnmarshalJSON(data []byte) error {
|
||||
type Alias NewOrderResponse
|
||||
aux := &struct {
|
||||
TransactionTime binanceTime `json:"transactTime"`
|
||||
TransactionTime types.Time `json:"transactTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -95,8 +67,8 @@ func (a *NewOrderResponse) UnmarshalJSON(data []byte) error {
|
||||
func (a *TradeStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias TradeStream
|
||||
aux := &struct {
|
||||
TimeStamp binanceTime `json:"T"`
|
||||
EventTime binanceTime `json:"E"`
|
||||
TimeStamp types.Time `json:"T"`
|
||||
EventTime types.Time `json:"E"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -113,10 +85,10 @@ func (a *TradeStream) UnmarshalJSON(data []byte) error {
|
||||
func (a *KlineStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias KlineStream
|
||||
aux := &struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
EventTime types.Time `json:"E"`
|
||||
Kline struct {
|
||||
StartTime binanceTime `json:"t"`
|
||||
CloseTime binanceTime `json:"T"`
|
||||
StartTime types.Time `json:"t"`
|
||||
CloseTime types.Time `json:"T"`
|
||||
*KlineStreamData
|
||||
} `json:"k"`
|
||||
*Alias
|
||||
@@ -137,9 +109,9 @@ func (a *KlineStream) UnmarshalJSON(data []byte) error {
|
||||
func (a *TickerStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias TickerStream
|
||||
aux := &struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
OpenTime binanceTime `json:"O"`
|
||||
CloseTime binanceTime `json:"C"`
|
||||
EventTime types.Time `json:"E"`
|
||||
OpenTime types.Time `json:"O"`
|
||||
CloseTime types.Time `json:"C"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -157,8 +129,8 @@ func (a *TickerStream) UnmarshalJSON(data []byte) error {
|
||||
func (a *PriceChangeStats) UnmarshalJSON(data []byte) error {
|
||||
type Alias PriceChangeStats
|
||||
aux := &struct {
|
||||
OpenTime binanceTime `json:"openTime"`
|
||||
CloseTime binanceTime `json:"closeTime"`
|
||||
OpenTime types.Time `json:"openTime"`
|
||||
CloseTime types.Time `json:"closeTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -175,7 +147,7 @@ func (a *PriceChangeStats) UnmarshalJSON(data []byte) error {
|
||||
func (a *RecentTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias RecentTrade
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
Time types.Time `json:"time"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -191,7 +163,7 @@ func (a *RecentTrade) UnmarshalJSON(data []byte) error {
|
||||
func (a *HistoricalTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias HistoricalTrade
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
Time types.Time `json:"time"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -207,8 +179,8 @@ func (a *HistoricalTrade) UnmarshalJSON(data []byte) error {
|
||||
func (a *QueryOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias QueryOrderData
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -225,8 +197,8 @@ func (a *QueryOrderData) UnmarshalJSON(data []byte) error {
|
||||
func (a *FuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesOrderData
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -243,8 +215,8 @@ func (a *FuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
func (a *UFuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias UFuturesOrderData
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -261,8 +233,8 @@ func (a *UFuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
func (a *FuturesOrderGetData) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesOrderGetData
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -279,8 +251,8 @@ func (a *FuturesOrderGetData) UnmarshalJSON(data []byte) error {
|
||||
func (a *UOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias UOrderData
|
||||
aux := &struct {
|
||||
Time binanceTime `json:"time"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -297,7 +269,7 @@ func (a *UOrderData) UnmarshalJSON(data []byte) error {
|
||||
func (a *Account) UnmarshalJSON(data []byte) error {
|
||||
type Alias Account
|
||||
aux := &struct {
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -313,7 +285,7 @@ func (a *Account) UnmarshalJSON(data []byte) error {
|
||||
func (a *WebsocketDepthStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias WebsocketDepthStream
|
||||
aux := &struct {
|
||||
Timestamp binanceTime `json:"E"`
|
||||
Timestamp types.Time `json:"E"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -330,8 +302,8 @@ func (a *wsAccountPosition) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsAccountPosition
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
LastUpdated binanceTime `json:"u"`
|
||||
EventTime types.Time `json:"E"`
|
||||
LastUpdated types.Time `json:"u"`
|
||||
*WsAccountPositionData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
@@ -352,8 +324,8 @@ func (a *wsBalanceUpdate) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsBalanceUpdate
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
ClearTime binanceTime `json:"T"`
|
||||
EventTime types.Time `json:"E"`
|
||||
ClearTime types.Time `json:"T"`
|
||||
*WsBalanceUpdateData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
@@ -374,10 +346,10 @@ func (a *wsOrderUpdate) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsOrderUpdate
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
OrderCreationTime binanceTime `json:"O"`
|
||||
TransactionTime binanceTime `json:"T"`
|
||||
WorkingTime binanceTime `json:"W"`
|
||||
EventTime types.Time `json:"E"`
|
||||
OrderCreationTime types.Time `json:"O"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
WorkingTime types.Time `json:"W"`
|
||||
*WsOrderUpdateData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
@@ -400,8 +372,8 @@ func (a *wsListStatus) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsListStatus
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime binanceTime `json:"E"`
|
||||
TransactionTime binanceTime `json:"T"`
|
||||
EventTime types.Time `json:"E"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
*WsListStatusData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
@@ -422,7 +394,7 @@ func (a *FuturesAccountInformationPosition) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesAccountInformationPosition
|
||||
|
||||
aux := &struct {
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -442,7 +414,7 @@ func (a *FuturesAccountInformation) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesAccountInformation
|
||||
|
||||
aux := &struct {
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
|
||||
@@ -52,12 +52,12 @@ type OrderbookData struct {
|
||||
|
||||
// UPublicTradesData stores trade data
|
||||
type UPublicTradesData struct {
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Qty float64 `json:"qty,string"`
|
||||
QuoteQty float64 `json:"quoteQty,string"`
|
||||
Time binanceTime `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Qty float64 `json:"qty,string"`
|
||||
QuoteQty float64 `json:"quoteQty,string"`
|
||||
Time types.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
}
|
||||
|
||||
// UCompressedTradeData stores compressed trade data
|
||||
@@ -300,22 +300,22 @@ type UAsset struct {
|
||||
|
||||
// UPosition holds account position information
|
||||
type UPosition struct {
|
||||
Symbol string `json:"symbol"`
|
||||
InitialMargin float64 `json:"initialMargin,string"`
|
||||
MaintenanceMargin float64 `json:"maintMargin,string"`
|
||||
UnrealisedProfit float64 `json:"unrealizedProfit,string"`
|
||||
PositionInitialMargin float64 `json:"positionInitialMargin,string"`
|
||||
OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
Isolated bool `json:"isolated"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MaxNotional float64 `json:"maxNotional,string"`
|
||||
BidNotional float64 `json:"bidNotional,string"`
|
||||
AskNotional float64 `json:"askNotional,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Symbol string `json:"symbol"`
|
||||
InitialMargin float64 `json:"initialMargin,string"`
|
||||
MaintenanceMargin float64 `json:"maintMargin,string"`
|
||||
UnrealisedProfit float64 `json:"unrealizedProfit,string"`
|
||||
PositionInitialMargin float64 `json:"positionInitialMargin,string"`
|
||||
OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
Isolated bool `json:"isolated"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MaxNotional float64 `json:"maxNotional,string"`
|
||||
BidNotional float64 `json:"bidNotional,string"`
|
||||
AskNotional float64 `json:"askNotional,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
}
|
||||
|
||||
// UChangeInitialLeverage stores leverage change data
|
||||
@@ -343,21 +343,21 @@ type UPositionMarginChangeHistoryData struct {
|
||||
|
||||
// UPositionInformationV2 stores positions data
|
||||
type UPositionInformationV2 struct {
|
||||
Symbol string `json:"symbol"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MarkPrice float64 `json:"markPrice,string"`
|
||||
UnrealizedProfit float64 `json:"unrealizedProfit,string"`
|
||||
LiquidationPrice float64 `json:"liquidationPrice,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
MaxNotionalValue float64 `json:"maxNotionalValue,string"`
|
||||
MarginType string `json:"marginType"`
|
||||
IsAutoAddMargin bool `json:"isAutoAddMargin,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Notional float64 `json:"notional,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
IsolatedMargin float64 `json:"isolatedMargin,string"`
|
||||
UpdateTime binanceTime `json:"updateTime"`
|
||||
Symbol string `json:"symbol"`
|
||||
PositionAmount float64 `json:"positionAmt,string"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MarkPrice float64 `json:"markPrice,string"`
|
||||
UnrealizedProfit float64 `json:"unrealizedProfit,string"`
|
||||
LiquidationPrice float64 `json:"liquidationPrice,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
MaxNotionalValue float64 `json:"maxNotionalValue,string"`
|
||||
MarginType string `json:"marginType"`
|
||||
IsAutoAddMargin bool `json:"isAutoAddMargin,string"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Notional float64 `json:"notional,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
IsolatedMargin float64 `json:"isolatedMargin,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
}
|
||||
|
||||
// UAccountTradeHistory stores trade data for the users account
|
||||
|
||||
Reference in New Issue
Block a user