add warning logs to pnl cmd

This commit is contained in:
c9s 2022-06-08 14:59:32 +08:00
parent 8c6331073d
commit 99bf914415
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"sort"
"strings" "strings"
"time" "time"
@ -105,7 +106,12 @@ var PnLCmd = &cobra.Command{
if err != nil { if err != nil {
return err return err
} }
_ = withdrawals
sort.Slice(withdrawals, func(i, j int) bool {
a := withdrawals[i].ApplyTime.Time()
b := withdrawals[j].ApplyTime.Time()
return a.Before(b)
})
// we need the backtest klines for the daily prices // we need the backtest klines for the daily prices
backtestService := &service.BacktestService{DB: environ.DatabaseService.DB} backtestService := &service.BacktestService{DB: environ.DatabaseService.DB}
@ -121,8 +127,8 @@ var PnLCmd = &cobra.Command{
trades, err = environ.TradeService.QueryForTradingFeeCurrency(exchange.Name(), symbol, tradingFeeCurrency) trades, err = environ.TradeService.QueryForTradingFeeCurrency(exchange.Name(), symbol, tradingFeeCurrency)
} else { } else {
trades, err = environ.TradeService.Query(service.QueryTradesOptions{ trades, err = environ.TradeService.Query(service.QueryTradesOptions{
Symbol: symbol, Symbol: symbol,
Limit: limit, Limit: limit,
}) })
} }
@ -155,6 +161,9 @@ var PnLCmd = &cobra.Command{
report := calculator.Calculate(symbol, trades, currentPrice) report := calculator.Calculate(symbol, trades, currentPrice)
report.Print() report.Print()
log.Warnf("note that if you're using cross-exchange arbitrage, the PnL won't be accurate")
log.Warnf("withdrawal and deposits are not considered in the PnL")
return nil return nil
}, },
} }