mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
move balance printing to debug-balance env var
This commit is contained in:
parent
f80c98b97c
commit
b8fe100b5e
|
@ -6,10 +6,17 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
)
|
||||
|
||||
var debugBalance = false
|
||||
|
||||
func init() {
|
||||
debugBalance = viper.GetBool("debug-balance")
|
||||
}
|
||||
|
||||
type Balance struct {
|
||||
Currency string `json:"currency"`
|
||||
Available fixedpoint.Value `json:"available"`
|
||||
|
@ -216,13 +223,16 @@ func (a *Account) UpdateBalances(balances BalanceMap) {
|
|||
}
|
||||
}
|
||||
|
||||
func printBalanceUpdate(balances BalanceMap) {
|
||||
logrus.Infof("balance update: %+v", balances)
|
||||
}
|
||||
|
||||
func (a *Account) BindStream(stream Stream) {
|
||||
stream.OnBalanceUpdate(a.UpdateBalances)
|
||||
stream.OnBalanceSnapshot(a.UpdateBalances)
|
||||
stream.OnBalanceUpdate(func(balances BalanceMap) {
|
||||
logrus.Infof("balance update: %+v", balances)
|
||||
})
|
||||
|
||||
if debugBalance {
|
||||
stream.OnBalanceUpdate(printBalanceUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Account) Print() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user