From 6f391c7a1f5df648d667d47194fd88a78199cf77 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 9 Sep 2024 18:03:03 +0800 Subject: [PATCH] xmaker: fix sides --- pkg/strategy/xmaker/strategy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index 6baa75f..a2b86f6 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -937,7 +937,7 @@ func aggregatePriceVolumeSliceWithPriceFilter(pvs types.PriceVolumeSlice, filter // tryArbitrage tries to arbitrage between the source and maker exchange func (s *Strategy) tryArbitrage(ctx context.Context, quote *Quote) (bool, error) { marginBidPrice := quote.BestBidPrice.Mul(fixedpoint.One.Sub(quote.BidMargin)) - marginAskPrice := quote.BestAskPrice.Mul(fixedpoint.One.Add(quote.BidMargin)) + marginAskPrice := quote.BestAskPrice.Mul(fixedpoint.One.Add(quote.AskMargin)) var iocOrders []types.SubmitOrder if makerBid, makerAsk, ok := s.makerBook.BestBidAndAsk(); ok { @@ -955,8 +955,8 @@ func (s *Strategy) tryArbitrage(ctx context.Context, quote *Quote) (bool, error) }) } else if makerBid.Price.Compare(marginAskPrice) >= 0 { - askPvs := s.makerBook.SideBook(types.SideTypeSell) - sumPv := aggregatePriceVolumeSliceWithPriceFilter(askPvs, marginBidPrice) + bidPvs := s.makerBook.SideBook(types.SideTypeBuy) + sumPv := aggregatePriceVolumeSliceWithPriceFilter(bidPvs, marginBidPrice) // send ioc order for arbitrage iocOrders = append(iocOrders, types.SubmitOrder{