mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
cmd/pnl: add --sync option
This commit is contained in:
parent
fa7177426f
commit
8c850c71a2
|
@ -21,6 +21,7 @@ func init() {
|
|||
PnLCmd.Flags().StringArray("session", []string{}, "target exchange sessions")
|
||||
PnLCmd.Flags().String("symbol", "", "trading symbol")
|
||||
PnLCmd.Flags().Bool("include-transfer", false, "convert transfer records into trades")
|
||||
PnLCmd.Flags().Bool("sync", false, "sync before loading trades")
|
||||
PnLCmd.Flags().String("since", "", "query trades from a time point")
|
||||
PnLCmd.Flags().Uint64("limit", 0, "number of trades")
|
||||
RootCmd.AddCommand(PnLCmd)
|
||||
|
@ -43,6 +44,11 @@ var PnLCmd = &cobra.Command{
|
|||
return errors.New("--session [SESSION] is required")
|
||||
}
|
||||
|
||||
wantSync, err := cmd.Flags().GetBool("sync")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
symbol, err := cmd.Flags().GetString("symbol")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -96,9 +102,11 @@ var PnLCmd = &cobra.Command{
|
|||
return fmt.Errorf("session %s not found", sessionName)
|
||||
}
|
||||
|
||||
if wantSync {
|
||||
if err := environ.SyncSession(ctx, session, symbol); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if includeTransfer {
|
||||
exchange := session.Exchange
|
||||
|
|
Loading…
Reference in New Issue
Block a user