Skip to content

Commit

Permalink
feat(GetPositionInfo): add missing property to response (#155)
Browse files Browse the repository at this point in the history
* feat(GetPositionInfo): add missing property to response

* test(GetPositionInfo): add missing property to response
  • Loading branch information
hirokisan authored Dec 22, 2023
1 parent d23ab3b commit 2f059f9
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,58 +1,39 @@
{
"category": "linear",
"nextPageCursor": "",
"nextPageCursor": "BTCUSDT%2C1691735404177%2C0",
"list": [
{
"symbol": "BTCUSDT",
"leverage": "2",
"avgPrice": "22714",
"liqPrice": "0.10",
"riskLimitValue": "2000000",
"takeProfit": "0.00",
"positionValue": "22.714",
"tpslMode": "Full",
"riskId": 1,
"trailingStop": "0.00",
"unrealisedPnl": "1.90344",
"markPrice": "24617.44",
"cumRealisedPnl": "-592.751693",
"positionMM": "0.0000005",
"createdTime": "1637760408825",
"positionIdx": 1,
"positionIM": "0.22714",
"updatedTime": "1676678400081",
"side": "Buy",
"bustPrice": "0.10",
"size": "0.001",
"positionStatus": "Normal",
"stopLoss": "0.00",
"tradeMode": 0
},
{
"symbol": "BTCUSDT",
"leverage": "2",
"leverage": "1",
"avgPrice": "0",
"liqPrice": "0.00",
"riskLimitValue": "2000000",
"takeProfit": "0.00",
"positionValue": "0",
"liqPrice": "",
"riskLimitValue": "6000000",
"takeProfit": "",
"positionValue": "",
"tpslMode": "Full",
"riskId": 1,
"trailingStop": "0.00",
"unrealisedPnl": "0",
"markPrice": "24578.06",
"cumRealisedPnl": "0",
"riskId": 3,
"trailingStop": "0",
"unrealisedPnl": "",
"markPrice": "43577.97",
"cumRealisedPnl": "-1618.71655122",
"adlRankIndicator": 0,
"isReduceOnly": false,
"mmrSysUpdatedTime": "",
"leverageSysUpdatedTime": "",
"positionMM": "0",
"createdTime": "1637760408825",
"positionIdx": 2,
"positionBalance": "0",
"createdTime": "1677287853003",
"updatedTime": "1691735404177",
"seq": 8093271558,
"positionIdx": 0,
"positionIM": "0",
"updatedTime": "1676678400081",
"side": "Sell",
"bustPrice": "0.00",
"size": "0.000",
"side": "",
"bustPrice": "",
"size": "0",
"positionStatus": "Normal",
"stopLoss": "0.00",
"tradeMode": 0
"stopLoss": "",
"tradeMode": 0,
"autoAddMargin": 0
}
]
}
12 changes: 12 additions & 0 deletions v5_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,15 @@ const (
CollateralSwitchV5On = CollateralSwitchV5("ON")
CollateralSwitchV5Off = CollateralSwitchV5("OFF")
)

// AdlRankIndicator : Auto-deleverage rank indicator
type AdlRankIndicator int

const (
AdlRankIndicator0 = AdlRankIndicator(0) // default value of empty position
AdlRankIndicator1 = AdlRankIndicator(1)
AdlRankIndicator2 = AdlRankIndicator(2)
AdlRankIndicator3 = AdlRankIndicator(3)
AdlRankIndicator4 = AdlRankIndicator(4)
AdlRankIndicator5 = AdlRankIndicator(5)
)
55 changes: 31 additions & 24 deletions v5_position_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,37 @@ type V5GetPositionInfoList []V5GetPositionInfoItem

// V5GetPositionInfoItem :
type V5GetPositionInfoItem struct {
Symbol SymbolV5 `json:"symbol"`
Leverage string `json:"leverage"`
AvgPrice string `json:"avgPrice"`
LiqPrice string `json:"liqPrice"`
RiskLimitValue string `json:"riskLimitValue"`
TakeProfit string `json:"takeProfit"`
PositionValue string `json:"positionValue"`
TpSlMode TpSlMode `json:"tpslMode"`
RiskID int `json:"riskId"`
TrailingStop string `json:"trailingStop"`
UnrealisedPnl string `json:"unrealisedPnl"`
MarkPrice string `json:"markPrice"`
CumRealisedPnl string `json:"cumRealisedPnl"`
PositionMM string `json:"positionMM"`
CreatedTime string `json:"createdTime"`
PositionIdx int `json:"positionIdx"`
PositionIM string `json:"positionIM"`
UpdatedTime string `json:"updatedTime"`
Side Side `json:"side"`
BustPrice string `json:"bustPrice"`
Size string `json:"size"`
PositionStatus string `json:"positionStatus"`
StopLoss string `json:"stopLoss"`
TradeMode int `json:"tradeMode"`
Symbol SymbolV5 `json:"symbol"`
Leverage string `json:"leverage"`
AvgPrice string `json:"avgPrice"`
LiqPrice string `json:"liqPrice"`
RiskLimitValue string `json:"riskLimitValue"`
TakeProfit string `json:"takeProfit"`
PositionValue string `json:"positionValue"`
TpSlMode TpSlMode `json:"tpslMode"`
RiskID int `json:"riskId"`
TrailingStop string `json:"trailingStop"`
UnrealisedPnl string `json:"unrealisedPnl"`
MarkPrice string `json:"markPrice"`
CumRealisedPnl string `json:"cumRealisedPnl"`
AdlRankIndicator AdlRankIndicator `json:"adlRankIndicator"`
IsReduceOnly bool `json:"isReduceOnly"`
MmrSysUpdatedTime string `json:"mmrSysUpdatedTime"`
LeverageSysUpdatedTime string `json:"leverageSysUpdatedTime"`
PositionMM string `json:"positionMM"`
PositionBalance string `json:"positionBalance"`
CreatedTime string `json:"createdTime"`
UpdatedTime string `json:"updatedTime"`
Seq int64 `json:"seq"`
PositionIdx int `json:"positionIdx"`
PositionIM string `json:"positionIM"`
Side Side `json:"side"`
BustPrice string `json:"bustPrice"`
Size string `json:"size"`
PositionStatus string `json:"positionStatus"`
StopLoss string `json:"stopLoss"`
TradeMode int `json:"tradeMode"`
AutoAddMargin int `json:"autoAddMargin"`
}

// GetPositionInfo :
Expand Down
55 changes: 31 additions & 24 deletions v5_position_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,37 @@ func TestV5Position_GetPositionInfo(t *testing.T) {
"nextPageCursor": "",
"list": []map[string]interface{}{
{
"symbol": "BTCUSDT",
"leverage": "2",
"avgPrice": "22714",
"liqPrice": "0.10",
"riskLimitValue": "2000000",
"takeProfit": "0.00",
"positionValue": "22.714",
"tpslMode": "Full",
"riskId": 1,
"trailingStop": "0.00",
"unrealisedPnl": "1.90344",
"markPrice": "24617.44",
"cumRealisedPnl": "-592.751693",
"positionMM": "0.0000005",
"createdTime": "1637760408825",
"positionIdx": 1,
"positionIM": "0.22714",
"updatedTime": "1676678400081",
"side": "Buy",
"bustPrice": "0.10",
"size": "0.001",
"positionStatus": "Normal",
"stopLoss": "0.00",
"tradeMode": 0,
"symbol": "BTCUSDT",
"leverage": "1",
"avgPrice": "0",
"liqPrice": "",
"riskLimitValue": "6000000",
"takeProfit": "",
"positionValue": "",
"tpslMode": "Full",
"riskId": 3,
"trailingStop": "0",
"unrealisedPnl": "",
"markPrice": "43577.97",
"cumRealisedPnl": "-1618.71655122",
"adlRankIndicator": 0,
"isReduceOnly": false,
"mmrSysUpdatedTime": "",
"leverageSysUpdatedTime": "",
"positionMM": "0",
"positionBalance": "0",
"createdTime": "1677287853003",
"updatedTime": "1691735404177",
"seq": 8093271558,
"positionIdx": 0,
"positionIM": "0",
"side": "",
"bustPrice": "",
"size": "0",
"positionStatus": "Normal",
"stopLoss": "",
"tradeMode": 0,
"autoAddMargin": 0,
},
},
},
Expand Down

0 comments on commit 2f059f9

Please sign in to comment.