Merge remote-tracking branch 'origin/v1.50'

This commit is contained in:
c9s 2023-08-01 13:23:04 +08:00
commit cfd5884350
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 10 additions and 3 deletions

View File

@ -485,7 +485,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)
}
@ -518,7 +518,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)
}

View File

@ -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 {

View File

@ -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
}