mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
Merge pull request #1441 from c9s/c9s/fix-sync-since-time-override
FIX: fix since time override
This commit is contained in:
commit
0a3269e38e
18
README.md
18
README.md
|
@ -139,15 +139,19 @@ the implementation.
|
|||
|
||||
## Requirements
|
||||
|
||||
Get your exchange API key and secret after you register the accounts (you can choose one or more exchanges):
|
||||
* Go SDK 1.20
|
||||
|
||||
- MAX: <https://max.maicoin.com/signup?r=c7982718>
|
||||
- Binance: <https://accounts.binance.com/en/register?ref=38192708>
|
||||
- OKEx: <https://www.okex.com/join/2412712?src=from:ios-share>
|
||||
- Kucoin: <https://www.kucoin.com/ucenter/signup?rcode=r3KX2D4>
|
||||
* Linux / MacOS / Windows (WSL)
|
||||
|
||||
This project is maintained and supported by a small group of team. If you would like to support this project, please
|
||||
register on the exchanges using the provided links with referral codes above.
|
||||
* Get your exchange API key and secret after you register the accounts (you can choose one or more exchanges):
|
||||
|
||||
- MAX: <https://max.maicoin.com/signup?r=c7982718>
|
||||
- Binance: <https://accounts.binance.com/en/register?ref=38192708>
|
||||
- OKEx: <https://www.okex.com/join/2412712?src=from:ios-share>
|
||||
- Kucoin: <https://www.kucoin.com/ucenter/signup?rcode=r3KX2D4>
|
||||
|
||||
This project is maintained and supported by a small group of team. If you would like to support this project, please
|
||||
register on the exchanges using the provided links with referral codes above.
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -451,11 +451,13 @@ func (environ *Environment) syncWithUserConfig(ctx context.Context, userConfig *
|
|||
sessions = environ.SelectSessions(selectedSessions...)
|
||||
}
|
||||
|
||||
since := time.Now().AddDate(0, -6, 0)
|
||||
since := defaultSyncSinceTime()
|
||||
if userConfig.Sync.Since != nil {
|
||||
since = userConfig.Sync.Since.Time()
|
||||
}
|
||||
|
||||
environ.SetSyncStartTime(since)
|
||||
|
||||
syncSymbolMap, restSymbols := categorizeSyncSymbol(userConfig.Sync.Symbols)
|
||||
for _, session := range sessions {
|
||||
syncSymbols := restSymbols
|
||||
|
@ -463,7 +465,7 @@ func (environ *Environment) syncWithUserConfig(ctx context.Context, userConfig *
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -520,8 +522,9 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
|
|||
}
|
||||
|
||||
// the default sync logics
|
||||
since := defaultSyncSinceTime()
|
||||
for _, session := range environ.sessions {
|
||||
if err := environ.syncSession(ctx, session); err != nil {
|
||||
if err := environ.syncSession(ctx, session, since); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -616,10 +619,13 @@ func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSe
|
|||
environ.setSyncing(Syncing)
|
||||
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...)
|
||||
if err != nil {
|
||||
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)
|
||||
|
||||
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 {
|
||||
|
@ -1014,3 +1020,7 @@ func (session *ExchangeSession) getSessionSymbols(defaultSymbols ...string) ([]s
|
|||
|
||||
return session.FindPossibleSymbols()
|
||||
}
|
||||
|
||||
func defaultSyncSinceTime() time.Time {
|
||||
return time.Now().AddDate(0, -6, 0)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user