Merge pull request #238 from jessy1092/binance_order

This commit is contained in:
Yo-An Lin 2021-05-14 11:00:13 +08:00 committed by GitHub
commit 9c666f9a04
2 changed files with 12 additions and 0 deletions

View File

@ -106,6 +106,7 @@ func (e *ExecutionReportEvent) Order() (*types.Order, error) {
switch e.CurrentExecutionType {
case "NEW", "CANCELED", "REJECTED", "EXPIRED":
case "REPLACED":
case "TRADE": // For Order FILLED status. And the order has been completed.
default:
return nil, errors.New("execution report type is not for order")
}

View File

@ -169,6 +169,17 @@ func NewStream(client *binance.Client) *Stream {
}
stream.EmitTradeUpdate(*trade)
order, err := e.Order()
if err != nil {
log.WithError(err).Error("order convert error")
return
}
// Update Order with FILLED event
if (order.Status == types.OrderStatusFilled) {
stream.EmitOrderUpdate(*order)
}
}
})