mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
feat: add limit option for pnl command
This commit is contained in:
parent
b90cc2a8c9
commit
893b513605
|
@ -21,6 +21,7 @@ import (
|
|||
func init() {
|
||||
PnLCmd.Flags().String("exchange", "", "target exchange")
|
||||
PnLCmd.Flags().String("symbol", "BTCUSDT", "trading symbol")
|
||||
PnLCmd.Flags().Int("limit", 500, "number of orders")
|
||||
RootCmd.AddCommand(PnLCmd)
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,11 @@ var PnLCmd = &cobra.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
limit, err := cmd.Flags().GetInt("limit")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exchange, err := cmdutil.NewExchange(exchangeName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -67,6 +73,7 @@ var PnLCmd = &cobra.Command{
|
|||
trades, err = tradeService.Query(service.QueryTradesOptions{
|
||||
Exchange: exchange.Name(),
|
||||
Symbol: symbol,
|
||||
Limit: limit,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -163,13 +163,13 @@ func (s *TradeService) QueryForTradingFeeCurrency(ex types.ExchangeName, symbol
|
|||
return s.scanRows(rows)
|
||||
}
|
||||
|
||||
// Only return 500 items.
|
||||
type QueryTradesOptions struct {
|
||||
Exchange types.ExchangeName
|
||||
Symbol string
|
||||
LastGID int64
|
||||
// ASC or DESC
|
||||
Ordering string
|
||||
Limit int
|
||||
}
|
||||
|
||||
func (s *TradeService) Query(options QueryTradesOptions) ([]types.Trade, error) {
|
||||
|
@ -225,7 +225,7 @@ func queryTradesSQL(options QueryTradesOptions) string {
|
|||
|
||||
sql += ` ORDER BY gid ` + ordering
|
||||
|
||||
sql += ` LIMIT ` + strconv.Itoa(500)
|
||||
sql += ` LIMIT ` + strconv.Itoa(options.Limit)
|
||||
return sql
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user