Skip to content

Commit

Permalink
Merge branch 'fix/open-positions-data-type' into 'main'
Browse files Browse the repository at this point in the history
change open/modify date format to float64 in open positions

See merge request whitebit_exchange/go-sdk!15
  • Loading branch information
whitebit-robot committed Apr 9, 2024
2 parents f245519 + 4bb8eea commit b7e4f76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions module/account/collateral/position_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import (
const openPositionsEndpointUrl = "/api/v4/collateral-account/positions/open"

type OpenPosition struct {
PositionID int64 `json:"positionId"`
Market string `json:"market"`
OpenDate string `json:"openDate"`
ModifyDate string `json:"modifyDate"`
Amount string `json:"amount"`
BasePrice string `json:"basePrice"`
LiquidationPrice string `json:"liquidationPrice"`
Leverage string `json:"leverage"`
Pnl string `json:"pnl"`
PnlPercent string `json:"pnlPercent"`
Margin string `json:"margin"`
FreeMargin string `json:"freeMargin"`
Funding string `json:"funding"`
UnrealizedFunding string `json:"unrealizedFunding"`
LiquidationState string `json:"liquidationState"`
PositionID int64 `json:"positionId"`
Market string `json:"market"`
OpenDate float64 `json:"openDate"`
ModifyDate float64 `json:"modifyDate"`
Amount string `json:"amount"`
BasePrice string `json:"basePrice"`
LiquidationPrice string `json:"liquidationPrice"`
Leverage string `json:"leverage"`
Pnl string `json:"pnl"`
PnlPercent string `json:"pnlPercent"`
Margin string `json:"margin"`
FreeMargin string `json:"freeMargin"`
Funding string `json:"funding"`
UnrealizedFunding string `json:"unrealizedFunding"`
LiquidationState string `json:"liquidationState"`
}

type openPositionsEndpoint struct {
Expand Down
6 changes: 3 additions & 3 deletions module/account/collateral/position_open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func (s *CollateralAccountTestSuite) TestOpenPositionWithResult() {
expectedServerResponse := []OpenPosition{
{PositionID: 664, Market: "BTC_USDT", OpenDate: "1669338402.712101", ModifyDate: "1669375581.3410611",
{PositionID: 664, Market: "BTC_USDT", OpenDate: 1669338402.712101, ModifyDate: 1669375581.3410611,
Amount: "100", BasePrice: "16558.5199706587661", LiquidationPrice: "8568.62", Leverage: "5",
Pnl: "-11629.86", PnlPercent: "-0.70", Margin: "371610.4", FreeMargin: "1379086.41", Funding: "0",
UnrealizedFunding: "0", LiquidationState: ""}}
Expand All @@ -21,8 +21,8 @@ func (s *CollateralAccountTestSuite) TestOpenPositionWithResult() {

s.Equal(expectedRequest, request.URL.String())

byteResponse := []byte(`[{"positionId":664,"market":"BTC_USDT","openDate":"1669338402.712101",
"modifyDate":"1669375581.3410611","amount":"100","basePrice":"16558.5199706587661","liquidationPrice":"8568.62",
byteResponse := []byte(`[{"positionId":664,"market":"BTC_USDT","openDate":1669338402.712101,
"modifyDate":1669375581.3410611,"amount":"100","basePrice":"16558.5199706587661","liquidationPrice":"8568.62",
"leverage":"5","pnl":"-11629.86","pnlPercent":"-0.70","margin":"371610.4","freeMargin":"1379086.41",
"funding":"0","unrealizedFunding":"0","liquidationState":""}]`)
s.client.On("SendRequest", mock.Anything).Return(byteResponse, nil).Once()
Expand Down

0 comments on commit b7e4f76

Please sign in to comment.