mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #598 from zenixls2/fix/sync-binance
Fix/sync binance
This commit is contained in:
commit
2d65e2d2b5
|
@ -29,11 +29,10 @@ sync:
|
|||
userDataStream:
|
||||
trades: true
|
||||
filledOrders: true
|
||||
since: 2020-12-01
|
||||
sessions:
|
||||
- binance
|
||||
symbols:
|
||||
- MATICUSDT
|
||||
sessions:
|
||||
- binance
|
||||
symbols:
|
||||
- MATICUSDT
|
||||
|
||||
backtest:
|
||||
startTime: "2022-04-14"
|
||||
|
|
|
@ -20,7 +20,7 @@ func init() {
|
|||
}
|
||||
|
||||
var SyncCmd = &cobra.Command{
|
||||
Use: "sync --session=[exchange_name] --symbol=[pair_name] [--since=yyyy/mm/dd]",
|
||||
Use: "sync [--session=[exchange_name]] [--symbol=[pair_name]] [[--since=yyyy/mm/dd]]",
|
||||
Short: "sync trades and orders history",
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
|
|
@ -1347,17 +1347,19 @@ func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *type
|
|||
req.FromID(int64(options.LastTradeID))
|
||||
}
|
||||
|
||||
if options.StartTime != nil && options.EndTime != nil {
|
||||
if options.EndTime.Sub(*options.StartTime) < 24*time.Hour {
|
||||
req.StartTime(options.StartTime.UnixMilli())
|
||||
// The parameter fromId cannot be sent with startTime or endTime.
|
||||
// Mentioned in binance futures docs
|
||||
if options.LastTradeID <= 0 {
|
||||
if options.StartTime != nil && options.EndTime != nil {
|
||||
if options.EndTime.Sub(*options.StartTime) < 24*time.Hour {
|
||||
req.StartTime(options.StartTime.UnixMilli())
|
||||
req.EndTime(options.EndTime.UnixMilli())
|
||||
} else {
|
||||
req.StartTime(options.StartTime.UnixMilli())
|
||||
}
|
||||
} else if options.EndTime != nil {
|
||||
req.EndTime(options.EndTime.UnixMilli())
|
||||
} else {
|
||||
req.StartTime(options.StartTime.UnixMilli())
|
||||
}
|
||||
} else if options.StartTime != nil {
|
||||
req.StartTime(options.StartTime.UnixMilli())
|
||||
} else if options.EndTime != nil {
|
||||
req.EndTime(options.EndTime.UnixMilli())
|
||||
}
|
||||
|
||||
remoteTrades, err = req.Do(ctx)
|
||||
|
|
Loading…
Reference in New Issue
Block a user