Skip to content

Commit

Permalink
feat: add portfolio apis for binance
Browse files Browse the repository at this point in the history
  • Loading branch information
linstohu committed Nov 3, 2023
1 parent 1dc4b7c commit 3d81a6d
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 15 deletions.
31 changes: 31 additions & 0 deletions binance/portfoliomargin/rest/types/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2023, LinstoHu
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package types

type Account struct {
UniMMR string `json:"uniMMR"`
AccountEquity string `json:"accountEquity"`
ActualEquity string `json:"actualEquity"`
AccountInitialMargin string `json:"accountInitialMargin"`
AccountMaintMargin string `json:"accountMaintMargin"`
AccountStatus string `json:"accountStatus"`
VirtualMaxWithdrawAmount string `json:"virtualMaxWithdrawAmount"`
TotalAvailableBalance string `json:"totalAvailableBalance"`
TotalMarginOpenLoss string `json:"totalMarginOpenLoss"`
UpdateTime int64 `json:"updateTime"`
}
13 changes: 0 additions & 13 deletions binance/portfoliomargin/rest/types/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,3 @@ type Balance struct {
CmUnrealizedPNL string `json:"cmUnrealizedPNL"`
UpdateTime int64 `json:"updateTime"`
}

type Account struct {
UniMMR string `json:"uniMMR"`
AccountEquity string `json:"accountEquity"`
ActualEquity string `json:"actualEquity"`
AccountInitialMargin string `json:"accountInitialMargin"`
AccountMaintMargin string `json:"accountMaintMargin"`
AccountStatus string `json:"accountStatus"`
VirtualMaxWithdrawAmount string `json:"virtualMaxWithdrawAmount"`
TotalAvailableBalance string `json:"totalAvailableBalance"`
TotalMarginOpenLoss string `json:"totalMarginOpenLoss"`
UpdateTime int64 `json:"updateTime"`
}
45 changes: 45 additions & 0 deletions binance/portfoliomargin/rest/types/cm_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023, LinstoHu
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package types

type CMAccount struct {
Assets []struct {
Asset string `json:"asset"`
CrossWalletBalance string `json:"crossWalletBalance"`
CrossUnPnl string `json:"crossUnPnl"`
MaintMargin string `json:"maintMargin"`
InitialMargin string `json:"initialMargin"`
PositionInitialMargin string `json:"positionInitialMargin"`
OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
UpdateTime int64 `json:"updateTime"`
} `json:"assets"`
Positions []struct {
Symbol string `json:"symbol"`
PositionAmt string `json:"positionAmt"`
InitialMargin string `json:"initialMargin"`
MaintMargin string `json:"maintMargin"`
UnrealizedProfit string `json:"unrealizedProfit"`
PositionInitialMargin string `json:"positionInitialMargin"`
OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
Leverage string `json:"leverage"`
PositionSide string `json:"positionSide"`
EntryPrice string `json:"entryPrice"`
MaxQty string `json:"maxQty"`
UpdateTime int64 `json:"updateTime"`
} `json:"positions"`
}
47 changes: 47 additions & 0 deletions binance/portfoliomargin/rest/types/um_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2023, LinstoHu
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package types

type UMAccount struct {
Assets []struct {
Asset string `json:"asset"`
CrossWalletBalance string `json:"crossWalletBalance"`
CrossUnPnl string `json:"crossUnPnl"`
MaintMargin string `json:"maintMargin"`
InitialMargin string `json:"initialMargin"`
PositionInitialMargin string `json:"positionInitialMargin"`
OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
UpdateTime int64 `json:"updateTime"`
} `json:"assets"`
Positions []struct {
Symbol string `json:"symbol"`
InitialMargin string `json:"initialMargin"`
MaintMargin string `json:"maintMargin"`
UnrealizedProfit string `json:"unrealizedProfit"`
PositionInitialMargin string `json:"positionInitialMargin"`
OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
Leverage string `json:"leverage"`
EntryPrice string `json:"entryPrice"`
MaxNotional string `json:"maxNotional"`
BidNotional string `json:"bidNotional"`
AskNotional string `json:"askNotional"`
PositionSide string `json:"positionSide"`
PositionAmt string `json:"positionAmt"`
UpdateTime int64 `json:"updateTime"`
} `json:"positions"`
}
2 changes: 1 addition & 1 deletion binance/spot/wallet/types/funding_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "github.com/linstohu/nexapi/binance/utils"

type GetFundingAssetParam struct {
Asset string `url:"asset,omitempty" validate:"omitempty"`
NeedBtcValuation string `url:"needBtcValuation,omitempty" validate:"omitempty"`
NeedBtcValuation bool `url:"needBtcValuation,omitempty" validate:"omitempty"`
}

type GetFundingAssetParams struct {
Expand Down
2 changes: 1 addition & 1 deletion binance/spot/wallet/types/user_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "github.com/linstohu/nexapi/binance/utils"

type GetUserAssetParam struct {
Asset string `url:"asset,omitempty" validate:"omitempty"`
NeedBtcValuation string `url:"needBtcValuation,omitempty" validate:"omitempty"`
NeedBtcValuation bool `url:"needBtcValuation,omitempty" validate:"omitempty"`
}

type GetUserAssetParams struct {
Expand Down

0 comments on commit 3d81a6d

Please sign in to comment.