Skip to content

Commit

Permalink
refactor: binance api response
Browse files Browse the repository at this point in the history
  • Loading branch information
linstohu committed Dec 25, 2023
1 parent 1b53b38 commit 1fefe3f
Show file tree
Hide file tree
Showing 23 changed files with 704 additions and 376 deletions.
508 changes: 321 additions & 187 deletions binance/usdmfutures/account/client.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions binance/usdmfutures/account/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

package types

import "github.com/linstohu/nexapi/utils"

type GetAccountInfoResp struct {
Http *utils.ApiResponse
Body *Account
}

type Account struct {
FeeTier int `json:"feeTier"`
CanTrade bool `json:"canTrade"`
Expand Down
7 changes: 7 additions & 0 deletions binance/usdmfutures/account/types/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package types

import "github.com/linstohu/nexapi/utils"

type Balance struct {
AccountAlias string `json:"accountAlias"`
Asset string `json:"asset"`
Expand All @@ -28,3 +30,8 @@ type Balance struct {
MarginAvailable bool `json:"marginAvailable"`
UpdateTime int64 `json:"updateTime"`
}

type GetBalanceResp struct {
Http *utils.ApiResponse
Body []*Balance
}
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/leverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types

import (
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type ChangeLeverageParam struct {
Expand All @@ -32,6 +33,11 @@ type ChangeLeverageParams struct {
}

type ChangeLeverageResp struct {
Http *utils.ApiResponse
Body *ChangeLeverageAPIResp
}

type ChangeLeverageAPIResp struct {
Leverage int `json:"leverage"`
MaxNotionalValue string `json:"maxNotionalValue"`
Symbol string `json:"symbol"`
Expand Down
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/margin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package types
import (
umutils "github.com/linstohu/nexapi/binance/usdmfutures/utils"
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type ChangeMarginTypeParam struct {
Expand All @@ -45,6 +46,11 @@ type ModifyIsolatedPositionMarginParams struct {
}

type ModifyIsolatedPositionMarginResp struct {
Http *utils.ApiResponse
Body *ModifyIsolatedPositionMarginAPIResp
}

type ModifyIsolatedPositionMarginAPIResp struct {
Amount float64 `json:"amount"`
Code int `json:"code"`
Msg string `json:"msg"`
Expand Down
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/multi_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types

import (
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type ChangeMultiAssetsModeParam struct {
Expand All @@ -31,5 +32,10 @@ type ChangeMultiAssetsModeParams struct {
}

type GetCurrentMultiAssetsModeResp struct {
Http *utils.ApiResponse
Body *GetCurrentMultiAssetsModeAPIResp
}

type GetCurrentMultiAssetsModeAPIResp struct {
MultiAssetsMargin bool `json:"multiAssetsMargin"`
}
11 changes: 11 additions & 0 deletions binance/usdmfutures/account/types/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package types
import (
umutils "github.com/linstohu/nexapi/binance/usdmfutures/utils"
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type Order struct {
Expand Down Expand Up @@ -69,6 +70,16 @@ type NewOrderParams struct {
bnutils.DefaultParam
}

type OrderResp struct {
Http *utils.ApiResponse
Body *Order
}

type OrdersResp struct {
Http *utils.ApiResponse
Body []*Order
}

type GetOrderParam struct {
Symbol string `url:"symbol" validate:"required"`
OrderID int64 `url:"orderId,omitempty" validate:"omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types

import (
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type GetPositionParam struct {
Expand All @@ -30,6 +31,11 @@ type GetPositionParams struct {
bnutils.DefaultParam
}

type GetPositionResp struct {
Http *utils.ApiResponse
Body []*Position
}

type Position struct {
EntryPrice string `json:"entryPrice"`
MarginType string `json:"marginType"`
Expand Down
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/position_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types

import (
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type ChangePositionModeParam struct {
Expand All @@ -31,5 +32,10 @@ type ChangePositionModeParams struct {
}

type GetCurrentPositionModeResp struct {
Http *utils.ApiResponse
Body *GetCurrentPositionModeAPIResp
}

type GetCurrentPositionModeAPIResp struct {
DualSidePosition bool `json:"dualSidePosition"`
}
7 changes: 7 additions & 0 deletions binance/usdmfutures/account/types/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

package types

import "github.com/linstohu/nexapi/utils"

type DefaultResp struct {
Http *utils.ApiResponse
Body *Response
}

type Response struct {
Code int `json:"code"`
Message string `json:"msg"`
Expand Down
6 changes: 6 additions & 0 deletions binance/usdmfutures/account/types/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types

import (
bnutils "github.com/linstohu/nexapi/binance/utils"
"github.com/linstohu/nexapi/utils"
)

type GetTradeListParam struct {
Expand All @@ -35,6 +36,11 @@ type GetTradeListParams struct {
bnutils.DefaultParam
}

type GetTradeListResp struct {
Http *utils.ApiResponse
Body []*Trade
}

type Trade struct {
Buyer bool `json:"buyer"`
Commission string `json:"commission"`
Expand Down
Loading

0 comments on commit 1fefe3f

Please sign in to comment.