From c5cd6bc95e764438ad226f90a43533a5378a292d Mon Sep 17 00:00:00 2001 From: narumi Date: Fri, 29 Sep 2023 01:12:53 +0800 Subject: [PATCH] fix common.Strategy.IsHalted --- config/fixedmaker.yaml | 19 ++++--------------- pkg/strategy/common/strategy.go | 3 +++ pkg/strategy/fixedmaker/strategy.go | 4 ++-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/config/fixedmaker.yaml b/config/fixedmaker.yaml index cdd474c02..98f213029 100644 --- a/config/fixedmaker.yaml +++ b/config/fixedmaker.yaml @@ -2,20 +2,9 @@ exchangeStrategies: - on: max fixedmaker: - interval: 5m symbol: BTCUSDT - halfSpreadRatio: 0.05% + interval: 5m + halfSpread: 0.05% quantity: 0.005 - dryRun: false - - - on: max - rebalance: - interval: 1h - quoteCurrency: USDT - targetWeights: - BTC: 50% - USDT: 50% - threshold: 2% - maxAmount: 200 # max amount to buy or sell per order - orderType: LIMIT_MAKER # LIMIT, LIMIT_MAKER or MARKET - dryRun: false + orderType: LIMIT_MAKER + dryRun: true diff --git a/pkg/strategy/common/strategy.go b/pkg/strategy/common/strategy.go index 4ad94e532..1ed590a84 100644 --- a/pkg/strategy/common/strategy.go +++ b/pkg/strategy/common/strategy.go @@ -90,5 +90,8 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se } func (s *Strategy) IsHalted(t time.Time) bool { + if s.circuitBreakRiskControl == nil { + return false + } return s.circuitBreakRiskControl.IsHalted(t) } diff --git a/pkg/strategy/fixedmaker/strategy.go b/pkg/strategy/fixedmaker/strategy.go index af4ed77c6..28de0a917 100644 --- a/pkg/strategy/fixedmaker/strategy.go +++ b/pkg/strategy/fixedmaker/strategy.go @@ -155,8 +155,8 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context) ([]types.SubmitOrde log.Infof("mid price: %+v", midPrice) // calculate bid and ask price - // ask price = mid price * (1 + r)) - // bid price = mid price * (1 - r)) + // sell price = mid price * (1 + r)) + // buy price = mid price * (1 - r)) sellPrice := midPrice.Mul(fixedpoint.One.Add(s.HalfSpread)).Round(s.Market.PricePrecision, fixedpoint.Up) buyPrice := midPrice.Mul(fixedpoint.One.Sub(s.HalfSpread)).Round(s.Market.PricePrecision, fixedpoint.Down) log.Infof("sell price: %s, buy price: %s", sellPrice.String(), buyPrice.String())