mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
exchange/ftx: add more guard condition
This commit is contained in:
parent
1ab20e6397
commit
740989ca64
|
@ -177,11 +177,14 @@ func (s *Stream) pollKLines(ctx context.Context) {
|
||||||
s.EmitKLineClosed(klines[0])
|
s.EmitKLineClosed(klines[0])
|
||||||
lastClosed = klines[0].StartTime.Time()
|
lastClosed = klines[0].StartTime.Time()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(klines) > 1 {
|
||||||
s.EmitKLine(klines[1])
|
s.EmitKLine(klines[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLast2KLine(e *Exchange, ctx context.Context, symbol string, interval types.Interval) []types.KLine {
|
func getLast2KLine(e *Exchange, ctx context.Context, symbol string, interval types.Interval) []types.KLine {
|
||||||
|
@ -202,6 +205,9 @@ func getLast2KLine(e *Exchange, ctx context.Context, symbol string, interval typ
|
||||||
func getLastClosedKLine(e *Exchange, ctx context.Context, symbol string, interval types.Interval) []types.KLine {
|
func getLastClosedKLine(e *Exchange, ctx context.Context, symbol string, interval types.Interval) []types.KLine {
|
||||||
// set since to more 30s ago to avoid getting no kline candle
|
// set since to more 30s ago to avoid getting no kline candle
|
||||||
klines := getLast2KLine(e, ctx, symbol, interval)
|
klines := getLast2KLine(e, ctx, symbol, interval)
|
||||||
|
if len(klines) == 0 {
|
||||||
|
return []types.KLine{}
|
||||||
|
}
|
||||||
return []types.KLine{klines[0]}
|
return []types.KLine{klines[0]}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user