mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
use multierr to handle err return from toGlobalOrder
This commit is contained in:
parent
a0946fbd42
commit
26cde5d57c
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"go.uber.org/multierr"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/exchange/okex/okexapi"
|
"github.com/c9s/bbgo/pkg/exchange/okex/okexapi"
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
|
@ -164,16 +165,17 @@ func toGlobalTrades(orderDetails []okexapi.OrderDetails) ([]types.Trade, error)
|
||||||
|
|
||||||
func toGlobalOrders(orderDetails []okexapi.OrderDetails) ([]types.Order, error) {
|
func toGlobalOrders(orderDetails []okexapi.OrderDetails) ([]types.Order, error) {
|
||||||
var orders []types.Order
|
var orders []types.Order
|
||||||
|
var err error
|
||||||
for _, orderDetail := range orderDetails {
|
for _, orderDetail := range orderDetails {
|
||||||
|
|
||||||
o, err := toGlobalOrder(&orderDetail)
|
o, err2 := toGlobalOrder(&orderDetail)
|
||||||
if err != nil {
|
if err2 != nil {
|
||||||
log.WithError(err).Error("order convert error")
|
err = multierr.Append(err, err2)
|
||||||
}
|
}
|
||||||
orders = append(orders, *o)
|
orders = append(orders, *o)
|
||||||
}
|
}
|
||||||
|
|
||||||
return orders, nil
|
return orders, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func toGlobalOrderStatus(state okexapi.OrderState) (types.OrderStatus, error) {
|
func toGlobalOrderStatus(state okexapi.OrderState) (types.OrderStatus, error) {
|
||||||
|
@ -209,8 +211,7 @@ func toLocalOrderType(orderType types.OrderType) (okexapi.OrderType, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func toGlobalOrderType(orderType okexapi.OrderType) (types.OrderType, error) {
|
func toGlobalOrderType(orderType okexapi.OrderType) (types.OrderType, error) {
|
||||||
// Okex IOC and FOK only implement limit order
|
// IOC, FOK are only allowed with limit order type, so we assume the order type is always limit order for FOK, IOC orders
|
||||||
// reference: https://www.okx.com/cn/help-center/360025135731
|
|
||||||
switch orderType {
|
switch orderType {
|
||||||
case okexapi.OrderTypeMarket:
|
case okexapi.OrderTypeMarket:
|
||||||
return types.OrderTypeMarket, nil
|
return types.OrderTypeMarket, nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user