mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
riskcontrol: move parameter order
This commit is contained in:
parent
c8ae36ddfc
commit
adbb6d7f93
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user