backtest: move QueryOrder method

This commit is contained in:
c9s 2022-07-04 02:29:18 +08:00
parent a31f61736a
commit 8fc17f9c0b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -72,20 +72,6 @@ type Exchange struct {
markets types.MarketMap
}
func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error) {
book := e.matchingBooks[q.Symbol]
oid, err := strconv.ParseUint(q.OrderID, 10, 64)
if err != nil {
return nil, err
}
order, ok := book.getOrder(oid)
if ok {
return &order, nil
}
return nil, nil
}
func NewExchange(sourceName types.ExchangeName, sourceExchange types.Exchange, srv *service.BacktestService, config *bbgo.Backtest) (*Exchange, error) {
ex := sourceExchange
@ -172,6 +158,20 @@ func (e *Exchange) NewStream() types.Stream {
}
}
func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error) {
book := e.matchingBooks[q.Symbol]
oid, err := strconv.ParseUint(q.OrderID, 10, 64)
if err != nil {
return nil, err
}
order, ok := book.getOrder(oid)
if ok {
return &order, nil
}
return nil, nil
}
func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) {
for _, order := range orders {
symbol := order.Symbol