From 044470377b735e4c119e754c9c1a2a82de962a58 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 27 Apr 2022 17:13:58 +0800 Subject: [PATCH] avoid using the iterator variable --- pkg/bbgo/environment.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/bbgo/environment.go b/pkg/bbgo/environment.go index 4f7ddd4d2..3a0a9bdd4 100644 --- a/pkg/bbgo/environment.go +++ b/pkg/bbgo/environment.go @@ -504,14 +504,16 @@ func (environ *Environment) BindSync(config *SyncConfig) { } for _, session := range environ.sessions { + // avoid using the iterator variable. + s2 := session // if trade sync is on, we will write all received trades if config.UserDataStream.Trades { - tradeWriter := tradeWriterCreator(session) + tradeWriter := tradeWriterCreator(s2) session.UserDataStream.OnTradeUpdate(tradeWriter) } if config.UserDataStream.FilledOrders { - orderWriter := orderWriterCreator(session) + orderWriter := orderWriterCreator(s2) session.UserDataStream.OnOrderUpdate(orderWriter) } }