From ec4f43b1000dc475f2289f369ea73973d6356a1b Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 19 Dec 2023 21:55:38 +0800 Subject: [PATCH] bollmaker: support custom quantity --- pkg/strategy/bollmaker/strategy.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/strategy/bollmaker/strategy.go b/pkg/strategy/bollmaker/strategy.go index d8f32b8c2..05e7d3c2e 100644 --- a/pkg/strategy/bollmaker/strategy.go +++ b/pkg/strategy/bollmaker/strategy.go @@ -58,6 +58,12 @@ type Strategy struct { bbgo.QuantityOrAmount + // BidQuantity is used for placing buy order, this will override the default quantity + BidQuantity fixedpoint.Value `json:"bidQuantity"` + + // AskQuantity is used for placing sell order, this will override the default quantity + AskQuantity fixedpoint.Value `json:"askQuantity"` + // TrendEMA is used for detecting the trend by a given EMA // you can define interval and window TrendEMA *bbgo.TrendEMA `json:"trendEMA"` @@ -251,8 +257,15 @@ func (s *Strategy) placeOrders(ctx context.Context, midPrice fixedpoint.Value, k s.Position, ) - sellQuantity := s.QuantityOrAmount.CalculateQuantity(askPrice) - buyQuantity := s.QuantityOrAmount.CalculateQuantity(bidPrice) + sellQuantity := s.AskQuantity + if sellQuantity.IsZero() { + sellQuantity = s.QuantityOrAmount.CalculateQuantity(askPrice) + } + + buyQuantity := s.BidQuantity + if buyQuantity.IsZero() { + buyQuantity = s.QuantityOrAmount.CalculateQuantity(bidPrice) + } sellOrder := types.SubmitOrder{ Symbol: s.Symbol,