common: pull out RiskController

This commit is contained in:
c9s 2023-07-10 15:27:36 +08:00
parent 3b6cff8dc7
commit 3293866a6c
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -11,6 +11,16 @@ import (
"github.com/c9s/bbgo/pkg/types" "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. // Strategy provides the core functionality that is required by a long/short strategy.
type Strategy struct { type Strategy struct {
Position *types.Position `json:"position,omitempty" persistence:"position"` Position *types.Position `json:"position,omitempty" persistence:"position"`
@ -23,13 +33,7 @@ type Strategy struct {
Session *bbgo.ExchangeSession Session *bbgo.ExchangeSession
OrderExecutor *bbgo.GeneralOrderExecutor OrderExecutor *bbgo.GeneralOrderExecutor
PositionHardLimit fixedpoint.Value `json:"positionHardLimit"` RiskController
MaxPositionQuantity fixedpoint.Value `json:"maxPositionQuantity"`
CircuitBreakLossThreshold fixedpoint.Value `json:"circuitBreakLossThreshold"`
CircuitBreakEMA types.IntervalWindow `json:"circuitBreakEMA"`
positionRiskControl *riskcontrol.PositionRiskControl
circuitBreakRiskControl *riskcontrol.CircuitBreakRiskControl
} }
func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, session *bbgo.ExchangeSession, market types.Market, strategyID, instanceID string) { func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, session *bbgo.ExchangeSession, market types.Market, strategyID, instanceID string) {