From f2109afa0e72c1cd5e3cf92ce403055874d5626d Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 31 Jul 2023 17:54:34 +0800 Subject: [PATCH 1/3] add last 30 days to loose date support --- pkg/types/time.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/types/time.go b/pkg/types/time.go index 5bc811c85..c6e912cc5 100644 --- a/pkg/types/time.go +++ b/pkg/types/time.go @@ -256,6 +256,10 @@ func ParseLooseFormatTime(s string) (LooseFormatTime, error) { t = time.Now().AddDate(0, -1, 0) return LooseFormatTime(t), nil + case "last 30 days": + t = time.Now().AddDate(0, 0, -30) + return LooseFormatTime(t), nil + case "last year": t = time.Now().AddDate(-1, 0, 0) return LooseFormatTime(t), nil @@ -357,4 +361,3 @@ func BeginningOfTheDay(t time.Time) time.Time { func Over24Hours(since time.Time) bool { return time.Since(since) >= 24*time.Hour } - From 43b8e7870da287acfcff7b9833bcc4a57d2770cb Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 31 Jul 2023 18:06:20 +0800 Subject: [PATCH 2/3] grid2: ignore discounted trades --- pkg/strategy/grid2/trade.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/strategy/grid2/trade.go b/pkg/strategy/grid2/trade.go index 381744ccd..c2a4d8eb6 100644 --- a/pkg/strategy/grid2/trade.go +++ b/pkg/strategy/grid2/trade.go @@ -9,6 +9,10 @@ import ( func collectTradeFee(trades []types.Trade) map[string]fixedpoint.Value { fees := make(map[string]fixedpoint.Value) for _, t := range trades { + if t.FeeDiscounted { + continue + } + if fee, ok := fees[t.FeeCurrency]; ok { fees[t.FeeCurrency] = fee.Add(t.Fee) } else { From 4560b475560801fe815cc21d10e2733a8435474c Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 31 Jul 2023 18:12:28 +0800 Subject: [PATCH 3/3] grid2: only for positive non-zero fee --- pkg/strategy/grid2/strategy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index 6a38c5f1f..e8247099b 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -484,7 +484,7 @@ func (s *Strategy) processFilledOrder(o types.Order) { // use the profit to buy more inventory in the grid if s.Compound || s.EarnBase { // if it's not using the platform fee currency, reduce the quote quantity for the buy order - if feeCurrency == s.Market.QuoteCurrency { + if feeCurrency == s.Market.QuoteCurrency && fee.Sign() > 0 { orderExecutedQuoteAmount = orderExecutedQuoteAmount.Sub(fee) } @@ -517,7 +517,7 @@ func (s *Strategy) processFilledOrder(o types.Order) { } } - if feeCurrency == s.Market.BaseCurrency { + if feeCurrency == s.Market.BaseCurrency && fee.Sign() > 0 { newQuantity = newQuantity.Sub(fee) }