mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-27 15:10:30 +00:00
exchanges/binance/coinm: fix order submission (#819)
* exchanges/binance: proper arguments order when calling Binance.FuturesNewOrder * exchanges/binance: adapt FuturesOrderPlaceData (+ unmarshaling) to latest coin/delivery futures API * exchanges/binance: introduce futuresNewOrderRequest and use it to pass order parameters for coin margined futures * exchanges/binance: test json unmarshaling of FuturesOrderPlaceData * exchanges/binance: reorder fields as per docs, include missing fields (also in tests) * exchanges/binance/coinm: use constants instead of hard coded strings (also fixes linting) * exchanges/binance/coinm: pass futuresNewOrderRequest by reference * exchanges/binance/coinm: expose FuturesNewOrderRequest * exchanges/binance/coinm: do not explicitly assign default values fields of FuturesNewOrderRequest * exchanges/binance/coinm: document FuturesNewOrderRequest * exchanges/binance/coinm: expose all fields of FuturesNewOrderRequest * exchanges/binance/coinm: expose fields of FuturesNewOrderRequest * exchange/binance/coin: order submission: add support for priceProtect Co-authored-by: Yordan Miladinov <jordanmiladinov@gmail.bg>
This commit is contained in:
@@ -936,27 +936,35 @@ func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (order.Submi
|
||||
var oType string
|
||||
switch s.Type {
|
||||
case order.Limit:
|
||||
oType = "LIMIT"
|
||||
oType = cfuturesLimit
|
||||
case order.Market:
|
||||
oType = "MARKET"
|
||||
oType = cfuturesMarket
|
||||
case order.Stop:
|
||||
oType = "STOP"
|
||||
oType = cfuturesStop
|
||||
case order.TakeProfit:
|
||||
oType = "TAKE_PROFIT"
|
||||
oType = cfuturesTakeProfit
|
||||
case order.StopMarket:
|
||||
oType = "STOP_MARKET"
|
||||
oType = cfuturesStopMarket
|
||||
case order.TakeProfitMarket:
|
||||
oType = "TAKE_PROFIT_MARKET"
|
||||
oType = cfuturesTakeProfitMarket
|
||||
case order.TrailingStop:
|
||||
oType = "TRAILING_STOP_MARKET"
|
||||
oType = cfuturesTrailingStopMarket
|
||||
default:
|
||||
return submitOrderResponse, errors.New("invalid type, check api docs for updates")
|
||||
}
|
||||
o, err := b.FuturesNewOrder(ctx,
|
||||
s.Pair, reqSide,
|
||||
"", oType, "GTC", "",
|
||||
s.ClientOrderID, "", "",
|
||||
s.Amount, s.Price, 0, 0, 0, s.ReduceOnly)
|
||||
o, err := b.FuturesNewOrder(
|
||||
ctx,
|
||||
&FuturesNewOrderRequest{
|
||||
Symbol: s.Pair,
|
||||
Side: reqSide,
|
||||
OrderType: oType,
|
||||
TimeInForce: "GTC",
|
||||
NewClientOrderID: s.ClientOrderID,
|
||||
Quantity: s.Amount,
|
||||
Price: s.Price,
|
||||
ReduceOnly: s.ReduceOnly,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return submitOrderResponse, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user