From f1f5f1ff3ac8ade7fc33fd66341d06a2ab1a50d7 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 20 Nov 2024 15:09:18 +0800 Subject: [PATCH] xmaker: solve scale in the Initialize() call --- pkg/strategy/xmaker/strategy.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index 16fc1e181..755988cb5 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -320,6 +320,29 @@ func (s *Strategy) Initialize() error { "exchange": s.MakerExchange, "symbol": s.Symbol, } + + if s.SignalReverseSideMarginScale != nil { + scale, err := s.SignalReverseSideMarginScale.Scale() + if err != nil { + return err + } + + if solveErr := scale.Solve(); solveErr != nil { + return solveErr + } + } + + if s.SignalTrendSideMarginScale != nil { + scale, err := s.SignalTrendSideMarginScale.Scale() + if err != nil { + return err + } + + if solveErr := scale.Solve(); solveErr != nil { + return solveErr + } + } + return nil } @@ -1805,10 +1828,6 @@ func (s *Strategy) CrossRun( return err } - if solveErr := scale.Solve(); solveErr != nil { - return solveErr - } - minAdditionalMargin := scale.Call(0.0) middleAdditionalMargin := scale.Call(1.0) maxAdditionalMargin := scale.Call(2.0)