bbgo: bind and update balance metrics updater

This commit is contained in:
c9s 2021-12-27 17:27:16 +08:00
parent 7b629c9d30
commit bb7b33e532
2 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ var (
}, },
[]string{ []string{
"exchange", // exchange name "exchange", // exchange name
"margin", // margin of connection. 1 or 0 "margin", // margin of connection. none, margin or isolated
"symbol", // margin symbol of the connection. "symbol", // margin symbol of the connection.
"currency", "currency",
}, },
@ -49,7 +49,7 @@ var (
}, },
[]string{ []string{
"exchange", // exchange name "exchange", // exchange name
"margin", // margin of connection. 1 or 0 "margin", // margin of connection. none, margin or isolated
"symbol", // margin symbol of the connection. "symbol", // margin symbol of the connection.
"currency", "currency",
}, },
@ -62,8 +62,7 @@ var (
}, },
[]string{ []string{
"exchange", // exchange name "exchange", // exchange name
"margin", // margin of connection. 1 or 0 "margin", // margin of connection. none, margin or isolated
"isolated", // isolated or not
"symbol", // margin symbol of the connection. "symbol", // margin symbol of the connection.
"side", // side: buy or sell "side", // side: buy or sell
"liquidity", // maker or taker "liquidity", // maker or taker
@ -77,8 +76,7 @@ var (
}, },
[]string{ []string{
"exchange", // exchange name "exchange", // exchange name
"margin", // margin of connection. 1 or 0 "margin", // margin of connection. none, margin or isolated
"isolated", // isolated or not
"symbol", // margin symbol of the connection. "symbol", // margin symbol of the connection.
"side", // side: buy or sell "side", // side: buy or sell
"liquidity", // maker or taker "liquidity", // maker or taker

View File

@ -323,6 +323,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
session.UserDataStream.OnOrderUpdate(session.OrderExecutor.EmitOrderUpdate) session.UserDataStream.OnOrderUpdate(session.OrderExecutor.EmitOrderUpdate)
session.Account.BindStream(session.UserDataStream) session.Account.BindStream(session.UserDataStream)
session.metricsBalancesUpdater(balances)
session.bindUserDataStreamMetrics(session.UserDataStream) session.bindUserDataStreamMetrics(session.UserDataStream)
} }
@ -815,5 +816,6 @@ func (session *ExchangeSession) metricsTradeUpdater(trade types.Trade) {
func (session *ExchangeSession) bindUserDataStreamMetrics(stream types.Stream) { func (session *ExchangeSession) bindUserDataStreamMetrics(stream types.Stream) {
stream.OnBalanceUpdate(session.metricsBalancesUpdater) stream.OnBalanceUpdate(session.metricsBalancesUpdater)
stream.OnBalanceSnapshot(session.metricsBalancesUpdater)
stream.OnTradeUpdate(session.metricsTradeUpdater) stream.OnTradeUpdate(session.metricsTradeUpdater)
} }