mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
bbgo: add DisableStartupBalanceQuery option
This commit is contained in:
parent
08a09c2fee
commit
3ea333fd52
|
@ -329,6 +329,11 @@ type ServiceConfig struct {
|
|||
type EnvironmentConfig struct {
|
||||
DisableDefaultKLineSubscription bool `json:"disableDefaultKLineSubscription"`
|
||||
DisableHistoryKLinePreload bool `json:"disableHistoryKLinePreload"`
|
||||
|
||||
// DisableStartUpBalanceQuery disables the balance query in the startup process
|
||||
// which initializes the session.Account with the QueryAccount method.
|
||||
DisableStartupBalanceQuery bool `json:"disableStartupBalanceQuery"`
|
||||
|
||||
DisableSessionTradeBuffer bool `json:"disableSessionTradeBuffer"`
|
||||
MaxSessionTradeBufferSize int `json:"maxSessionTradeBufferSize"`
|
||||
}
|
||||
|
|
|
@ -256,6 +256,12 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
|
|||
}
|
||||
}
|
||||
|
||||
disableStartupBalanceQuery := environ.environmentConfig != nil && environ.environmentConfig.DisableStartupBalanceQuery
|
||||
if disableStartupBalanceQuery {
|
||||
session.accountMutex.Lock()
|
||||
session.Account = types.NewAccount()
|
||||
session.accountMutex.Unlock()
|
||||
} else {
|
||||
logger.Infof("querying account balances...")
|
||||
account, err := session.Exchange.QueryAccount(ctx)
|
||||
if err != nil {
|
||||
|
@ -265,6 +271,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
|
|||
session.accountMutex.Lock()
|
||||
session.Account = account
|
||||
session.accountMutex.Unlock()
|
||||
}
|
||||
|
||||
logger.Infof("account %s balances:\n%s", session.Name, account.Balances().String())
|
||||
|
||||
|
|
|
@ -103,8 +103,26 @@ type IsolatedMarginAccountInfo struct {
|
|||
|
||||
func NewAccount() *Account {
|
||||
return &Account{
|
||||
AccountType: "spot",
|
||||
FuturesInfo: nil,
|
||||
MarginInfo: nil,
|
||||
IsolatedMarginInfo: nil,
|
||||
MarginLevel: fixedpoint.Zero,
|
||||
MarginTolerance: fixedpoint.Zero,
|
||||
BorrowEnabled: false,
|
||||
TransferEnabled: false,
|
||||
MarginRatio: fixedpoint.Zero,
|
||||
LiquidationPrice: fixedpoint.Zero,
|
||||
LiquidationRate: fixedpoint.Zero,
|
||||
MakerFeeRate: fixedpoint.Zero,
|
||||
TakerFeeRate: fixedpoint.Zero,
|
||||
TotalAccountValue: fixedpoint.Zero,
|
||||
CanDeposit: false,
|
||||
CanTrade: false,
|
||||
CanWithdraw: false,
|
||||
balances: make(BalanceMap),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Balances lock the balances and returned the copied balances
|
||||
|
|
Loading…
Reference in New Issue
Block a user