Skip to content

Commit

Permalink
common: pull out RiskController
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jul 10, 2023
1 parent 3b6cff8 commit 3293866
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/strategy/common/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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) {
Expand Down

0 comments on commit 3293866

Please sign in to comment.