Merge pull request #793 from LarryLuTW/larry/fix-pnl-market

Fix pnl command
This commit is contained in:
Yo-An Lin 2022-07-04 01:42:32 +08:00 committed by GitHub
commit 6fe980a2a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,9 +184,15 @@ var PnLCmd = &cobra.Command{
return errors.New("no ticker data for current price") return errors.New("no ticker data for current price")
} }
market, ok := session.Market(symbol)
if !ok {
return fmt.Errorf("market not found: %s, %s", symbol, session.Exchange.Name())
}
currentPrice := currentTick.Last currentPrice := currentTick.Last
calculator := &pnl.AverageCostCalculator{ calculator := &pnl.AverageCostCalculator{
TradingFeeCurrency: tradingFeeCurrency, TradingFeeCurrency: tradingFeeCurrency,
Market: market,
} }
report := calculator.Calculate(symbol, trades, currentPrice) report := calculator.Calculate(symbol, trades, currentPrice)