From 3d81a6db79a0342749e2a9c19f3a67daa402ea3c Mon Sep 17 00:00:00 2001 From: linsto Date: Fri, 3 Nov 2023 11:02:24 +0800 Subject: [PATCH] feat: add portfolio apis for binance --- binance/portfoliomargin/rest/types/account.go | 31 ++++++++++++ binance/portfoliomargin/rest/types/balance.go | 13 ----- .../portfoliomargin/rest/types/cm_account.go | 45 ++++++++++++++++++ .../portfoliomargin/rest/types/um_account.go | 47 +++++++++++++++++++ binance/spot/wallet/types/funding_wallet.go | 2 +- binance/spot/wallet/types/user_asset.go | 2 +- 6 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 binance/portfoliomargin/rest/types/account.go create mode 100644 binance/portfoliomargin/rest/types/cm_account.go create mode 100644 binance/portfoliomargin/rest/types/um_account.go diff --git a/binance/portfoliomargin/rest/types/account.go b/binance/portfoliomargin/rest/types/account.go new file mode 100644 index 0000000..aa9c4f2 --- /dev/null +++ b/binance/portfoliomargin/rest/types/account.go @@ -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"` +} diff --git a/binance/portfoliomargin/rest/types/balance.go b/binance/portfoliomargin/rest/types/balance.go index eb472fb..ed051e0 100644 --- a/binance/portfoliomargin/rest/types/balance.go +++ b/binance/portfoliomargin/rest/types/balance.go @@ -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"` -} diff --git a/binance/portfoliomargin/rest/types/cm_account.go b/binance/portfoliomargin/rest/types/cm_account.go new file mode 100644 index 0000000..22e29b5 --- /dev/null +++ b/binance/portfoliomargin/rest/types/cm_account.go @@ -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"` +} diff --git a/binance/portfoliomargin/rest/types/um_account.go b/binance/portfoliomargin/rest/types/um_account.go new file mode 100644 index 0000000..7b78b33 --- /dev/null +++ b/binance/portfoliomargin/rest/types/um_account.go @@ -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"` +} diff --git a/binance/spot/wallet/types/funding_wallet.go b/binance/spot/wallet/types/funding_wallet.go index 241eba2..24e95d8 100644 --- a/binance/spot/wallet/types/funding_wallet.go +++ b/binance/spot/wallet/types/funding_wallet.go @@ -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 { diff --git a/binance/spot/wallet/types/user_asset.go b/binance/spot/wallet/types/user_asset.go index c8e0fc6..326442b 100644 --- a/binance/spot/wallet/types/user_asset.go +++ b/binance/spot/wallet/types/user_asset.go @@ -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 {