Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: support binance futures stop limit order #1891

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading