mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
twap: improve cancelContextIfTargetQuantityFilled check method
This commit is contained in:
parent
0530809834
commit
b9c41b7ad7
|
@ -220,10 +220,14 @@ func (e *FixedQuantityExecutor) handleFilledOrder(order types.Order) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *FixedQuantityExecutor) cancelContextIfTargetQuantityFilled() bool {
|
func (e *FixedQuantityExecutor) cancelContextIfTargetQuantityFilled() bool {
|
||||||
|
// ensure that the trades are processed
|
||||||
|
e.tradeCollector.Process()
|
||||||
|
|
||||||
|
// now get the base quantity from the position
|
||||||
base := e.position.GetBase()
|
base := e.position.GetBase()
|
||||||
|
|
||||||
if base.Abs().Compare(e.targetQuantity) >= 0 {
|
if base.Abs().Sub(e.targetQuantity).Compare(e.market.MinQuantity.Neg()) >= 0 {
|
||||||
e.logger.Infof("filled target quantity, canceling the order execution context")
|
e.logger.Infof("position is filled with target quantity, canceling the order execution context")
|
||||||
e.cancelExecution()
|
e.cancelExecution()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user