Skip to content

Commit

Permalink
Merge pull request #1257 from c9s/c9s/max-grid2-fee-discounted
Browse files Browse the repository at this point in the history
FEATURE: [grid2] fee discounted filtering
  • Loading branch information
c9s authored Jul 31, 2023
2 parents 570ccab + 4560b47 commit 82a43dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/strategy/grid2/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/strategy/grid2/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -357,4 +361,3 @@ func BeginningOfTheDay(t time.Time) time.Time {
func Over24Hours(since time.Time) bool {
return time.Since(since) >= 24*time.Hour
}

0 comments on commit 82a43dc

Please sign in to comment.