From 74cac6e97773828b67ccf9825c4ba3304312b332 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 3 Jul 2022 15:44:37 +0800 Subject: [PATCH] pivotshort: adjust layer price calculation --- pkg/strategy/pivotshort/resistance.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/strategy/pivotshort/resistance.go b/pkg/strategy/pivotshort/resistance.go index 195aeee69..200152f1c 100644 --- a/pkg/strategy/pivotshort/resistance.go +++ b/pkg/strategy/pivotshort/resistance.go @@ -112,7 +112,6 @@ func (s *ResistanceShort) findNextResistancePriceAndPlaceOrders(closePrice fixed ctx := context.Background() resistanceUpdated := s.updateNextResistancePrice(closePrice) if resistanceUpdated { - // TODO: consider s.activeOrders.NumOfOrders() > 0 bbgo.Notify("Found next resistance price: %f, updating resistance order...", s.currentResistancePrice.Float64()) s.placeResistanceOrders(ctx, s.currentResistancePrice) } @@ -140,6 +139,7 @@ func (s *ResistanceShort) placeResistanceOrders(ctx context.Context, resistanceP log.Infof("placing resistance orders: resistance price = %f, layer quantity = %f, num of layers = %d", resistancePrice.Float64(), quantity.Float64(), numLayers) + var sellPriceStart = resistancePrice.Mul(fixedpoint.One.Add(s.Ratio)) var orderForms []types.SubmitOrder for i := 0; i < numLayers; i++ { balances := s.session.GetAccount().Balances() @@ -148,13 +148,11 @@ func (s *ResistanceShort) placeResistanceOrders(ctx context.Context, resistanceP _ = quoteBalance _ = baseBalance - // price = (resistance_price * (1.0 + ratio)) * ((1.0 + layerSpread) * i) - price := resistancePrice.Mul(fixedpoint.One.Add(s.Ratio)) spread := layerSpread.Mul(fixedpoint.NewFromInt(int64(i))) - price = price.Add(spread) + price := sellPriceStart.Mul(one.Add(spread)) log.Infof("price = %f", price.Float64()) - log.Infof("placing bounce short order #%d: price = %f, quantity = %f", i, price.Float64(), quantity.Float64()) + log.Infof("placing resistance short order #%d: price = %f, quantity = %f", i, price.Float64(), quantity.Float64()) orderForms = append(orderForms, types.SubmitOrder{ Symbol: s.Symbol,