Skip to content

Commit

Permalink
xmaker: fix quantity adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Nov 29, 2024
1 parent 3b009a9 commit daeef13
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/strategy/xmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ func (s *Strategy) updateQuote(ctx context.Context) error {
makerQuota.QuoteAsset.Available,
)

bidQuantity = s.makerMarket.TruncateQuantity(requiredQuote.Div(bidPrice))

// if we bought, then we need to sell the base from the hedge session
// if the hedge session is a margin session, we don't need to lock the base asset
if makerQuota.QuoteAsset.Lock(requiredQuote) &&
Expand Down Expand Up @@ -1082,6 +1084,7 @@ func (s *Strategy) updateQuote(ctx context.Context) error {
}

requiredBase := fixedpoint.Min(askQuantity, makerQuota.BaseAsset.Available)
askQuantity = requiredBase
if makerQuota.BaseAsset.Lock(requiredBase) &&
(s.sourceSession.Margin || hedgeQuota.QuoteAsset.Lock(requiredBase.Mul(askPrice))) {

Expand Down

0 comments on commit daeef13

Please sign in to comment.