Skip to content

Commit

Permalink
Add ReplaceLinearOrder for USDT perp (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: Emanuele Bolognesi <35916369+adrift942@users.noreply.github.com>
  • Loading branch information
quantoor and quantoor authored Dec 19, 2022
1 parent 66cd0b9 commit 7ab8e57
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions future_usdt_perpetual.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type FutureUSDTPerpetualServiceI interface {
ListLinearOrder(ListLinearOrderParam) (*ListLinearOrderResponse, error)
CancelLinearOrder(CancelLinearOrderParam) (*CancelLinearOrderResponse, error)
LinearCancelAllOrder(LinearCancelAllParam) (*LinearCancelAllResponse, error)
ReplaceLinearOrder(ReplaceLinearOrderParam) (*ReplaceLinearOrderResponse, error)
QueryLinearOrder(QueryLinearOrderParam) (*QueryLinearOrderResponse, error)
CreateLinearStopOrder(CreateLinearStopOrderParam) (*CreateLinearStopOrderResponse, error)
ListLinearStopOrder(ListLinearStopOrderParam) (*ListLinearStopOrderResponse, error)
Expand Down Expand Up @@ -495,6 +496,47 @@ func (s *FutureUSDTPerpetualService) LinearCancelAllOrder(param LinearCancelAllP
return &res, nil
}

// ReplaceLinearOrderResponse :
type ReplaceLinearOrderResponse struct {
CommonResponse `json:",inline"`
Result ReplaceLinearOrderResult `json:"result"`
}

// ReplaceLinearOrderResult :
type ReplaceLinearOrderResult struct {
OrderID string `json:"order_id"`
}

// ReplaceLinearOrderParam :
type ReplaceLinearOrderParam struct {
Symbol SymbolFuture `json:"symbol"`

OrderID *string `json:"order_id,omitempty"`
OrderLinkID *string `json:"order_link_id,omitempty"`
NewQuantity *float64 `json:"p_r_qty,omitempty"`
NewPrice *float64 `json:"p_r_price,omitempty"`
TakeProfit *float64 `json:"take_profit,omitempty"`
StopLoss *float64 `json:"stop_loss,omitempty"`
TpTriggerBy *TriggerByFuture `json:"tp_trigger_by,omitempty"`
SlTriggerBy *TriggerByFuture `json:"sl_trigger_by,omitempty"`
}

// ReplaceLinearOrder :
func (s *FutureUSDTPerpetualService) ReplaceLinearOrder(param ReplaceLinearOrderParam) (*ReplaceLinearOrderResponse, error) {
var res ReplaceLinearOrderResponse

body, err := json.Marshal(param)
if err != nil {
return nil, fmt.Errorf("json marshal for ReplaceLinearOrderResult: %w", err)
}

if err := s.client.postJSON("/private/linear/order/replace", body, &res); err != nil {
return nil, err
}

return &res, nil
}

// QueryLinearOrderResponse :
type QueryLinearOrderResponse struct {
CommonResponse `json:",inline"`
Expand Down

0 comments on commit 7ab8e57

Please sign in to comment.