move OrderPriceRiskControl to riskcontrol

This commit is contained in:
narumi 2024-05-20 15:13:23 +08:00
parent 5f096bbe0d
commit 8ad85fc365
3 changed files with 6 additions and 4 deletions

View File

@ -1,9 +1,10 @@
package xfixedmaker package riskcontrol
import ( import (
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
indicatorv2 "github.com/c9s/bbgo/pkg/indicator/v2" indicatorv2 "github.com/c9s/bbgo/pkg/indicator/v2"
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
log "github.com/sirupsen/logrus"
) )
type OrderPriceRiskControl struct { type OrderPriceRiskControl struct {

View File

@ -1,4 +1,4 @@
package xfixedmaker package riskcontrol
import ( import (
"testing" "testing"

View File

@ -9,6 +9,7 @@ import (
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/risk/riskcontrol"
"github.com/c9s/bbgo/pkg/strategy/common" "github.com/c9s/bbgo/pkg/strategy/common"
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
) )
@ -42,7 +43,7 @@ type Strategy struct {
market types.Market market types.Market
activeOrderBook *bbgo.ActiveOrderBook activeOrderBook *bbgo.ActiveOrderBook
orderPriceRiskControl *OrderPriceRiskControl orderPriceRiskControl *riskcontrol.OrderPriceRiskControl
} }
func (s *Strategy) Defaults() error { func (s *Strategy) Defaults() error {
@ -120,7 +121,7 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
s.Strategy.Initialize(ctx, s.Environment, tradingSession, s.market, ID, s.InstanceID()) s.Strategy.Initialize(ctx, s.Environment, tradingSession, s.market, ID, s.InstanceID())
s.orderPriceRiskControl = NewOrderPriceRiskControl( s.orderPriceRiskControl = riskcontrol.NewOrderPriceRiskControl(
referenceSession.Indicators(s.Symbol).EMA(s.ReferencePriceEMA), referenceSession.Indicators(s.Symbol).EMA(s.ReferencePriceEMA),
s.OrderPriceLossThreshold, s.OrderPriceLossThreshold,
) )