mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bbgo: fix since time override
This commit is contained in:
parent
a4ae414c1d
commit
33f0571511
|
@ -451,11 +451,13 @@ func (environ *Environment) syncWithUserConfig(ctx context.Context, userConfig *
|
||||||
sessions = environ.SelectSessions(selectedSessions...)
|
sessions = environ.SelectSessions(selectedSessions...)
|
||||||
}
|
}
|
||||||
|
|
||||||
since := time.Now().AddDate(0, -6, 0)
|
since := defaultSyncSinceTime()
|
||||||
if userConfig.Sync.Since != nil {
|
if userConfig.Sync.Since != nil {
|
||||||
since = userConfig.Sync.Since.Time()
|
since = userConfig.Sync.Since.Time()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environ.SetSyncStartTime(since)
|
||||||
|
|
||||||
syncSymbolMap, restSymbols := categorizeSyncSymbol(userConfig.Sync.Symbols)
|
syncSymbolMap, restSymbols := categorizeSyncSymbol(userConfig.Sync.Symbols)
|
||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
syncSymbols := restSymbols
|
syncSymbols := restSymbols
|
||||||
|
@ -463,7 +465,7 @@ func (environ *Environment) syncWithUserConfig(ctx context.Context, userConfig *
|
||||||
syncSymbols = append(syncSymbols, ss...)
|
syncSymbols = append(syncSymbols, ss...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := environ.syncSession(ctx, session, syncSymbols...); err != nil {
|
if err := environ.syncSession(ctx, session, since, syncSymbols...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +522,9 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
|
||||||
}
|
}
|
||||||
|
|
||||||
// the default sync logics
|
// the default sync logics
|
||||||
|
since := defaultSyncSinceTime()
|
||||||
for _, session := range environ.sessions {
|
for _, session := range environ.sessions {
|
||||||
if err := environ.syncSession(ctx, session); err != nil {
|
if err := environ.syncSession(ctx, session, since); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,10 +619,13 @@ func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSe
|
||||||
environ.setSyncing(Syncing)
|
environ.setSyncing(Syncing)
|
||||||
defer environ.setSyncing(SyncDone)
|
defer environ.setSyncing(SyncDone)
|
||||||
|
|
||||||
return environ.syncSession(ctx, session, defaultSymbols...)
|
since := defaultSyncSinceTime()
|
||||||
|
return environ.syncSession(ctx, session, since, defaultSymbols...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (environ *Environment) syncSession(ctx context.Context, session *ExchangeSession, defaultSymbols ...string) error {
|
func (environ *Environment) syncSession(
|
||||||
|
ctx context.Context, session *ExchangeSession, syncStartTime time.Time, defaultSymbols ...string,
|
||||||
|
) error {
|
||||||
symbols, err := session.getSessionSymbols(defaultSymbols...)
|
symbols, err := session.getSessionSymbols(defaultSymbols...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -627,7 +633,7 @@ func (environ *Environment) syncSession(ctx context.Context, session *ExchangeSe
|
||||||
|
|
||||||
log.Infof("syncing symbols %v from session %s", symbols, session.Name)
|
log.Infof("syncing symbols %v from session %s", symbols, session.Name)
|
||||||
|
|
||||||
return environ.SyncService.SyncSessionSymbols(ctx, session.Exchange, environ.syncStartTime, symbols...)
|
return environ.SyncService.SyncSessionSymbols(ctx, session.Exchange, syncStartTime, symbols...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (environ *Environment) ConfigureNotificationSystem(ctx context.Context, userConfig *Config) error {
|
func (environ *Environment) ConfigureNotificationSystem(ctx context.Context, userConfig *Config) error {
|
||||||
|
@ -1014,3 +1020,7 @@ func (session *ExchangeSession) getSessionSymbols(defaultSymbols ...string) ([]s
|
||||||
|
|
||||||
return session.FindPossibleSymbols()
|
return session.FindPossibleSymbols()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultSyncSinceTime() time.Time {
|
||||||
|
return time.Now().AddDate(0, -6, 0)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user