mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
pkg: return err if rate limit err
This commit is contained in:
parent
ef8d1c7046
commit
b71030c5db
|
@ -12,6 +12,7 @@ import (
|
||||||
func (e *Exchange) CancelReplace(ctx context.Context, cancelReplaceMode types.CancelReplaceModeType, o types.Order) (*types.Order, error) {
|
func (e *Exchange) CancelReplace(ctx context.Context, cancelReplaceMode types.CancelReplaceModeType, o types.Order) (*types.Order, error) {
|
||||||
if err := orderLimiter.Wait(ctx); err != nil {
|
if err := orderLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("order rate limiter wait error")
|
log.WithError(err).Errorf("order rate limiter wait error")
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.IsFutures || e.IsMargin {
|
if e.IsFutures || e.IsMargin {
|
||||||
|
|
|
@ -764,8 +764,9 @@ func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if err := orderLimiter.Wait(ctx); err != nil {
|
if err = orderLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("order rate limiter wait error")
|
log.WithError(err).Errorf("order rate limiter wait error")
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("querying closed orders %s from %s <=> %s ...", symbol, since, until)
|
log.Infof("querying closed orders %s from %s <=> %s ...", symbol, since, until)
|
||||||
|
@ -822,8 +823,9 @@ func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err error) {
|
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err error) {
|
||||||
if err := orderLimiter.Wait(ctx); err != nil {
|
if err = orderLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("order rate limiter wait error")
|
log.WithError(err).Errorf("order rate limiter wait error")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.IsFutures {
|
if e.IsFutures {
|
||||||
|
@ -1086,8 +1088,9 @@ func (e *Exchange) submitSpotOrder(ctx context.Context, order types.SubmitOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error) {
|
func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error) {
|
||||||
if err := orderLimiter.Wait(ctx); err != nil {
|
if err = orderLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("order rate limiter wait error")
|
log.WithError(err).Errorf("order rate limiter wait error")
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.IsMargin {
|
if e.IsMargin {
|
||||||
|
|
|
@ -73,6 +73,7 @@ func (r *TelegramReply) Send(message string) {
|
||||||
for _, split := range splits {
|
for _, split := range splits {
|
||||||
if err := sendLimiter.Wait(ctx); err != nil {
|
if err := sendLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("telegram send limit exceeded")
|
log.WithError(err).Errorf("telegram send limit exceeded")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
checkSendErr(r.bot.Send(r.session.Chat, split))
|
checkSendErr(r.bot.Send(r.session.Chat, split))
|
||||||
}
|
}
|
||||||
|
@ -175,6 +176,7 @@ func (tm *Telegram) Start(ctx context.Context) {
|
||||||
for i, split := range splits {
|
for i, split := range splits {
|
||||||
if err := sendLimiter.Wait(ctx); err != nil {
|
if err := sendLimiter.Wait(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("telegram send limit exceeded")
|
log.WithError(err).Errorf("telegram send limit exceeded")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if i == len(splits)-1 {
|
if i == len(splits)-1 {
|
||||||
// only set menu on the last message
|
// only set menu on the last message
|
||||||
|
|
Loading…
Reference in New Issue
Block a user