mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
bbgo: load last price from 1m interval kline only
This commit is contained in:
parent
83378b1934
commit
44a0b10240
|
@ -406,10 +406,10 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
|
|||
}
|
||||
}
|
||||
|
||||
var lastPriceTime time.Time
|
||||
for interval := range klineSubscriptions {
|
||||
// avoid querying the last unclosed kline
|
||||
endTime := environ.startTime.Add(-interval.Duration())
|
||||
// endTime := environ.startTime.Add(-interval.Duration())
|
||||
endTime := environ.startTime.Add(-time.Millisecond)
|
||||
kLines, err := session.Exchange.QueryKLines(ctx, symbol, interval, types.KLineQueryOptions{
|
||||
EndTime: &endTime,
|
||||
Limit: 1000, // indicators need at least 100
|
||||
|
@ -425,12 +425,9 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
|
|||
|
||||
// update last prices by the given kline
|
||||
lastKLine := kLines[len(kLines)-1]
|
||||
if lastPriceTime == emptyTime {
|
||||
if interval == types.Interval1m {
|
||||
log.Infof("last kline %+v", lastKLine)
|
||||
session.lastPrices[symbol] = lastKLine.Close
|
||||
lastPriceTime = lastKLine.EndTime
|
||||
} else if lastKLine.EndTime.After(lastPriceTime) {
|
||||
session.lastPrices[symbol] = lastKLine.Close
|
||||
lastPriceTime = lastKLine.EndTime
|
||||
}
|
||||
|
||||
for _, k := range kLines {
|
||||
|
|
Loading…
Reference in New Issue
Block a user