diff --git a/config/linregmaker.yaml b/config/linregmaker.yaml index a550aaee0..6b7eda488 100644 --- a/config/linregmaker.yaml +++ b/config/linregmaker.yaml @@ -27,7 +27,7 @@ backtest: makerCommission: 10 # 0.15% takerCommission: 15 # 0.15% balances: - BTC: 10.0 + BTC: 2.0 USDT: 10000.0 exchangeStrategies: @@ -70,7 +70,6 @@ exchangeStrategies: # spread spread: 0.1% - # dynamicSpread dynamicSpread: amplitude: # delete other scaling strategy if this is defined @@ -96,7 +95,7 @@ exchangeStrategies: # when in up band, holds 0.05 by maximum range: [ 0.001, 0.002 ] - maxExposurePosition: 10 + #maxExposurePosition: 10 DynamicExposure: bollBandExposure: interval: "1h" @@ -142,3 +141,8 @@ exchangeStrategies: # when in down band, holds 1.0 by maximum # when in up band, holds 0.05 by maximum range: [ 0, 0.1 ] + + exits: + # roiStopLoss is the stop loss percentage of the position ROI (currently the price change) + - roiStopLoss: + percentage: 20% diff --git a/pkg/strategy/linregmaker/strategy.go b/pkg/strategy/linregmaker/strategy.go index 1ce8481c9..c7492034a 100644 --- a/pkg/strategy/linregmaker/strategy.go +++ b/pkg/strategy/linregmaker/strategy.go @@ -89,8 +89,7 @@ type Strategy struct { // For ask orders, the ask price is ((bestAsk + bestBid) / 2 * (1.0 + spread)) // For bid orders, the bid price is ((bestAsk + bestBid) / 2 * (1.0 - spread)) // Spread can be set by percentage or floating number. e.g., 0.1% or 0.001 - // TODO: if nil? - Spread fixedpoint.Value `json:"spread,omitempty"` + Spread fixedpoint.Value `json:"spread"` // BidSpread overrides the spread setting, this spread will be used for the buy order BidSpread fixedpoint.Value `json:"bidSpread,omitempty"` @@ -104,8 +103,7 @@ type Strategy struct { // MaxExposurePosition is the maximum position you can hold // 10 means you can hold 10 ETH long/short position by maximum - // TODO: if nil? - MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition,omitempty"` + MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"` // DynamicExposure is used to define the exposure position range with the given percentage. // When DynamicExposure is set, your MaxExposurePosition will be calculated dynamically @@ -429,6 +427,11 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se s.useTickerPrice = true } + // Default spread + if s.Spread == fixedpoint.Zero { + s.Spread = fixedpoint.NewFromFloat(0.001) + } + // StrategyController s.Status = types.StrategyStatusRunning s.OnSuspend(func() {