mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
backtest: move QueryOrder method
This commit is contained in:
parent
a31f61736a
commit
8fc17f9c0b
|
@ -72,20 +72,6 @@ type Exchange struct {
|
||||||
markets types.MarketMap
|
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) {
|
func NewExchange(sourceName types.ExchangeName, sourceExchange types.Exchange, srv *service.BacktestService, config *bbgo.Backtest) (*Exchange, error) {
|
||||||
ex := sourceExchange
|
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) {
|
func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) {
|
||||||
for _, order := range orders {
|
for _, order := range orders {
|
||||||
symbol := order.Symbol
|
symbol := order.Symbol
|
||||||
|
|
Loading…
Reference in New Issue
Block a user