mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
bbgo: add more sync options
This commit is contained in:
parent
76012f0b71
commit
a57a238e09
|
@ -8,14 +8,6 @@ sessions:
|
||||||
exchange: max
|
exchange: max
|
||||||
envVarPrefix: max
|
envVarPrefix: max
|
||||||
|
|
||||||
okex:
|
|
||||||
exchange: okex
|
|
||||||
envVarPrefix: okex
|
|
||||||
|
|
||||||
kucoin:
|
|
||||||
exchange: kucoin
|
|
||||||
envVarPrefix: kucoin
|
|
||||||
|
|
||||||
sync:
|
sync:
|
||||||
# userDataStream is used to sync the trading data in real-time
|
# userDataStream is used to sync the trading data in real-time
|
||||||
# it uses the websocket connection to insert the trades
|
# it uses the websocket connection to insert the trades
|
||||||
|
|
|
@ -187,6 +187,15 @@ type SyncConfig struct {
|
||||||
// Symbols is the list of symbol to sync, if ignored, symbols wlll be discovered by your existing crypto balances
|
// Symbols is the list of symbol to sync, if ignored, symbols wlll be discovered by your existing crypto balances
|
||||||
Symbols []string `json:"symbols,omitempty" yaml:"symbols,omitempty"`
|
Symbols []string `json:"symbols,omitempty" yaml:"symbols,omitempty"`
|
||||||
|
|
||||||
|
// DepositHistory for syncing deposit history
|
||||||
|
DepositHistory bool `json:"depositHistory" yaml:"depositHistory"`
|
||||||
|
|
||||||
|
// WithdrawHistory for syncing withdraw history
|
||||||
|
WithdrawHistory bool `json:"withdrawHistory" yaml:"withdrawHistory"`
|
||||||
|
|
||||||
|
// RewardHistory for syncing reward history
|
||||||
|
RewardHistory bool `json:"rewardHistory" yaml:"rewardHistory"`
|
||||||
|
|
||||||
// Since is the date where you want to start syncing data
|
// Since is the date where you want to start syncing data
|
||||||
Since *types.LooseFormatTime `json:"since,omitempty"`
|
Since *types.LooseFormatTime `json:"since,omitempty"`
|
||||||
|
|
||||||
|
|
|
@ -561,11 +561,31 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
|
||||||
if len(selectedSessions) > 0 {
|
if len(selectedSessions) > 0 {
|
||||||
sessions = environ.SelectSessions(selectedSessions...)
|
sessions = environ.SelectSessions(selectedSessions...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
if err := environ.syncSession(ctx, session, syncSymbols...); err != nil {
|
if err := environ.syncSession(ctx, session, syncSymbols...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.DepositHistory {
|
||||||
|
if err := environ.SyncService.SyncDepositHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.WithdrawHistory {
|
||||||
|
if err := environ.SyncService.SyncWithdrawHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.RewardHistory {
|
||||||
|
if err := environ.SyncService.SyncRewardHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,6 +594,24 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
|
||||||
if err := environ.syncSession(ctx, session); err != nil {
|
if err := environ.syncSession(ctx, session); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.DepositHistory {
|
||||||
|
if err := environ.SyncService.SyncDepositHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.WithdrawHistory {
|
||||||
|
if err := environ.SyncService.SyncWithdrawHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if userConfig[0].Sync.RewardHistory {
|
||||||
|
if err := environ.SyncService.SyncRewardHistory(ctx, session.Exchange); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -128,7 +128,7 @@ type Deposit struct {
|
||||||
type GetDepositHistoryRequest struct {
|
type GetDepositHistoryRequest struct {
|
||||||
client requestgen.AuthenticatedAPIClient
|
client requestgen.AuthenticatedAPIClient
|
||||||
|
|
||||||
currency *string `param:"currency"`
|
currency *string `param:"currency"`
|
||||||
from *int64 `param:"from"` // seconds
|
from *int64 `param:"from"` // seconds
|
||||||
to *int64 `param:"to"` // seconds
|
to *int64 `param:"to"` // seconds
|
||||||
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
|
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
|
||||||
|
|
|
@ -54,24 +54,38 @@ func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exc
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("syncing %s deposit records...", exchange.Name())
|
return nil
|
||||||
if err := s.DepositService.Sync(ctx, exchange); err != nil {
|
}
|
||||||
if err != ErrNotImplemented {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("syncing %s withdraw records...", exchange.Name())
|
|
||||||
if err := s.WithdrawService.Sync(ctx, exchange); err != nil {
|
|
||||||
if err != ErrNotImplemented {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
func (s *SyncService) SyncRewardHistory(ctx context.Context, exchange types.Exchange) error {
|
||||||
log.Infof("syncing %s reward records...", exchange.Name())
|
log.Infof("syncing %s reward records...", exchange.Name())
|
||||||
if err := s.RewardService.Sync(ctx, exchange); err != nil {
|
if err := s.RewardService.Sync(ctx, exchange); err != nil {
|
||||||
if err != ErrExchangeRewardServiceNotImplemented {
|
if err != ErrExchangeRewardServiceNotImplemented {
|
||||||
log.Infof("%s reward service is not supported", exchange.Name())
|
log.Warnf("%s reward service is not supported", exchange.Name())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SyncService) SyncDepositHistory(ctx context.Context, exchange types.Exchange) error {
|
||||||
|
log.Infof("syncing %s deposit records...", exchange.Name())
|
||||||
|
if err := s.DepositService.Sync(ctx, exchange); err != nil {
|
||||||
|
if err != ErrNotImplemented {
|
||||||
|
log.Warnf("%s deposit service is not supported", exchange.Name())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SyncService) SyncWithdrawHistory(ctx context.Context, exchange types.Exchange) error {
|
||||||
|
log.Infof("syncing %s withdraw records...", exchange.Name())
|
||||||
|
if err := s.WithdrawService.Sync(ctx, exchange); err != nil {
|
||||||
|
if err != ErrNotImplemented {
|
||||||
|
log.Warnf("%s withdraw service is not supported", exchange.Name())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ func (o Order) String() string {
|
||||||
orderID = strconv.FormatUint(o.OrderID, 10)
|
orderID = strconv.FormatUint(o.OrderID, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("ORDER %s %s %s %s %s/%s @ %s -> %s",
|
return fmt.Sprintf("ORDER %s %s %s %s %s/%s @ %s -> %s %s",
|
||||||
o.Exchange.String(),
|
o.Exchange.String(),
|
||||||
orderID,
|
orderID,
|
||||||
o.Symbol,
|
o.Symbol,
|
||||||
|
@ -248,7 +248,7 @@ func (o Order) String() string {
|
||||||
o.ExecutedQuantity.String(),
|
o.ExecutedQuantity.String(),
|
||||||
o.Quantity.String(),
|
o.Quantity.String(),
|
||||||
o.Price.String(),
|
o.Price.String(),
|
||||||
o.Status)
|
o.Status, o.CreationTime.Time().Format(time.RFC1123))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlainText is used for telegram-styled messages
|
// PlainText is used for telegram-styled messages
|
||||||
|
|
Loading…
Reference in New Issue
Block a user