Skip to content

Commit

Permalink
Merge pull request #1891 from anywhy/binance_futures_stop_order
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s authored Jan 23, 2025
2 parents 7586dad + adb17a5 commit 852536e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tebeka/strftime v0.1.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/bbgo/activeorderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (b *ActiveOrderBook) Update(order types.Order) {

b.C.Emit()

case types.OrderStatusCanceled, types.OrderStatusRejected:
case types.OrderStatusCanceled, types.OrderStatusRejected, types.OrderStatusExpired:
// TODO: note that orders transit to "canceled" may have partially filled
log.Debugf("[ActiveOrderBook] order is %s, removing order %s", order.Status, order)
b.orders.Remove(order.OrderID)
Expand Down
11 changes: 7 additions & 4 deletions pkg/exchange/binance/convert_futures.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ func toLocalFuturesOrderType(orderType types.OrderType) (futures.OrderType, erro
case types.OrderTypeLimit, types.OrderTypeLimitMaker:
return futures.OrderTypeLimit, nil

// case types.OrderTypeStopLimit:
// return futures.OrderTypeStopLossLimit, nil //TODO
case types.OrderTypeStopLimit:
return futures.OrderTypeStop, nil

// case types.OrderTypeStopMarket:
// return futures.OrderTypeStopLoss, nil //TODO
case types.OrderTypeStopMarket:
return futures.OrderTypeStopMarket, nil

case types.OrderTypeMarket:
return futures.OrderTypeMarket, nil
Expand Down Expand Up @@ -224,6 +224,9 @@ func toGlobalFuturesOrderType(orderType futures.OrderType) types.OrderType {
case futures.OrderTypeLimit:
return types.OrderTypeLimit

case futures.OrderTypeStop:
return types.OrderTypeStopLimit

case futures.OrderTypeMarket:
return types.OrderTypeMarket

Expand Down
6 changes: 5 additions & 1 deletion pkg/types/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ const (

// OrderStatusRejected means the order is not placed successfully, it's rejected by the api
OrderStatusRejected OrderStatus = "REJECTED"

// OrderStatusExpired means the order is expired, it's an end state.
OrderStatusExpired OrderStatus = "EXPIRED"
)

func (o OrderStatus) Closed() bool {
return o == OrderStatusFilled ||
o == OrderStatusCanceled ||
o == OrderStatusRejected
o == OrderStatusRejected ||
o == OrderStatusExpired
}

type SubmitOrder struct {
Expand Down

0 comments on commit 852536e

Please sign in to comment.