riskcontrol: move parameter order

This commit is contained in:
c9s 2023-07-04 21:32:34 +08:00
parent c8ae36ddfc
commit adbb6d7f93
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 4 additions and 4 deletions

View File

@ -24,7 +24,7 @@ type PositionRiskControl struct {
releasePositionCallbacks []func(quantity fixedpoint.Value, side types.SideType)
}
func NewPositionRiskControl(hardLimit, quantity fixedpoint.Value, orderExecutor *bbgo.GeneralOrderExecutor) *PositionRiskControl {
func NewPositionRiskControl(orderExecutor *bbgo.GeneralOrderExecutor, hardLimit, quantity fixedpoint.Value) *PositionRiskControl {
control := &PositionRiskControl{
orderExecutor: orderExecutor,
hardLimit: hardLimit,

View File

@ -21,7 +21,7 @@ func Test_ModifiedQuantity(t *testing.T) {
},
}
orderExecutor := bbgo.NewGeneralOrderExecutor(nil, "BTCUSDT", "strategy", "strategy-1", pos)
riskControl := NewPositionRiskControl(fixedpoint.NewFromInt(10), fixedpoint.NewFromInt(2), orderExecutor)
riskControl := NewPositionRiskControl(orderExecutor, fixedpoint.NewFromInt(10), fixedpoint.NewFromInt(2))
cases := []struct {
name string
@ -92,7 +92,7 @@ func TestReleasePositionCallbacks(t *testing.T) {
}
orderExecutor := bbgo.NewGeneralOrderExecutor(nil, "BTCUSDT", "strategy", "strategy-1", pos)
riskControl := NewPositionRiskControl(fixedpoint.NewFromInt(10), fixedpoint.NewFromInt(2), orderExecutor)
riskControl := NewPositionRiskControl(orderExecutor, fixedpoint.NewFromInt(10), fixedpoint.NewFromInt(2))
riskControl.OnReleasePosition(func(quantity fixedpoint.Value, side types.SideType) {
if side == types.SideTypeBuy {
pos.Base = pos.Base.Add(quantity)

View File

@ -146,7 +146,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
if !s.PositionHardLimit.IsZero() && !s.MaxPositionQuantity.IsZero() {
log.Infof("positionHardLimit and maxPositionQuantity are configured, setting up PositionRiskControl...")
s.positionRiskControl = riskcontrol.NewPositionRiskControl(s.PositionHardLimit, s.MaxPositionQuantity, s.orderExecutor)
s.positionRiskControl = riskcontrol.NewPositionRiskControl(s.orderExecutor, s.PositionHardLimit, s.MaxPositionQuantity)
}
if !s.CircuitBreakLossThreshold.IsZero() {