Skip to content

Commit

Permalink
Merge pull request c9s#1462 from c9s/c9s/bollmaker-custom-quantity
Browse files Browse the repository at this point in the history
FEATURE: [bollmaker] support custom quantity
  • Loading branch information
c9s authored Dec 19, 2023
2 parents 66a90c5 + ec4f43b commit f047e75
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/strategy/bollmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f047e75

Please sign in to comment.