mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
backtest: add order quantity check
This commit is contained in:
parent
c374a56110
commit
a515fff053
|
@ -48,6 +48,8 @@ import (
|
|||
var log = logrus.WithField("cmd", "backtest")
|
||||
|
||||
var ErrUnimplemented = errors.New("unimplemented method")
|
||||
var ErrNegativeQuantity = errors.New("order quantity can not be negative")
|
||||
var ErrZeroQuantity = errors.New("order quantity can not be zero")
|
||||
|
||||
type Exchange struct {
|
||||
sourceName types.ExchangeName
|
||||
|
@ -176,6 +178,14 @@ func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (cr
|
|||
return nil, fmt.Errorf("matching engine is not initialized for symbol %s", symbol)
|
||||
}
|
||||
|
||||
if order.Quantity.Sign() < 0 {
|
||||
return nil, ErrNegativeQuantity
|
||||
}
|
||||
|
||||
if order.Quantity.IsZero() {
|
||||
return nil, ErrZeroQuantity
|
||||
}
|
||||
|
||||
createdOrder, _, err = matching.PlaceOrder(order)
|
||||
if createdOrder != nil {
|
||||
// market order can be closed immediately.
|
||||
|
|
Loading…
Reference in New Issue
Block a user