Skip to content

Commit d8fca1e

Browse files
authored
fix Mark Price, Order futures (#533)
* fix Mark Price * fix Order futures * fix Mark Price, Order futures (remove commenting code)
1 parent b962076 commit d8fca1e

File tree

4 files changed

+111
-87
lines changed

4 files changed

+111
-87
lines changed

v2/futures/mark_price.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ func (s *PremiumIndexService) Do(ctx context.Context, opts ...RequestOption) (re
4545

4646
// PremiumIndex define premium index of mark price
4747
type PremiumIndex struct {
48-
Symbol string `json:"symbol"`
49-
MarkPrice string `json:"markPrice"`
50-
LastFundingRate string `json:"lastFundingRate"`
51-
NextFundingTime int64 `json:"nextFundingTime"`
52-
Time int64 `json:"time"`
48+
Symbol string `json:"symbol"`
49+
MarkPrice string `json:"markPrice"`
50+
IndexPrice string `json:"indexPrice"`
51+
EstimatedSettlePrice string `json:"estimatedSettlePrice"`
52+
LastFundingRate string `json:"lastFundingRate"`
53+
NextFundingTime int64 `json:"nextFundingTime"`
54+
InterestRate string `json:"interestRate"`
55+
Time int64 `json:"time"`
5356
}
5457

5558
// FundingRateService get funding rate

v2/futures/mark_price_test.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ func (s *premiumIndexServiceTestSuite) TestGetPremiumIndex() {
1818
data := []byte(`[{
1919
"symbol": "BTCUSDT",
2020
"markPrice": "11012.80409769",
21+
"indexPrice": "11781.80495970",
22+
"estimatedSettlePrice": "11781.80495970",
2123
"lastFundingRate": "-0.03750000",
2224
"nextFundingTime": 1562569200000,
25+
"interestRate": "0.00010000",
2326
"time": 1562566020000
2427
}]`)
2528
s.mockDo(data, nil)
@@ -36,11 +39,14 @@ func (s *premiumIndexServiceTestSuite) TestGetPremiumIndex() {
3639
res, err := s.client.NewPremiumIndexService().Symbol(symbol).Do(newContext())
3740
s.r().NoError(err)
3841
e := []*PremiumIndex{&PremiumIndex{
39-
Symbol: symbol,
40-
MarkPrice: "11012.80409769",
41-
LastFundingRate: "-0.03750000",
42-
NextFundingTime: int64(1562569200000),
43-
Time: int64(1562566020000),
42+
Symbol: symbol,
43+
MarkPrice: "11012.80409769",
44+
IndexPrice: "11781.80495970",
45+
EstimatedSettlePrice: "11781.80495970",
46+
LastFundingRate: "-0.03750000",
47+
NextFundingTime: int64(1562569200000),
48+
InterestRate: "0.00010000",
49+
Time: int64(1562566020000),
4450
},
4551
}
4652
s.assertPremiumIndexEqual(e, res)
@@ -50,8 +56,11 @@ func (s *premiumIndexServiceTestSuite) assertPremiumIndexEqual(e, a []*PremiumIn
5056
r := s.r()
5157
r.Equal(e[0].Symbol, a[0].Symbol, "Symbol")
5258
r.Equal(e[0].MarkPrice, a[0].MarkPrice, "MarkPrice")
59+
r.Equal(e[0].IndexPrice, a[0].IndexPrice, "IndexPrice")
60+
r.Equal(e[0].EstimatedSettlePrice, a[0].EstimatedSettlePrice, "EstimatedSettlePrice")
5361
r.Equal(e[0].LastFundingRate, a[0].LastFundingRate, "LastFundingRate")
5462
r.Equal(e[0].NextFundingTime, a[0].NextFundingTime, "NextFundingTime")
63+
r.Equal(e[0].InterestRate, a[0].InterestRate, "InterestRate")
5564
r.Equal(e[0].Time, a[0].Time, "Time")
5665
}
5766

v2/futures/order_service.go

+55-47
Original file line numberDiff line numberDiff line change
@@ -204,29 +204,34 @@ func (s *CreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res
204204

205205
// CreateOrderResponse define create order response
206206
type CreateOrderResponse struct {
207-
Symbol string `json:"symbol"`
208-
OrderID int64 `json:"orderId"`
209-
ClientOrderID string `json:"clientOrderId"`
210-
Price string `json:"price"`
211-
OrigQuantity string `json:"origQty"`
212-
ExecutedQuantity string `json:"executedQty"`
213-
CumQuote string `json:"cumQuote"`
214-
ReduceOnly bool `json:"reduceOnly"`
215-
Status OrderStatusType `json:"status"`
216-
StopPrice string `json:"stopPrice"`
217-
TimeInForce TimeInForceType `json:"timeInForce"`
218-
Type OrderType `json:"type"`
219-
Side SideType `json:"side"`
220-
UpdateTime int64 `json:"updateTime"`
221-
WorkingType WorkingType `json:"workingType"`
222-
ActivatePrice string `json:"activatePrice"`
223-
PriceRate string `json:"priceRate"`
224-
AvgPrice string `json:"avgPrice"`
225-
PositionSide PositionSideType `json:"positionSide"`
226-
ClosePosition bool `json:"closePosition"`
227-
PriceProtect bool `json:"priceProtect"`
228-
RateLimitOrder10s string `json:"rateLimitOrder10s,omitempty"`
229-
RateLimitOrder1m string `json:"rateLimitOrder1m,omitempty"`
207+
Symbol string `json:"symbol"` //
208+
OrderID int64 `json:"orderId"` //
209+
ClientOrderID string `json:"clientOrderId"` //
210+
Price string `json:"price"` //
211+
OrigQuantity string `json:"origQty"` //
212+
ExecutedQuantity string `json:"executedQty"` //
213+
CumQuote string `json:"cumQuote"` //
214+
ReduceOnly bool `json:"reduceOnly"` //
215+
Status OrderStatusType `json:"status"` //
216+
StopPrice string `json:"stopPrice"` // please ignore when order type is TRAILING_STOP_MARKET
217+
TimeInForce TimeInForceType `json:"timeInForce"` //
218+
Type OrderType `json:"type"` //
219+
Side SideType `json:"side"` //
220+
UpdateTime int64 `json:"updateTime"` // update time
221+
WorkingType WorkingType `json:"workingType"` //
222+
ActivatePrice string `json:"activatePrice"` // activation price, only return with TRAILING_STOP_MARKET order
223+
PriceRate string `json:"priceRate"` // callback rate, only return with TRAILING_STOP_MARKET order
224+
AvgPrice string `json:"avgPrice"` //
225+
PositionSide PositionSideType `json:"positionSide"` //
226+
ClosePosition bool `json:"closePosition"` // if Close-All
227+
PriceProtect bool `json:"priceProtect"` // if conditional order trigger is protected
228+
PriceMatch string `json:"priceMatch"` // price match mode
229+
SelfTradePreventionMode string `json:"selfTradePreventionMode"` // self trading preventation mode
230+
GoodTillDate int64 `json:"goodTillDate"` // order pre-set auto cancel time for TIF GTD order
231+
CumQty string `json:"cumQty"` //
232+
OrigType OrderType `json:"origType"` //
233+
RateLimitOrder10s string `json:"rateLimitOrder10s,omitempty"` //
234+
RateLimitOrder1m string `json:"rateLimitOrder1m,omitempty"` //
230235
}
231236

232237
// ListOpenOrdersService list opened orders
@@ -368,30 +373,33 @@ func (s *GetOrderService) Do(ctx context.Context, opts ...RequestOption) (res *O
368373

369374
// Order define order info
370375
type Order struct {
371-
Symbol string `json:"symbol"`
372-
OrderID int64 `json:"orderId"`
373-
ClientOrderID string `json:"clientOrderId"`
374-
Price string `json:"price"`
375-
ReduceOnly bool `json:"reduceOnly"`
376-
OrigQuantity string `json:"origQty"`
377-
ExecutedQuantity string `json:"executedQty"`
378-
CumQuantity string `json:"cumQty"`
379-
CumQuote string `json:"cumQuote"`
380-
Status OrderStatusType `json:"status"`
381-
TimeInForce TimeInForceType `json:"timeInForce"`
382-
Type OrderType `json:"type"`
383-
Side SideType `json:"side"`
384-
StopPrice string `json:"stopPrice"`
385-
Time int64 `json:"time"`
386-
UpdateTime int64 `json:"updateTime"`
387-
WorkingType WorkingType `json:"workingType"`
388-
ActivatePrice string `json:"activatePrice"`
389-
PriceRate string `json:"priceRate"`
390-
AvgPrice string `json:"avgPrice"`
391-
OrigType string `json:"origType"`
392-
PositionSide PositionSideType `json:"positionSide"`
393-
PriceProtect bool `json:"priceProtect"`
394-
ClosePosition bool `json:"closePosition"`
376+
Symbol string `json:"symbol"`
377+
OrderID int64 `json:"orderId"`
378+
ClientOrderID string `json:"clientOrderId"`
379+
Price string `json:"price"`
380+
ReduceOnly bool `json:"reduceOnly"`
381+
OrigQuantity string `json:"origQty"`
382+
ExecutedQuantity string `json:"executedQty"`
383+
CumQuantity string `json:"cumQty"`
384+
CumQuote string `json:"cumQuote"`
385+
Status OrderStatusType `json:"status"`
386+
TimeInForce TimeInForceType `json:"timeInForce"`
387+
Type OrderType `json:"type"`
388+
Side SideType `json:"side"`
389+
StopPrice string `json:"stopPrice"`
390+
Time int64 `json:"time"`
391+
UpdateTime int64 `json:"updateTime"`
392+
WorkingType WorkingType `json:"workingType"`
393+
ActivatePrice string `json:"activatePrice"`
394+
PriceRate string `json:"priceRate"`
395+
AvgPrice string `json:"avgPrice"`
396+
OrigType OrderType `json:"origType"`
397+
PositionSide PositionSideType `json:"positionSide"`
398+
PriceProtect bool `json:"priceProtect"`
399+
ClosePosition bool `json:"closePosition"`
400+
PriceMatch string `json:"priceMatch"`
401+
SelfTradePreventionMode string `json:"selfTradePreventionMode"`
402+
GoodTillDate int64 `json:"goodTillDate"`
395403
}
396404

397405
// ListOrdersService all account orders; active, canceled, or filled

v2/futures/websocket_service.go

+34-30
Original file line numberDiff line numberDiff line change
@@ -999,36 +999,40 @@ type WsPosition struct {
999999

10001000
// WsOrderTradeUpdate define order trade update
10011001
type WsOrderTradeUpdate struct {
1002-
Symbol string `json:"s"`
1003-
ClientOrderID string `json:"c"`
1004-
Side SideType `json:"S"`
1005-
Type OrderType `json:"o"`
1006-
TimeInForce TimeInForceType `json:"f"`
1007-
OriginalQty string `json:"q"`
1008-
OriginalPrice string `json:"p"`
1009-
AveragePrice string `json:"ap"`
1010-
StopPrice string `json:"sp"`
1011-
ExecutionType OrderExecutionType `json:"x"`
1012-
Status OrderStatusType `json:"X"`
1013-
ID int64 `json:"i"`
1014-
LastFilledQty string `json:"l"`
1015-
AccumulatedFilledQty string `json:"z"`
1016-
LastFilledPrice string `json:"L"`
1017-
CommissionAsset string `json:"N"`
1018-
Commission string `json:"n"`
1019-
TradeTime int64 `json:"T"`
1020-
TradeID int64 `json:"t"`
1021-
BidsNotional string `json:"b"`
1022-
AsksNotional string `json:"a"`
1023-
IsMaker bool `json:"m"`
1024-
IsReduceOnly bool `json:"R"`
1025-
WorkingType WorkingType `json:"wt"`
1026-
OriginalType OrderType `json:"ot"`
1027-
PositionSide PositionSideType `json:"ps"`
1028-
IsClosingPosition bool `json:"cp"`
1029-
ActivationPrice string `json:"AP"`
1030-
CallbackRate string `json:"cr"`
1031-
RealizedPnL string `json:"rp"`
1002+
Symbol string `json:"s"` // Symbol
1003+
ClientOrderID string `json:"c"` // Client order ID
1004+
Side SideType `json:"S"` // Side
1005+
Type OrderType `json:"o"` // Order type
1006+
TimeInForce TimeInForceType `json:"f"` // Time in force
1007+
OriginalQty string `json:"q"` // Original quantity
1008+
OriginalPrice string `json:"p"` // Original price
1009+
AveragePrice string `json:"ap"` // Average price
1010+
StopPrice string `json:"sp"` // Stop price. Please ignore with TRAILING_STOP_MARKET order
1011+
ExecutionType OrderExecutionType `json:"x"` // Execution type
1012+
Status OrderStatusType `json:"X"` // Order status
1013+
ID int64 `json:"i"` // Order ID
1014+
LastFilledQty string `json:"l"` // Order Last Filled Quantity
1015+
AccumulatedFilledQty string `json:"z"` // Order Filled Accumulated Quantity
1016+
LastFilledPrice string `json:"L"` // Last Filled Price
1017+
CommissionAsset string `json:"N"` // Commission Asset, will not push if no commission
1018+
Commission string `json:"n"` // Commission, will not push if no commission
1019+
TradeTime int64 `json:"T"` // Order Trade Time
1020+
TradeID int64 `json:"t"` // Trade ID
1021+
BidsNotional string `json:"b"` // Bids Notional
1022+
AsksNotional string `json:"a"` // Asks Notional
1023+
IsMaker bool `json:"m"` // Is this trade the maker side?
1024+
IsReduceOnly bool `json:"R"` // Is this reduce only
1025+
WorkingType WorkingType `json:"wt"` // Stop Price Working Type
1026+
OriginalType OrderType `json:"ot"` // Original Order Type
1027+
PositionSide PositionSideType `json:"ps"` // Position Side
1028+
IsClosingPosition bool `json:"cp"` // If Close-All, pushed with conditional order
1029+
ActivationPrice string `json:"AP"` // Activation Price, only puhed with TRAILING_STOP_MARKET order
1030+
CallbackRate string `json:"cr"` // Callback Rate, only puhed with TRAILING_STOP_MARKET order
1031+
PriceProtect bool `json:"pP"` // If price protection is turned on
1032+
RealizedPnL string `json:"rp"` // Realized Profit of the trade
1033+
STP string `json:"V"` // STP mode
1034+
PriceMode string `json:"pm"` // Price match mode
1035+
GTD int64 `json:"gtd"` // TIF GTD order auto cancel time
10321036
}
10331037

10341038
// WsAccountConfigUpdate define account config update

0 commit comments

Comments
 (0)