mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +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"`
|
||||
}
|
||||
|
||||
//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 {
|
||||
client requestgen.AuthenticatedAPIClient
|
||||
|
||||
// Account type
|
||||
// - Unified account: UNIFIED (trade spot/linear/options), CONTRACT(trade inverse)
|
||||
// - Normal account: CONTRACT, SPOT
|
||||
accountType AccountType `param:"accountType,query" validValues:"SPOT"`
|
||||
accountType AccountType `param:"accountType,query" validValues:"UNIFIED"`
|
||||
// Coin name
|
||||
// - If not passed, it returns non-zero asset info
|
||||
// - You can pass multiple coins to query, separated by comma. USDT,USDC
|
||||
|
@ -87,6 +87,6 @@ type GetWalletBalancesRequest struct {
|
|||
func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest {
|
||||
return &GetWalletBalancesRequest{
|
||||
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
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
|||
"regexp"
|
||||
)
|
||||
|
||||
var GetWalletBalancesRequestLimiter = rate.NewLimiter(15.000000150000002, 1)
|
||||
var GetWalletBalancesRequestLimiter = rate.NewLimiter(45.00000045, 1)
|
||||
|
||||
func (g *GetWalletBalancesRequest) AccountType(accountType AccountType) *GetWalletBalancesRequest {
|
||||
g.accountType = accountType
|
||||
|
@ -32,7 +32,7 @@ func (g *GetWalletBalancesRequest) GetQueryParameters() (url.Values, error) {
|
|||
|
||||
// TEMPLATE check-valid-values
|
||||
switch accountType {
|
||||
case "SPOT":
|
||||
case "UNIFIED":
|
||||
params["accountType"] = accountType
|
||||
|
||||
default:
|
||||
|
|
|
@ -127,7 +127,7 @@ const (
|
|||
|
||||
type AccountType string
|
||||
|
||||
const AccountTypeSpot AccountType = "SPOT"
|
||||
const AccountTypeUnified AccountType = "UNIFIED"
|
||||
|
||||
type MarketUnit string
|
||||
|
||||
|
|
|
@ -362,14 +362,14 @@ func toGlobalTrade(trade bybitapi.Trade) (*types.Trade, error) {
|
|||
func toGlobalBalanceMap(events []bybitapi.WalletBalances) types.BalanceMap {
|
||||
bm := types.BalanceMap{}
|
||||
for _, event := range events {
|
||||
if event.AccountType != bybitapi.AccountTypeSpot {
|
||||
if event.AccountType != bybitapi.AccountTypeUnified {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, obj := range event.Coins {
|
||||
bm[obj.Coin] = types.Balance{
|
||||
Currency: obj.Coin,
|
||||
Available: obj.Free,
|
||||
Available: obj.WalletBalance.Sub(obj.Locked),
|
||||
Locked: obj.Locked,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user