mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
grid2: add recoverGrid
This commit is contained in:
parent
1fd431df5f
commit
330be79ec6
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -986,6 +987,33 @@ func (s *Strategy) checkMinimalQuoteInvestment() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) recoverGrid(ctx context.Context, session *bbgo.ExchangeSession) error {
|
||||
historyService, ok := session.Exchange.(types.ExchangeTradeHistoryService)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
orders, err := session.Exchange.QueryOpenOrders(ctx, s.Symbol)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
firstOrderTime := orders[0].CreationTime.Time()
|
||||
for _, o := range orders {
|
||||
if o.CreationTime.Before(firstOrderTime) {
|
||||
firstOrderTime = o.CreationTime.Time()
|
||||
}
|
||||
}
|
||||
|
||||
closedOrders, err := historyService.QueryClosedOrders(ctx, s.Symbol, firstOrderTime, time.Now(), 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = closedOrders
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
instanceID := s.InstanceID()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user