mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 11:03:53 +00:00
pkg/exchange: update query wallet balance to latest
This commit is contained in:
parent
0712a8399a
commit
5a4c38caa2
|
@ -70,14 +70,14 @@ type WalletBalances struct {
|
||||||
} `json:"coin"`
|
} `json:"coin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate GetRequest -url "/v5/account/wallet-balance" -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+15/1s
|
//go:generate GetRequest -url "/v5/account/wallet-balance" -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+45/1s
|
||||||
type GetWalletBalancesRequest struct {
|
type GetWalletBalancesRequest struct {
|
||||||
client requestgen.AuthenticatedAPIClient
|
client requestgen.AuthenticatedAPIClient
|
||||||
|
|
||||||
// Account type
|
// Account type
|
||||||
// - Unified account: UNIFIED (trade spot/linear/options), CONTRACT(trade inverse)
|
// - Unified account: UNIFIED (trade spot/linear/options), CONTRACT(trade inverse)
|
||||||
// - Normal account: CONTRACT, SPOT
|
// - Normal account: CONTRACT, SPOT
|
||||||
accountType AccountType `param:"accountType,query" validValues:"SPOT"`
|
accountType AccountType `param:"accountType,query" validValues:"UNIFIED"`
|
||||||
// Coin name
|
// Coin name
|
||||||
// - If not passed, it returns non-zero asset info
|
// - If not passed, it returns non-zero asset info
|
||||||
// - You can pass multiple coins to query, separated by comma. USDT,USDC
|
// - You can pass multiple coins to query, separated by comma. USDT,USDC
|
||||||
|
@ -87,6 +87,6 @@ type GetWalletBalancesRequest struct {
|
||||||
func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest {
|
func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest {
|
||||||
return &GetWalletBalancesRequest{
|
return &GetWalletBalancesRequest{
|
||||||
client: c,
|
client: c,
|
||||||
accountType: AccountTypeSpot,
|
accountType: AccountTypeUnified,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Result -url /v5/account/wallet-balance -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+15/1s"; DO NOT EDIT.
|
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Result -url /v5/account/wallet-balance -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+45/1s"; DO NOT EDIT.
|
||||||
|
|
||||||
package bybitapi
|
package bybitapi
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GetWalletBalancesRequestLimiter = rate.NewLimiter(15.000000150000002, 1)
|
var GetWalletBalancesRequestLimiter = rate.NewLimiter(45.00000045, 1)
|
||||||
|
|
||||||
func (g *GetWalletBalancesRequest) AccountType(accountType AccountType) *GetWalletBalancesRequest {
|
func (g *GetWalletBalancesRequest) AccountType(accountType AccountType) *GetWalletBalancesRequest {
|
||||||
g.accountType = accountType
|
g.accountType = accountType
|
||||||
|
@ -32,7 +32,7 @@ func (g *GetWalletBalancesRequest) GetQueryParameters() (url.Values, error) {
|
||||||
|
|
||||||
// TEMPLATE check-valid-values
|
// TEMPLATE check-valid-values
|
||||||
switch accountType {
|
switch accountType {
|
||||||
case "SPOT":
|
case "UNIFIED":
|
||||||
params["accountType"] = accountType
|
params["accountType"] = accountType
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -127,7 +127,7 @@ const (
|
||||||
|
|
||||||
type AccountType string
|
type AccountType string
|
||||||
|
|
||||||
const AccountTypeSpot AccountType = "SPOT"
|
const AccountTypeUnified AccountType = "UNIFIED"
|
||||||
|
|
||||||
type MarketUnit string
|
type MarketUnit string
|
||||||
|
|
||||||
|
|
|
@ -362,14 +362,14 @@ func toGlobalTrade(trade bybitapi.Trade) (*types.Trade, error) {
|
||||||
func toGlobalBalanceMap(events []bybitapi.WalletBalances) types.BalanceMap {
|
func toGlobalBalanceMap(events []bybitapi.WalletBalances) types.BalanceMap {
|
||||||
bm := types.BalanceMap{}
|
bm := types.BalanceMap{}
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
if event.AccountType != bybitapi.AccountTypeSpot {
|
if event.AccountType != bybitapi.AccountTypeUnified {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, obj := range event.Coins {
|
for _, obj := range event.Coins {
|
||||||
bm[obj.Coin] = types.Balance{
|
bm[obj.Coin] = types.Balance{
|
||||||
Currency: obj.Coin,
|
Currency: obj.Coin,
|
||||||
Available: obj.Free,
|
Available: obj.WalletBalance.Sub(obj.Locked),
|
||||||
Locked: obj.Locked,
|
Locked: obj.Locked,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user