From 3293866a6c66985d07629ff83ecb064b167aa1e7 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 10 Jul 2023 15:27:36 +0800 Subject: [PATCH] common: pull out RiskController --- pkg/strategy/common/strategy.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/strategy/common/strategy.go b/pkg/strategy/common/strategy.go index 6a076540c..5e2cd2c4d 100644 --- a/pkg/strategy/common/strategy.go +++ b/pkg/strategy/common/strategy.go @@ -11,6 +11,16 @@ import ( "github.com/c9s/bbgo/pkg/types" ) +type RiskController struct { + PositionHardLimit fixedpoint.Value `json:"positionHardLimit"` + MaxPositionQuantity fixedpoint.Value `json:"maxPositionQuantity"` + CircuitBreakLossThreshold fixedpoint.Value `json:"circuitBreakLossThreshold"` + CircuitBreakEMA types.IntervalWindow `json:"circuitBreakEMA"` + + positionRiskControl *riskcontrol.PositionRiskControl + circuitBreakRiskControl *riskcontrol.CircuitBreakRiskControl +} + // Strategy provides the core functionality that is required by a long/short strategy. type Strategy struct { Position *types.Position `json:"position,omitempty" persistence:"position"` @@ -23,13 +33,7 @@ type Strategy struct { Session *bbgo.ExchangeSession OrderExecutor *bbgo.GeneralOrderExecutor - PositionHardLimit fixedpoint.Value `json:"positionHardLimit"` - MaxPositionQuantity fixedpoint.Value `json:"maxPositionQuantity"` - CircuitBreakLossThreshold fixedpoint.Value `json:"circuitBreakLossThreshold"` - CircuitBreakEMA types.IntervalWindow `json:"circuitBreakEMA"` - - positionRiskControl *riskcontrol.PositionRiskControl - circuitBreakRiskControl *riskcontrol.CircuitBreakRiskControl + RiskController } func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, session *bbgo.ExchangeSession, market types.Market, strategyID, instanceID string) {