mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
binance: use types.Time instead of time.Time (#1828)
* binance: use types.Time instead of time.Time Signed-off-by: Ye Sijun <junnplus@gmail.com> * binance: remove type_convert.go Signed-off-by: Ye Sijun <junnplus@gmail.com> --------- Signed-off-by: Ye Sijun <junnplus@gmail.com>
This commit is contained in:
@@ -277,10 +277,10 @@ func (b *Binance) GetAggregatedTrades(ctx context.Context, arg *AggregatedTradeR
|
||||
params.Set("fromId", strconv.FormatInt(arg.FromID, 10))
|
||||
}
|
||||
if !arg.StartTime.IsZero() {
|
||||
params.Set("startTime", timeString(arg.StartTime))
|
||||
params.Set("startTime", strconv.FormatInt(arg.StartTime.UnixMilli(), 10))
|
||||
}
|
||||
if !arg.EndTime.IsZero() {
|
||||
params.Set("endTime", timeString(arg.EndTime))
|
||||
params.Set("endTime", strconv.FormatInt(arg.EndTime.UnixMilli(), 10))
|
||||
}
|
||||
|
||||
// startTime and endTime are set and time between startTime and endTime is more than 1 hour
|
||||
@@ -327,8 +327,8 @@ func (b *Binance) batchAggregateTrades(ctx context.Context, arg *AggregatedTrade
|
||||
// All requests returned empty
|
||||
return nil, nil
|
||||
}
|
||||
params.Set("startTime", timeString(start))
|
||||
params.Set("endTime", timeString(start.Add(increment)))
|
||||
params.Set("startTime", strconv.FormatInt(start.UnixMilli(), 10))
|
||||
params.Set("endTime", strconv.FormatInt(start.Add(increment).UnixMilli(), 10))
|
||||
path := aggregatedTrades + "?" + params.Encode()
|
||||
err := b.SendHTTPRequest(ctx,
|
||||
exchange.RestSpotSupplementary, path, spotDefaultRate, &resp)
|
||||
@@ -360,7 +360,7 @@ func (b *Binance) batchAggregateTrades(ctx context.Context, arg *AggregatedTrade
|
||||
if !arg.EndTime.IsZero() {
|
||||
// get index for truncating to end time
|
||||
lastIndex = sort.Search(len(additionalTrades), func(i int) bool {
|
||||
return arg.EndTime.Before(additionalTrades[i].TimeStamp)
|
||||
return arg.EndTime.Before(additionalTrades[i].TimeStamp.Time())
|
||||
})
|
||||
}
|
||||
// don't include the first as the request was inclusive from last ATradeID
|
||||
@@ -399,10 +399,10 @@ func (b *Binance) GetSpotKline(ctx context.Context, arg *KlinesRequestParams) ([
|
||||
params.Set("limit", strconv.FormatUint(arg.Limit, 10))
|
||||
}
|
||||
if !arg.StartTime.IsZero() {
|
||||
params.Set("startTime", timeString(arg.StartTime))
|
||||
params.Set("startTime", strconv.FormatInt(arg.StartTime.UnixMilli(), 10))
|
||||
}
|
||||
if !arg.EndTime.IsZero() {
|
||||
params.Set("endTime", timeString(arg.EndTime))
|
||||
params.Set("endTime", strconv.FormatInt(arg.EndTime.UnixMilli(), 10))
|
||||
}
|
||||
|
||||
path := candleStick + "?" + params.Encode()
|
||||
@@ -807,7 +807,8 @@ func (b *Binance) SendHTTPRequest(ctx context.Context, ePath exchange.URL, path
|
||||
Result: result,
|
||||
Verbose: b.Verbose,
|
||||
HTTPDebugging: b.HTTPDebugging,
|
||||
HTTPRecording: b.HTTPRecording}
|
||||
HTTPRecording: b.HTTPRecording,
|
||||
}
|
||||
|
||||
return b.SendPayload(ctx, f, func() (*request.Item, error) {
|
||||
return item, nil
|
||||
@@ -836,7 +837,8 @@ func (b *Binance) SendAPIKeyHTTPRequest(ctx context.Context, ePath exchange.URL,
|
||||
Result: result,
|
||||
Verbose: b.Verbose,
|
||||
HTTPDebugging: b.HTTPDebugging,
|
||||
HTTPRecording: b.HTTPRecording}
|
||||
HTTPRecording: b.HTTPRecording,
|
||||
}
|
||||
|
||||
return b.SendPayload(ctx, f, func() (*request.Item, error) {
|
||||
return item, nil
|
||||
@@ -887,7 +889,8 @@ func (b *Binance) SendAuthHTTPRequest(ctx context.Context, ePath exchange.URL, m
|
||||
Result: &interim,
|
||||
Verbose: b.Verbose,
|
||||
HTTPDebugging: b.HTTPDebugging,
|
||||
HTTPRecording: b.HTTPRecording}, nil
|
||||
HTTPRecording: b.HTTPRecording,
|
||||
}, nil
|
||||
}, request.AuthenticatedRequest)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1084,9 +1084,9 @@ func TestGetExchangeInfo(t *testing.T) {
|
||||
require.NoError(t, err, "GetExchangeInfo must not error")
|
||||
if mockTests {
|
||||
exp := time.Date(2024, 5, 10, 6, 8, 1, int(707*time.Millisecond), time.UTC)
|
||||
assert.True(t, info.ServerTime.Equal(exp), "expected %v received %v", exp.UTC(), info.ServerTime.UTC())
|
||||
assert.True(t, info.ServerTime.Time().Equal(exp), "expected %v received %v", exp.UTC(), info.ServerTime.Time().UTC())
|
||||
} else {
|
||||
assert.WithinRange(t, info.ServerTime, time.Now().Add(-24*time.Hour), time.Now().Add(24*time.Hour), "ServerTime should be within a day of now")
|
||||
assert.WithinRange(t, info.ServerTime.Time(), time.Now().Add(-24*time.Hour), time.Now().Add(24*time.Hour), "ServerTime should be within a day of now")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,7 +1115,6 @@ func TestGetOrderBook(t *testing.T) {
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Limit: 1000,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Error("Binance GetOrderBook() error", err)
|
||||
}
|
||||
@@ -1128,7 +1127,6 @@ func TestGetMostRecentTrades(t *testing.T) {
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Limit: 15,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Error("Binance GetMostRecentTrades() error", err)
|
||||
}
|
||||
@@ -1267,7 +1265,7 @@ func TestAllOrders(t *testing.T) {
|
||||
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var feeBuilder = setFeeBuilder()
|
||||
feeBuilder := setFeeBuilder()
|
||||
_, err := b.GetFeeByType(context.Background(), feeBuilder)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -1286,7 +1284,7 @@ func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
|
||||
func TestGetFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var feeBuilder = setFeeBuilder()
|
||||
feeBuilder := setFeeBuilder()
|
||||
|
||||
if sharedtestvalues.AreAPICredentialsSet(b) && mockTests {
|
||||
// CryptocurrencyTradeFee Basic
|
||||
@@ -1364,7 +1362,7 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
var getOrdersRequest = order.MultiOrderRequest{
|
||||
getOrdersRequest := order.MultiOrderRequest{
|
||||
Type: order.AnyType,
|
||||
Pairs: currency.Pairs{pair},
|
||||
AssetType: asset.Spot,
|
||||
@@ -1385,7 +1383,7 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
func TestGetOrderHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var getOrdersRequest = order.MultiOrderRequest{
|
||||
getOrdersRequest := order.MultiOrderRequest{
|
||||
Type: order.AnyType,
|
||||
AssetType: asset.Spot,
|
||||
Side: order.AnySide,
|
||||
@@ -1398,7 +1396,8 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
|
||||
getOrdersRequest.Pairs = []currency.Pair{
|
||||
currency.NewPair(currency.LTC,
|
||||
currency.BTC)}
|
||||
currency.BTC),
|
||||
}
|
||||
|
||||
_, err = b.GetOrderHistory(context.Background(), &getOrdersRequest)
|
||||
switch {
|
||||
@@ -1560,8 +1559,8 @@ func TestGetAggregatedTradesBatched(t *testing.T) {
|
||||
t.Errorf("GetAggregatedTradesBatched() expected %v entries, got %v", tt.numExpected, len(result))
|
||||
}
|
||||
lastTradeTime := result[len(result)-1].TimeStamp
|
||||
if !lastTradeTime.Equal(tt.lastExpected) {
|
||||
t.Errorf("last trade expected %v, got %v", tt.lastExpected.UTC(), lastTradeTime.UTC())
|
||||
if !lastTradeTime.Time().Equal(tt.lastExpected) {
|
||||
t.Errorf("last trade expected %v, got %v", tt.lastExpected.UTC(), lastTradeTime.Time().UTC())
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1623,7 +1622,7 @@ func TestSubmitOrder(t *testing.T) {
|
||||
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
|
||||
}
|
||||
|
||||
var orderSubmission = &order.Submit{
|
||||
orderSubmission := &order.Submit{
|
||||
Exchange: b.Name,
|
||||
Pair: currency.Pair{
|
||||
Delimiter: "_",
|
||||
@@ -1655,7 +1654,7 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
if !mockTests {
|
||||
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
|
||||
}
|
||||
var orderCancellation = &order.Cancel{
|
||||
orderCancellation := &order.Cancel{
|
||||
OrderID: "1",
|
||||
WalletAddress: core.BitcoinDonationAddress,
|
||||
AccountID: "1",
|
||||
@@ -1680,7 +1679,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
if !mockTests {
|
||||
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
|
||||
}
|
||||
var orderCancellation = &order.Cancel{
|
||||
orderCancellation := &order.Cancel{
|
||||
OrderID: "1",
|
||||
WalletAddress: core.BitcoinDonationAddress,
|
||||
AccountID: "1",
|
||||
|
||||
@@ -38,10 +38,10 @@ const (
|
||||
|
||||
// ExchangeInfo holds the full exchange information type
|
||||
type ExchangeInfo struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Timezone string `json:"timezone"`
|
||||
ServerTime time.Time `json:"serverTime"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Timezone string `json:"timezone"`
|
||||
ServerTime types.Time `json:"serverTime"`
|
||||
RateLimits []*struct {
|
||||
RateLimitType string `json:"rateLimitType"`
|
||||
Interval string `json:"interval"`
|
||||
@@ -163,7 +163,7 @@ type DepthUpdateParams []struct {
|
||||
// WebsocketDepthStream is the difference for the update depth stream
|
||||
type WebsocketDepthStream struct {
|
||||
Event string `json:"e"`
|
||||
Timestamp time.Time `json:"E"`
|
||||
Timestamp types.Time `json:"E"`
|
||||
Pair string `json:"s"`
|
||||
FirstUpdateID int64 `json:"U"`
|
||||
LastUpdateID int64 `json:"u"`
|
||||
@@ -179,25 +179,25 @@ type RecentTradeRequestParams struct {
|
||||
|
||||
// RecentTrade holds recent trade data
|
||||
type RecentTrade struct {
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Quantity float64 `json:"qty,string"`
|
||||
Time time.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
IsBestMatch bool `json:"isBestMatch"`
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Quantity float64 `json:"qty,string"`
|
||||
Time types.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
IsBestMatch bool `json:"isBestMatch"`
|
||||
}
|
||||
|
||||
// TradeStream holds the trade stream data
|
||||
type TradeStream struct {
|
||||
EventType string `json:"e"`
|
||||
EventTime time.Time `json:"E"`
|
||||
EventTime types.Time `json:"E"`
|
||||
Symbol string `json:"s"`
|
||||
TradeID int64 `json:"t"`
|
||||
Price types.Number `json:"p"`
|
||||
Quantity types.Number `json:"q"`
|
||||
BuyerOrderID int64 `json:"b"`
|
||||
SellerOrderID int64 `json:"a"`
|
||||
TimeStamp time.Time `json:"T"`
|
||||
TimeStamp types.Time `json:"T"`
|
||||
IsBuyerMaker bool `json:"m"`
|
||||
BestMatchPrice bool `json:"M"`
|
||||
}
|
||||
@@ -205,15 +205,15 @@ type TradeStream struct {
|
||||
// KlineStream holds the kline stream data
|
||||
type KlineStream struct {
|
||||
EventType string `json:"e"`
|
||||
EventTime time.Time `json:"E"`
|
||||
EventTime types.Time `json:"E"`
|
||||
Symbol string `json:"s"`
|
||||
Kline KlineStreamData `json:"k"`
|
||||
}
|
||||
|
||||
// KlineStreamData defines kline streaming data
|
||||
type KlineStreamData struct {
|
||||
StartTime time.Time `json:"t"`
|
||||
CloseTime time.Time `json:"T"`
|
||||
StartTime types.Time `json:"t"`
|
||||
CloseTime types.Time `json:"T"`
|
||||
Symbol string `json:"s"`
|
||||
Interval string `json:"i"`
|
||||
FirstTradeID int64 `json:"f"`
|
||||
@@ -233,7 +233,7 @@ type KlineStreamData struct {
|
||||
// TickerStream holds the ticker stream data
|
||||
type TickerStream struct {
|
||||
EventType string `json:"e"`
|
||||
EventTime time.Time `json:"E"`
|
||||
EventTime types.Time `json:"E"`
|
||||
Symbol string `json:"s"`
|
||||
PriceChange types.Number `json:"p"`
|
||||
PriceChangePercent types.Number `json:"P"`
|
||||
@@ -250,8 +250,8 @@ type TickerStream struct {
|
||||
LowPrice types.Number `json:"l"`
|
||||
TotalTradedVolume types.Number `json:"v"`
|
||||
TotalTradedQuoteVolume types.Number `json:"q"`
|
||||
OpenTime time.Time `json:"O"`
|
||||
CloseTime time.Time `json:"C"`
|
||||
OpenTime types.Time `json:"O"`
|
||||
CloseTime types.Time `json:"C"`
|
||||
FirstTradeID int64 `json:"F"`
|
||||
LastTradeID int64 `json:"L"`
|
||||
NumberOfTrades int64 `json:"n"`
|
||||
@@ -259,13 +259,13 @@ type TickerStream struct {
|
||||
|
||||
// HistoricalTrade holds recent trade data
|
||||
type HistoricalTrade struct {
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Quantity float64 `json:"qty,string"`
|
||||
QuoteQuantity float64 `json:"quoteQty,string"`
|
||||
Time time.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
IsBestMatch bool `json:"isBestMatch"`
|
||||
ID int64 `json:"id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Quantity float64 `json:"qty,string"`
|
||||
QuoteQuantity float64 `json:"quoteQty,string"`
|
||||
Time types.Time `json:"time"`
|
||||
IsBuyerMaker bool `json:"isBuyerMaker"`
|
||||
IsBestMatch bool `json:"isBestMatch"`
|
||||
}
|
||||
|
||||
// AggregatedTradeRequestParams holds request params
|
||||
@@ -282,14 +282,14 @@ type AggregatedTradeRequestParams struct {
|
||||
|
||||
// AggregatedTrade holds aggregated trade information
|
||||
type AggregatedTrade struct {
|
||||
ATradeID int64 `json:"a"`
|
||||
Price float64 `json:"p,string"`
|
||||
Quantity float64 `json:"q,string"`
|
||||
FirstTradeID int64 `json:"f"`
|
||||
LastTradeID int64 `json:"l"`
|
||||
TimeStamp time.Time `json:"T"`
|
||||
IsBuyerMaker bool `json:"m"`
|
||||
BestMatchPrice bool `json:"M"`
|
||||
ATradeID int64 `json:"a"`
|
||||
Price float64 `json:"p,string"`
|
||||
Quantity float64 `json:"q,string"`
|
||||
FirstTradeID int64 `json:"f"`
|
||||
LastTradeID int64 `json:"l"`
|
||||
TimeStamp types.Time `json:"T"`
|
||||
IsBuyerMaker bool `json:"m"`
|
||||
BestMatchPrice bool `json:"M"`
|
||||
}
|
||||
|
||||
// IndexMarkPrice stores data for index and mark prices
|
||||
@@ -343,8 +343,8 @@ type PriceChangeStats struct {
|
||||
LowPrice types.Number `json:"lowPrice"`
|
||||
Volume types.Number `json:"volume"`
|
||||
QuoteVolume types.Number `json:"quoteVolume"`
|
||||
OpenTime time.Time `json:"openTime"`
|
||||
CloseTime time.Time `json:"closeTime"`
|
||||
OpenTime types.Time `json:"openTime"`
|
||||
CloseTime types.Time `json:"closeTime"`
|
||||
FirstID int64 `json:"firstId"`
|
||||
LastID int64 `json:"lastId"`
|
||||
Count int64 `json:"count"`
|
||||
@@ -389,15 +389,15 @@ type NewOrderRequest struct {
|
||||
|
||||
// NewOrderResponse is the return structured response from the exchange
|
||||
type NewOrderResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Symbol string `json:"symbol"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
TransactionTime time.Time `json:"transactTime"`
|
||||
Price float64 `json:"price,string"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Symbol string `json:"symbol"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
TransactionTime types.Time `json:"transactTime"`
|
||||
Price float64 `json:"price,string"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
// The cumulative amount of the quote that has been spent (with a BUY order) or received (with a SELL order).
|
||||
CumulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
|
||||
Status string `json:"status"`
|
||||
@@ -422,26 +422,26 @@ type CancelOrderResponse struct {
|
||||
|
||||
// QueryOrderData holds query order data
|
||||
type QueryOrderData struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Symbol string `json:"symbol"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
Price float64 `json:"price,string"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
Status string `json:"status"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
Type string `json:"type"`
|
||||
Side string `json:"side"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
IcebergQty float64 `json:"icebergQty,string"`
|
||||
Time time.Time `json:"time"`
|
||||
IsWorking bool `json:"isWorking"`
|
||||
CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
|
||||
OrderListID int64 `json:"orderListId"`
|
||||
OrigQuoteOrderQty float64 `json:"origQuoteOrderQty,string"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Symbol string `json:"symbol"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
Price float64 `json:"price,string"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
Status string `json:"status"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
Type string `json:"type"`
|
||||
Side string `json:"side"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
IcebergQty float64 `json:"icebergQty,string"`
|
||||
Time types.Time `json:"time"`
|
||||
IsWorking bool `json:"isWorking"`
|
||||
CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
|
||||
OrderListID int64 `json:"orderListId"`
|
||||
OrigQuoteOrderQty float64 `json:"origQuoteOrderQty,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
}
|
||||
|
||||
// Balance holds query order data
|
||||
@@ -453,15 +453,15 @@ type Balance struct {
|
||||
|
||||
// Account holds the account data
|
||||
type Account struct {
|
||||
MakerCommission int `json:"makerCommission"`
|
||||
TakerCommission int `json:"takerCommission"`
|
||||
BuyerCommission int `json:"buyerCommission"`
|
||||
SellerCommission int `json:"sellerCommission"`
|
||||
CanTrade bool `json:"canTrade"`
|
||||
CanWithdraw bool `json:"canWithdraw"`
|
||||
CanDeposit bool `json:"canDeposit"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
Balances []Balance `json:"balances"`
|
||||
MakerCommission int `json:"makerCommission"`
|
||||
TakerCommission int `json:"takerCommission"`
|
||||
BuyerCommission int `json:"buyerCommission"`
|
||||
SellerCommission int `json:"sellerCommission"`
|
||||
CanTrade bool `json:"canTrade"`
|
||||
CanWithdraw bool `json:"canWithdraw"`
|
||||
CanDeposit bool `json:"canDeposit"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
Balances []Balance `json:"balances"`
|
||||
}
|
||||
|
||||
// MarginAccount holds the margin account data
|
||||
@@ -772,11 +772,6 @@ type WsAccountInfoData struct {
|
||||
} `json:"B"`
|
||||
}
|
||||
|
||||
type wsAccountPosition struct {
|
||||
Stream string `json:"stream"`
|
||||
Data WsAccountPositionData `json:"data"`
|
||||
}
|
||||
|
||||
// WsAccountPositionData defines websocket account position data
|
||||
type WsAccountPositionData struct {
|
||||
Currencies []struct {
|
||||
@@ -784,89 +779,74 @@ type WsAccountPositionData struct {
|
||||
Available float64 `json:"f,string"`
|
||||
Locked float64 `json:"l,string"`
|
||||
} `json:"B"`
|
||||
EventTime time.Time `json:"E"`
|
||||
LastUpdated time.Time `json:"u"`
|
||||
EventType string `json:"e"`
|
||||
}
|
||||
|
||||
type wsBalanceUpdate struct {
|
||||
Stream string `json:"stream"`
|
||||
Data WsBalanceUpdateData `json:"data"`
|
||||
EventTime types.Time `json:"E"`
|
||||
LastUpdated types.Time `json:"u"`
|
||||
EventType string `json:"e"`
|
||||
}
|
||||
|
||||
// WsBalanceUpdateData defines websocket account balance data
|
||||
type WsBalanceUpdateData struct {
|
||||
EventTime time.Time `json:"E"`
|
||||
ClearTime time.Time `json:"T"`
|
||||
BalanceDelta float64 `json:"d,string"`
|
||||
Asset string `json:"a"`
|
||||
EventType string `json:"e"`
|
||||
}
|
||||
|
||||
type wsOrderUpdate struct {
|
||||
Stream string `json:"stream"`
|
||||
Data WsOrderUpdateData `json:"data"`
|
||||
EventTime types.Time `json:"E"`
|
||||
ClearTime types.Time `json:"T"`
|
||||
BalanceDelta float64 `json:"d,string"`
|
||||
Asset string `json:"a"`
|
||||
EventType string `json:"e"`
|
||||
}
|
||||
|
||||
// WsOrderUpdateData defines websocket account order update data
|
||||
type WsOrderUpdateData struct {
|
||||
EventType string `json:"e"`
|
||||
EventTime time.Time `json:"E"`
|
||||
Symbol string `json:"s"`
|
||||
ClientOrderID string `json:"c"`
|
||||
Side string `json:"S"`
|
||||
OrderType string `json:"o"`
|
||||
TimeInForce string `json:"f"`
|
||||
Quantity float64 `json:"q,string"`
|
||||
Price float64 `json:"p,string"`
|
||||
StopPrice float64 `json:"P,string"`
|
||||
IcebergQuantity float64 `json:"F,string"`
|
||||
OrderListID int64 `json:"g"`
|
||||
CancelledClientOrderID string `json:"C"`
|
||||
CurrentExecutionType string `json:"x"`
|
||||
OrderStatus string `json:"X"`
|
||||
RejectionReason string `json:"r"`
|
||||
OrderID int64 `json:"i"`
|
||||
LastExecutedQuantity float64 `json:"l,string"`
|
||||
CumulativeFilledQuantity float64 `json:"z,string"`
|
||||
LastExecutedPrice float64 `json:"L,string"`
|
||||
Commission float64 `json:"n,string"`
|
||||
CommissionAsset string `json:"N"`
|
||||
TransactionTime time.Time `json:"T"`
|
||||
TradeID int64 `json:"t"`
|
||||
Ignored int64 `json:"I"` // Must be ignored explicitly, otherwise it overwrites 'i'.
|
||||
IsOnOrderBook bool `json:"w"`
|
||||
IsMaker bool `json:"m"`
|
||||
Ignored2 bool `json:"M"` // See the comment for "I".
|
||||
OrderCreationTime time.Time `json:"O"`
|
||||
WorkingTime time.Time `json:"W"`
|
||||
CumulativeQuoteTransactedQuantity float64 `json:"Z,string"`
|
||||
LastQuoteAssetTransactedQuantity float64 `json:"Y,string"`
|
||||
QuoteOrderQuantity float64 `json:"Q,string"`
|
||||
}
|
||||
|
||||
type wsListStatus struct {
|
||||
Stream string `json:"stream"`
|
||||
Data WsListStatusData `json:"data"`
|
||||
EventType string `json:"e"`
|
||||
EventTime types.Time `json:"E"`
|
||||
Symbol string `json:"s"`
|
||||
ClientOrderID string `json:"c"`
|
||||
Side string `json:"S"`
|
||||
OrderType string `json:"o"`
|
||||
TimeInForce string `json:"f"`
|
||||
Quantity float64 `json:"q,string"`
|
||||
Price float64 `json:"p,string"`
|
||||
StopPrice float64 `json:"P,string"`
|
||||
IcebergQuantity float64 `json:"F,string"`
|
||||
OrderListID int64 `json:"g"`
|
||||
CancelledClientOrderID string `json:"C"`
|
||||
CurrentExecutionType string `json:"x"`
|
||||
OrderStatus string `json:"X"`
|
||||
RejectionReason string `json:"r"`
|
||||
OrderID int64 `json:"i"`
|
||||
LastExecutedQuantity float64 `json:"l,string"`
|
||||
CumulativeFilledQuantity float64 `json:"z,string"`
|
||||
LastExecutedPrice float64 `json:"L,string"`
|
||||
Commission float64 `json:"n,string"`
|
||||
CommissionAsset string `json:"N"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
TradeID int64 `json:"t"`
|
||||
Ignored int64 `json:"I"` // Must be ignored explicitly, otherwise it overwrites 'i'.
|
||||
IsOnOrderBook bool `json:"w"`
|
||||
IsMaker bool `json:"m"`
|
||||
Ignored2 bool `json:"M"` // See the comment for "I".
|
||||
OrderCreationTime types.Time `json:"O"`
|
||||
WorkingTime types.Time `json:"W"`
|
||||
CumulativeQuoteTransactedQuantity float64 `json:"Z,string"`
|
||||
LastQuoteAssetTransactedQuantity float64 `json:"Y,string"`
|
||||
QuoteOrderQuantity float64 `json:"Q,string"`
|
||||
}
|
||||
|
||||
// WsListStatusData defines websocket account listing status data
|
||||
type WsListStatusData struct {
|
||||
ListClientOrderID string `json:"C"`
|
||||
EventTime time.Time `json:"E"`
|
||||
ListOrderStatus string `json:"L"`
|
||||
ListClientOrderID string `json:"C"`
|
||||
EventTime types.Time `json:"E"`
|
||||
ListOrderStatus string `json:"L"`
|
||||
Orders []struct {
|
||||
ClientOrderID string `json:"c"`
|
||||
OrderID int64 `json:"i"`
|
||||
Symbol string `json:"s"`
|
||||
} `json:"O"`
|
||||
TransactionTime time.Time `json:"T"`
|
||||
ContingencyType string `json:"c"`
|
||||
EventType string `json:"e"`
|
||||
OrderListID int64 `json:"g"`
|
||||
ListStatusType string `json:"l"`
|
||||
RejectionReason string `json:"r"`
|
||||
Symbol string `json:"s"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
ContingencyType string `json:"c"`
|
||||
EventType string `json:"e"`
|
||||
OrderListID int64 `json:"g"`
|
||||
ListStatusType string `json:"l"`
|
||||
RejectionReason string `json:"r"`
|
||||
Symbol string `json:"s"`
|
||||
}
|
||||
|
||||
// WsPayload defines the payload through the websocket connection
|
||||
|
||||
@@ -237,8 +237,8 @@ func (b *Binance) UKlineData(ctx context.Context, symbol currency.Pair, interval
|
||||
if startTime.After(endTime) {
|
||||
return nil, errors.New("startTime cannot be after endTime")
|
||||
}
|
||||
params.Set("startTime", timeString(startTime))
|
||||
params.Set("endTime", timeString(endTime))
|
||||
params.Set("startTime", strconv.FormatInt(startTime.UnixMilli(), 10))
|
||||
params.Set("endTime", strconv.FormatInt(endTime.UnixMilli(), 10))
|
||||
}
|
||||
rateBudget := uFuturesDefaultRate
|
||||
switch {
|
||||
|
||||
@@ -185,8 +185,8 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
if err == nil {
|
||||
switch event {
|
||||
case "outboundAccountPosition":
|
||||
var data wsAccountPosition
|
||||
err = json.Unmarshal(respRaw, &data)
|
||||
var data WsAccountPositionData
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v - Could not convert to outboundAccountPosition structure %s",
|
||||
b.Name,
|
||||
@@ -195,8 +195,8 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- data
|
||||
return nil
|
||||
case "balanceUpdate":
|
||||
var data wsBalanceUpdate
|
||||
err = json.Unmarshal(respRaw, &data)
|
||||
var data WsBalanceUpdateData
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v - Could not convert to balanceUpdate structure %s",
|
||||
b.Name,
|
||||
@@ -205,31 +205,31 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- data
|
||||
return nil
|
||||
case "executionReport":
|
||||
var data wsOrderUpdate
|
||||
err = json.Unmarshal(respRaw, &data)
|
||||
var data WsOrderUpdateData
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v - Could not convert to executionReport structure %s",
|
||||
b.Name,
|
||||
err)
|
||||
}
|
||||
avgPrice := 0.0
|
||||
if data.Data.CumulativeFilledQuantity != 0 {
|
||||
avgPrice = data.Data.CumulativeQuoteTransactedQuantity / data.Data.CumulativeFilledQuantity
|
||||
if data.CumulativeFilledQuantity != 0 {
|
||||
avgPrice = data.CumulativeQuoteTransactedQuantity / data.CumulativeFilledQuantity
|
||||
}
|
||||
remainingAmount := data.Data.Quantity - data.Data.CumulativeFilledQuantity
|
||||
remainingAmount := data.Quantity - data.CumulativeFilledQuantity
|
||||
var pair currency.Pair
|
||||
var assetType asset.Item
|
||||
pair, assetType, err = b.GetRequestFormattedPairAndAssetType(data.Data.Symbol)
|
||||
pair, assetType, err = b.GetRequestFormattedPairAndAssetType(data.Symbol)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var feeAsset currency.Code
|
||||
if data.Data.CommissionAsset != "" {
|
||||
feeAsset = currency.NewCode(data.Data.CommissionAsset)
|
||||
if data.CommissionAsset != "" {
|
||||
feeAsset = currency.NewCode(data.CommissionAsset)
|
||||
}
|
||||
orderID := strconv.FormatInt(data.Data.OrderID, 10)
|
||||
orderID := strconv.FormatInt(data.OrderID, 10)
|
||||
var orderStatus order.Status
|
||||
orderStatus, err = stringToOrderStatus(data.Data.OrderStatus)
|
||||
orderStatus, err = stringToOrderStatus(data.OrderStatus)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- order.ClassificationError{
|
||||
Exchange: b.Name,
|
||||
@@ -237,12 +237,12 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
clientOrderID := data.Data.ClientOrderID
|
||||
clientOrderID := data.ClientOrderID
|
||||
if orderStatus == order.Cancelled {
|
||||
clientOrderID = data.Data.CancelledClientOrderID
|
||||
clientOrderID = data.CancelledClientOrderID
|
||||
}
|
||||
var orderType order.Type
|
||||
orderType, err = order.StringToOrderType(data.Data.OrderType)
|
||||
orderType, err = order.StringToOrderType(data.OrderType)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- order.ClassificationError{
|
||||
Exchange: b.Name,
|
||||
@@ -251,7 +251,7 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
var orderSide order.Side
|
||||
orderSide, err = order.StringToOrderSide(data.Data.Side)
|
||||
orderSide, err = order.StringToOrderSide(data.Side)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- order.ClassificationError{
|
||||
Exchange: b.Name,
|
||||
@@ -260,14 +260,14 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
b.Websocket.DataHandler <- &order.Detail{
|
||||
Price: data.Data.Price,
|
||||
Amount: data.Data.Quantity,
|
||||
Price: data.Price,
|
||||
Amount: data.Quantity,
|
||||
AverageExecutedPrice: avgPrice,
|
||||
ExecutedAmount: data.Data.CumulativeFilledQuantity,
|
||||
ExecutedAmount: data.CumulativeFilledQuantity,
|
||||
RemainingAmount: remainingAmount,
|
||||
Cost: data.Data.CumulativeQuoteTransactedQuantity,
|
||||
Cost: data.CumulativeQuoteTransactedQuantity,
|
||||
CostAsset: pair.Quote,
|
||||
Fee: data.Data.Commission,
|
||||
Fee: data.Commission,
|
||||
FeeAsset: feeAsset,
|
||||
Exchange: b.Name,
|
||||
OrderID: orderID,
|
||||
@@ -276,14 +276,14 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
Side: orderSide,
|
||||
Status: orderStatus,
|
||||
AssetType: assetType,
|
||||
Date: data.Data.OrderCreationTime,
|
||||
LastUpdated: data.Data.TransactionTime,
|
||||
Date: data.OrderCreationTime.Time(),
|
||||
LastUpdated: data.TransactionTime.Time(),
|
||||
Pair: pair,
|
||||
}
|
||||
return nil
|
||||
case "listStatus":
|
||||
var data wsListStatus
|
||||
err = json.Unmarshal(respRaw, &data)
|
||||
var data WsListStatusData
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v - Could not convert to listStatus structure %s",
|
||||
b.Name,
|
||||
@@ -331,7 +331,7 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
|
||||
var t TradeStream
|
||||
err = json.Unmarshal(jsonData, &t)
|
||||
err := json.Unmarshal(jsonData, &t)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v - Could not unmarshal trade data: %s",
|
||||
b.Name,
|
||||
@@ -339,12 +339,13 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
td := trade.Data{
|
||||
CurrencyPair: pair,
|
||||
Timestamp: t.TimeStamp,
|
||||
Timestamp: t.TimeStamp.Time(),
|
||||
Price: t.Price.Float64(),
|
||||
Amount: t.Quantity.Float64(),
|
||||
Exchange: b.Name,
|
||||
AssetType: asset.Spot,
|
||||
TID: strconv.FormatInt(t.TradeID, 10)}
|
||||
TID: strconv.FormatInt(t.TradeID, 10),
|
||||
}
|
||||
|
||||
if t.IsBuyerMaker { // Seller is Taker
|
||||
td.Side = order.Sell
|
||||
@@ -371,7 +372,7 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
Bid: t.BestBidPrice.Float64(),
|
||||
Ask: t.BestAskPrice.Float64(),
|
||||
Last: t.LastPrice.Float64(),
|
||||
LastUpdated: t.EventTime,
|
||||
LastUpdated: t.EventTime.Time(),
|
||||
AssetType: asset.Spot,
|
||||
Pair: pair,
|
||||
}
|
||||
@@ -386,12 +387,12 @@ func (b *Binance) wsHandleData(respRaw []byte) error {
|
||||
err)
|
||||
}
|
||||
b.Websocket.DataHandler <- stream.KlineData{
|
||||
Timestamp: kline.EventTime,
|
||||
Timestamp: kline.EventTime.Time(),
|
||||
Pair: pair,
|
||||
AssetType: asset.Spot,
|
||||
Exchange: b.Name,
|
||||
StartTime: kline.Kline.StartTime,
|
||||
CloseTime: kline.Kline.CloseTime,
|
||||
StartTime: kline.Kline.StartTime.Time(),
|
||||
CloseTime: kline.Kline.CloseTime.Time(),
|
||||
Interval: kline.Kline.Interval,
|
||||
OpenPrice: kline.Kline.OpenPrice.Float64(),
|
||||
ClosePrice: kline.Kline.ClosePrice.Float64(),
|
||||
@@ -633,7 +634,7 @@ func (b *Binance) ProcessUpdate(cp currency.Pair, a asset.Item, ws *WebsocketDep
|
||||
Asks: updateAsk,
|
||||
Pair: cp,
|
||||
UpdateID: ws.LastUpdateID,
|
||||
UpdateTime: ws.Timestamp,
|
||||
UpdateTime: ws.Timestamp.Time(),
|
||||
Asset: a,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -752,7 +752,7 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset.
|
||||
AssetType: a,
|
||||
Price: tradeData[i].Price,
|
||||
Amount: tradeData[i].Quantity,
|
||||
Timestamp: tradeData[i].Time,
|
||||
Timestamp: tradeData[i].Time.Time(),
|
||||
}
|
||||
if tradeData[i].IsBuyerMaker { // Seller is Taker
|
||||
td.Side = order.Sell
|
||||
@@ -850,7 +850,7 @@ func (b *Binance) GetHistoricTrades(ctx context.Context, p currency.Pair, a asse
|
||||
Amount: trades[i].Quantity,
|
||||
Exchange: b.Name,
|
||||
Price: trades[i].Price,
|
||||
Timestamp: trades[i].TimeStamp,
|
||||
Timestamp: trades[i].TimeStamp.Time(),
|
||||
AssetType: a,
|
||||
}
|
||||
if trades[i].IsBuyerMaker { // Seller is Taker
|
||||
@@ -897,7 +897,7 @@ func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Subm
|
||||
return nil, fmt.Errorf("%w %v", order.ErrUnsupportedOrderType, s.Type)
|
||||
}
|
||||
|
||||
var orderRequest = NewOrderRequest{
|
||||
orderRequest := NewOrderRequest{
|
||||
Symbol: s.Pair,
|
||||
Side: sideType,
|
||||
Price: s.Price,
|
||||
@@ -1190,8 +1190,8 @@ func (b *Binance) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
||||
Status: status,
|
||||
Price: resp.Price,
|
||||
ExecutedAmount: resp.ExecutedQty,
|
||||
Date: resp.Time,
|
||||
LastUpdated: resp.UpdateTime,
|
||||
Date: resp.Time.Time(),
|
||||
LastUpdated: resp.UpdateTime.Time(),
|
||||
}, nil
|
||||
case asset.CoinMarginedFutures:
|
||||
orderData, err := b.FuturesOpenOrderData(ctx, pair, orderID, "")
|
||||
@@ -1220,8 +1220,8 @@ func (b *Binance) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
||||
respData.Side = orderVars.Side
|
||||
respData.Status = orderVars.Status
|
||||
respData.Type = orderVars.OrderType
|
||||
respData.Date = orderData.Time
|
||||
respData.LastUpdated = orderData.UpdateTime
|
||||
respData.Date = orderData.Time.Time()
|
||||
respData.LastUpdated = orderData.UpdateTime.Time()
|
||||
case asset.USDTMarginedFutures:
|
||||
orderData, err := b.UGetOrderData(ctx, pair, orderID, "")
|
||||
if err != nil {
|
||||
@@ -1249,8 +1249,8 @@ func (b *Binance) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
||||
respData.Side = orderVars.Side
|
||||
respData.Status = orderVars.Status
|
||||
respData.Type = orderVars.OrderType
|
||||
respData.Date = orderData.Time
|
||||
respData.LastUpdated = orderData.UpdateTime
|
||||
respData.Date = orderData.Time.Time()
|
||||
respData.LastUpdated = orderData.UpdateTime.Time()
|
||||
default:
|
||||
return nil, fmt.Errorf("%w %v", asset.ErrNotSupported, assetType)
|
||||
}
|
||||
@@ -1353,7 +1353,7 @@ func (b *Binance) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequ
|
||||
}
|
||||
orders = append(orders, order.Detail{
|
||||
Amount: resp[x].OrigQty,
|
||||
Date: resp[x].Time,
|
||||
Date: resp[x].Time.Time(),
|
||||
Exchange: b.Name,
|
||||
OrderID: strconv.FormatInt(resp[x].OrderID, 10),
|
||||
ClientOrderID: resp[x].ClientOrderID,
|
||||
@@ -1363,7 +1363,7 @@ func (b *Binance) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequ
|
||||
Status: orderStatus,
|
||||
Pair: req.Pairs[i],
|
||||
AssetType: req.AssetType,
|
||||
LastUpdated: resp[x].UpdateTime,
|
||||
LastUpdated: resp[x].UpdateTime.Time(),
|
||||
})
|
||||
}
|
||||
case asset.CoinMarginedFutures:
|
||||
@@ -1395,8 +1395,8 @@ func (b *Binance) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequ
|
||||
Status: orderVars.Status,
|
||||
Pair: req.Pairs[i],
|
||||
AssetType: asset.CoinMarginedFutures,
|
||||
Date: openOrders[y].Time,
|
||||
LastUpdated: openOrders[y].UpdateTime,
|
||||
Date: openOrders[y].Time.Time(),
|
||||
LastUpdated: openOrders[y].UpdateTime.Time(),
|
||||
})
|
||||
}
|
||||
case asset.USDTMarginedFutures:
|
||||
@@ -1428,8 +1428,8 @@ func (b *Binance) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequ
|
||||
Status: orderVars.Status,
|
||||
Pair: req.Pairs[i],
|
||||
AssetType: asset.USDTMarginedFutures,
|
||||
Date: openOrders[y].Time,
|
||||
LastUpdated: openOrders[y].UpdateTime,
|
||||
Date: openOrders[y].Time.Time(),
|
||||
LastUpdated: openOrders[y].UpdateTime.Time(),
|
||||
})
|
||||
}
|
||||
default:
|
||||
@@ -1493,8 +1493,8 @@ func (b *Binance) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequ
|
||||
RemainingAmount: resp[i].OrigQty - resp[i].ExecutedQty,
|
||||
Cost: cost,
|
||||
CostAsset: req.Pairs[x].Quote,
|
||||
Date: resp[i].Time,
|
||||
LastUpdated: resp[i].UpdateTime,
|
||||
Date: resp[i].Time.Time(),
|
||||
LastUpdated: resp[i].UpdateTime.Time(),
|
||||
Exchange: b.Name,
|
||||
OrderID: strconv.FormatInt(resp[i].OrderID, 10),
|
||||
Side: side,
|
||||
@@ -1561,7 +1561,7 @@ func (b *Binance) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequ
|
||||
Status: orderVars.Status,
|
||||
Pair: req.Pairs[i],
|
||||
AssetType: asset.CoinMarginedFutures,
|
||||
Date: orderHistory[y].Time,
|
||||
Date: orderHistory[y].Time.Time(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1619,7 +1619,7 @@ func (b *Binance) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequ
|
||||
Status: orderVars.Status,
|
||||
Pair: req.Pairs[i],
|
||||
AssetType: asset.USDTMarginedFutures,
|
||||
Date: orderHistory[y].Time,
|
||||
Date: orderHistory[y].Time.Time(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1949,7 +1949,7 @@ func (b *Binance) GetServerTime(ctx context.Context, ai asset.Item) (time.Time,
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return info.ServerTime, nil
|
||||
return info.ServerTime.Time(), nil
|
||||
case asset.CoinMarginedFutures:
|
||||
info, err := b.FuturesExchangeInfo(ctx)
|
||||
if err != nil {
|
||||
@@ -2681,7 +2681,7 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
sd := req.StartDate
|
||||
switch req.Asset {
|
||||
case asset.USDTMarginedFutures:
|
||||
var orderLimit = 1000
|
||||
orderLimit := 1000
|
||||
for x := range req.Pairs {
|
||||
fPair, err := b.FormatExchangeCurrency(req.Pairs[x], req.Asset)
|
||||
if err != nil {
|
||||
@@ -2703,7 +2703,7 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
return nil, err
|
||||
}
|
||||
for i := range orders {
|
||||
if orders[i].Time.After(req.EndDate) {
|
||||
if orders[i].Time.Time().After(req.EndDate) {
|
||||
continue
|
||||
}
|
||||
orderVars := compatibleOrderVars(orders[i].Side, orders[i].Status, orders[i].OrderType)
|
||||
@@ -2731,8 +2731,8 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
Side: orderVars.Side,
|
||||
Status: orderVars.Status,
|
||||
AssetType: asset.USDTMarginedFutures,
|
||||
Date: orders[i].Time,
|
||||
LastUpdated: orders[i].UpdateTime,
|
||||
Date: orders[i].Time.Time(),
|
||||
LastUpdated: orders[i].UpdateTime.Time(),
|
||||
Pair: req.Pairs[x],
|
||||
MarginType: mt,
|
||||
})
|
||||
@@ -2746,7 +2746,7 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
}
|
||||
}
|
||||
case asset.CoinMarginedFutures:
|
||||
var orderLimit = 100
|
||||
orderLimit := 100
|
||||
for x := range req.Pairs {
|
||||
fPair, err := b.FormatExchangeCurrency(req.Pairs[x], req.Asset)
|
||||
if err != nil {
|
||||
@@ -2773,7 +2773,7 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
return nil, err
|
||||
}
|
||||
for i := range orders {
|
||||
if orders[i].Time.After(req.EndDate) {
|
||||
if orders[i].Time.Time().After(req.EndDate) {
|
||||
continue
|
||||
}
|
||||
var orderPair currency.Pair
|
||||
@@ -2806,8 +2806,8 @@ func (b *Binance) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos
|
||||
Side: orderVars.Side,
|
||||
Status: orderVars.Status,
|
||||
AssetType: asset.CoinMarginedFutures,
|
||||
Date: orders[i].Time,
|
||||
LastUpdated: orders[i].UpdateTime,
|
||||
Date: orders[i].Time.Time(),
|
||||
LastUpdated: orders[i].UpdateTime.Time(),
|
||||
Pair: req.Pairs[x],
|
||||
MarginType: mt,
|
||||
})
|
||||
|
||||
@@ -257,59 +257,59 @@ type FuturesOrderPlaceData struct {
|
||||
|
||||
// FuturesOrderGetData stores futures order data for get requests
|
||||
type FuturesOrderGetData struct {
|
||||
AveragePrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderID"`
|
||||
CumulativeQuantity float64 `json:"cumQty,string"`
|
||||
CumulativeBase float64 `json:"cumBase,string"`
|
||||
ExecutedQuantity float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OriginalQuantity float64 `json:"origQty,string"`
|
||||
OriginalType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"buy"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
Time time.Time `json:"time"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
PriceProtect bool `json:"priceProtect"`
|
||||
AveragePrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderID"`
|
||||
CumulativeQuantity float64 `json:"cumQty,string"`
|
||||
CumulativeBase float64 `json:"cumBase,string"`
|
||||
ExecutedQuantity float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OriginalQuantity float64 `json:"origQty,string"`
|
||||
OriginalType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"buy"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
PriceProtect bool `json:"priceProtect"`
|
||||
}
|
||||
|
||||
// FuturesOrderData stores order data for futures
|
||||
type FuturesOrderData struct {
|
||||
AvgPrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
CumBase string `json:"cumBase"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
OrigType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
Time time.Time `json:"time"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
PriceProtect bool `json:"priceProtect"`
|
||||
AvgPrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
CumBase string `json:"cumBase"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
OrigType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Pair string `json:"pair"`
|
||||
Time types.Time `json:"time"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
PriceProtect bool `json:"priceProtect"`
|
||||
}
|
||||
|
||||
// OrderVars stores side, status and type for any order/trade
|
||||
@@ -362,21 +362,21 @@ type FuturesAccountBalanceData struct {
|
||||
|
||||
// FuturesAccountInformationPosition holds account position data
|
||||
type FuturesAccountInformationPosition struct {
|
||||
Symbol string `json:"symbol"`
|
||||
Amount float64 `json:"positionAmt,string"`
|
||||
InitialMargin float64 `json:"initialMargin,string"`
|
||||
MaintenanceMargin float64 `json:"maintMargin,string"`
|
||||
UnrealizedProfit float64 `json:"unrealizedProfit,string"`
|
||||
PositionInitialMargin float64 `json:"positionInitialMargin,string"`
|
||||
OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
Isolated bool `json:"isolated"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MaxQty float64 `json:"maxQty,string"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
NotionalValue float64 `json:"notionalValue,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
Symbol string `json:"symbol"`
|
||||
Amount float64 `json:"positionAmt,string"`
|
||||
InitialMargin float64 `json:"initialMargin,string"`
|
||||
MaintenanceMargin float64 `json:"maintMargin,string"`
|
||||
UnrealizedProfit float64 `json:"unrealizedProfit,string"`
|
||||
PositionInitialMargin float64 `json:"positionInitialMargin,string"`
|
||||
OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
|
||||
Leverage float64 `json:"leverage,string"`
|
||||
Isolated bool `json:"isolated"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
EntryPrice float64 `json:"entryPrice,string"`
|
||||
MaxQty float64 `json:"maxQty,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
NotionalValue float64 `json:"notionalValue,string"`
|
||||
IsolatedWallet float64 `json:"isolatedWallet,string"`
|
||||
}
|
||||
|
||||
// FuturesAccountInformation stores account information for futures account
|
||||
@@ -387,7 +387,7 @@ type FuturesAccountInformation struct {
|
||||
CanTrade bool `json:"canTrade"`
|
||||
CanWithdraw bool `json:"canWithdraw"`
|
||||
FeeTier int64 `json:"feeTier"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
}
|
||||
|
||||
// FuturesAccountAsset holds account asset information
|
||||
|
||||
@@ -1,430 +0,0 @@
|
||||
package binance
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/encoding/json"
|
||||
"github.com/thrasher-corp/gocryptotrader/types"
|
||||
)
|
||||
|
||||
// timeString gets the time as Binance timestamp
|
||||
func timeString(t time.Time) string {
|
||||
return strconv.FormatInt(t.UnixMilli(), 10)
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *ExchangeInfo) UnmarshalJSON(data []byte) error {
|
||||
type Alias ExchangeInfo
|
||||
aux := &struct {
|
||||
Servertime types.Time `json:"serverTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.ServerTime = aux.Servertime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *AggregatedTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias AggregatedTrade
|
||||
aux := &struct {
|
||||
TimeStamp types.Time `json:"T"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.TimeStamp = aux.TimeStamp.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *NewOrderResponse) UnmarshalJSON(data []byte) error {
|
||||
type Alias NewOrderResponse
|
||||
aux := &struct {
|
||||
TransactionTime types.Time `json:"transactTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
if aux != nil {
|
||||
a.TransactionTime = aux.TransactionTime.Time()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *TradeStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias TradeStream
|
||||
aux := &struct {
|
||||
TimeStamp types.Time `json:"T"`
|
||||
EventTime types.Time `json:"E"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.TimeStamp = aux.TimeStamp.Time()
|
||||
a.EventTime = aux.EventTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *KlineStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias KlineStream
|
||||
aux := &struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
Kline struct {
|
||||
StartTime types.Time `json:"t"`
|
||||
CloseTime types.Time `json:"T"`
|
||||
*KlineStreamData
|
||||
} `json:"k"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Kline = *aux.Kline.KlineStreamData
|
||||
a.EventTime = aux.EventTime.Time()
|
||||
a.Kline.StartTime = aux.Kline.StartTime.Time()
|
||||
a.Kline.CloseTime = aux.Kline.CloseTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *TickerStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias TickerStream
|
||||
aux := &struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
OpenTime types.Time `json:"O"`
|
||||
CloseTime types.Time `json:"C"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.EventTime = aux.EventTime.Time()
|
||||
a.OpenTime = aux.OpenTime.Time()
|
||||
a.CloseTime = aux.CloseTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *PriceChangeStats) UnmarshalJSON(data []byte) error {
|
||||
type Alias PriceChangeStats
|
||||
aux := &struct {
|
||||
OpenTime types.Time `json:"openTime"`
|
||||
CloseTime types.Time `json:"closeTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.OpenTime = aux.OpenTime.Time()
|
||||
a.CloseTime = aux.CloseTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *RecentTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias RecentTrade
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *HistoricalTrade) UnmarshalJSON(data []byte) error {
|
||||
type Alias HistoricalTrade
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *QueryOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias QueryOrderData
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *FuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesOrderData
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *UFuturesOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias UFuturesOrderData
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *FuturesOrderGetData) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesOrderGetData
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *UOrderData) UnmarshalJSON(data []byte) error {
|
||||
type Alias UOrderData
|
||||
aux := &struct {
|
||||
Time types.Time `json:"time"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Time = aux.Time.Time()
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *Account) UnmarshalJSON(data []byte) error {
|
||||
type Alias Account
|
||||
aux := &struct {
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *WebsocketDepthStream) UnmarshalJSON(data []byte) error {
|
||||
type Alias WebsocketDepthStream
|
||||
aux := &struct {
|
||||
Timestamp types.Time `json:"E"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Timestamp = aux.Timestamp.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *wsAccountPosition) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsAccountPosition
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
LastUpdated types.Time `json:"u"`
|
||||
*WsAccountPositionData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Data = *aux.Data.WsAccountPositionData
|
||||
a.Data.EventTime = aux.Data.EventTime.Time()
|
||||
a.Data.LastUpdated = aux.Data.LastUpdated.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *wsBalanceUpdate) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsBalanceUpdate
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
ClearTime types.Time `json:"T"`
|
||||
*WsBalanceUpdateData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Data = *aux.Data.WsBalanceUpdateData
|
||||
a.Data.EventTime = aux.Data.EventTime.Time()
|
||||
a.Data.ClearTime = aux.Data.ClearTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *wsOrderUpdate) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsOrderUpdate
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
OrderCreationTime types.Time `json:"O"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
WorkingTime types.Time `json:"W"`
|
||||
*WsOrderUpdateData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Data = *aux.Data.WsOrderUpdateData
|
||||
a.Data.EventTime = aux.Data.EventTime.Time()
|
||||
a.Data.OrderCreationTime = aux.Data.OrderCreationTime.Time()
|
||||
a.Data.TransactionTime = aux.Data.TransactionTime.Time()
|
||||
a.Data.WorkingTime = aux.Data.WorkingTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *wsListStatus) UnmarshalJSON(data []byte) error {
|
||||
type Alias wsListStatus
|
||||
aux := &struct {
|
||||
Data struct {
|
||||
EventTime types.Time `json:"E"`
|
||||
TransactionTime types.Time `json:"T"`
|
||||
*WsListStatusData
|
||||
} `json:"data"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Data = *aux.Data.WsListStatusData
|
||||
a.Data.EventTime = aux.Data.EventTime.Time()
|
||||
a.Data.TransactionTime = aux.Data.TransactionTime.Time()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *FuturesAccountInformationPosition) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesAccountInformationPosition
|
||||
|
||||
aux := &struct {
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON deserialises the JSON info, including the timestamp
|
||||
func (a *FuturesAccountInformation) UnmarshalJSON(data []byte) error {
|
||||
type Alias FuturesAccountInformation
|
||||
|
||||
aux := &struct {
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.UpdateTime = aux.UpdateTime.Time()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package binance
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/types"
|
||||
)
|
||||
@@ -195,57 +193,57 @@ type UCompositeIndexInfoData struct {
|
||||
|
||||
// UOrderData stores order data
|
||||
type UOrderData struct {
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
Time time.Time `json:"time"`
|
||||
CumulativeQuantity float64 `json:"cumQty,string"`
|
||||
CumulativeQuote float64 `json:"cumQuote,string"`
|
||||
ExecutedQuantity float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
AveragePrice float64 `json:"avgPrice,string"`
|
||||
OriginalQuantity float64 `json:"origQty,string"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
OriginalType string `json:"origType"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
Code int64 `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
Time types.Time `json:"time"`
|
||||
CumulativeQuantity float64 `json:"cumQty,string"`
|
||||
CumulativeQuote float64 `json:"cumQuote,string"`
|
||||
ExecutedQuantity float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
AveragePrice float64 `json:"avgPrice,string"`
|
||||
OriginalQuantity float64 `json:"origQty,string"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
OriginalType string `json:"origType"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
Code int64 `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
// UFuturesOrderData stores order data for ufutures
|
||||
type UFuturesOrderData struct {
|
||||
AvgPrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
CumQuote string `json:"cumQuote"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
OrigType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Time time.Time `json:"time"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
AvgPrice float64 `json:"avgPrice,string"`
|
||||
ClientOrderID string `json:"clientOrderId"`
|
||||
CumQuote string `json:"cumQuote"`
|
||||
ExecutedQty float64 `json:"executedQty,string"`
|
||||
OrderID int64 `json:"orderId"`
|
||||
OrigQty float64 `json:"origQty,string"`
|
||||
OrigType string `json:"origType"`
|
||||
Price float64 `json:"price,string"`
|
||||
ReduceOnly bool `json:"reduceOnly"`
|
||||
Side string `json:"side"`
|
||||
PositionSide string `json:"positionSide"`
|
||||
Status string `json:"status"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ClosePosition bool `json:"closePosition"`
|
||||
Symbol string `json:"symbol"`
|
||||
Time types.Time `json:"time"`
|
||||
TimeInForce string `json:"timeInForce"`
|
||||
OrderType string `json:"type"`
|
||||
ActivatePrice float64 `json:"activatePrice,string"`
|
||||
PriceRate float64 `json:"priceRate,string"`
|
||||
UpdateTime types.Time `json:"updateTime"`
|
||||
WorkingType string `json:"workingType"`
|
||||
}
|
||||
|
||||
// UAccountBalanceV2Data stores account balance data for ufutures
|
||||
|
||||
Reference in New Issue
Block a user