From 77b595ca94f81d62476766e38bf9d389179958cc Mon Sep 17 00:00:00 2001 From: evzpav Date: Sat, 4 Mar 2023 16:45:38 -0300 Subject: [PATCH] add reduce only flag to order request --- pkg/models/common/common.go | 1 + pkg/models/order/orderrequests.go | 5 +++++ v2/rest/client.go | 5 ++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/models/common/common.go b/pkg/models/common/common.go index 84cd62b2a..3630defaa 100644 --- a/pkg/models/common/common.go +++ b/pkg/models/common/common.go @@ -8,6 +8,7 @@ import ( const ( OrderFlagHidden int = 64 OrderFlagClose int = 512 + OrderFlagReduceOnly int = 1024 OrderFlagPostOnly int = 4096 OrderFlagOCO int = 16384 Checksum int = 131072 diff --git a/pkg/models/order/orderrequests.go b/pkg/models/order/orderrequests.go index 19afcefd7..4a0f907a5 100644 --- a/pkg/models/order/orderrequests.go +++ b/pkg/models/order/orderrequests.go @@ -22,6 +22,7 @@ type NewRequest struct { PriceOcoStop float64 `json:"price_oco_stop,string,omitempty"` Hidden bool `json:"hidden,omitempty"` PostOnly bool `json:"postonly,omitempty"` + ReduceOnly bool `json:"reduceonly,omitempty"` Close bool `json:"close,omitempty"` OcoOrder bool `json:"oco_order,omitempty"` TimeInForce string `json:"tif,omitempty"` @@ -77,6 +78,10 @@ func (nr *NewRequest) EnrichedPayload() interface{} { pld.Flags = pld.Flags + common.OrderFlagPostOnly } + if nr.ReduceOnly { + pld.Flags = pld.Flags + common.OrderFlagReduceOnly + } + if nr.OcoOrder { pld.Flags = pld.Flags + common.OrderFlagOCO } diff --git a/v2/rest/client.go b/v2/rest/client.go index 3e195769e..664c5e015 100644 --- a/v2/rest/client.go +++ b/v2/rest/client.go @@ -52,7 +52,6 @@ type Client struct { Pulse PulseService Invoice InvoiceService Market MarketService - Synchronous } @@ -100,11 +99,11 @@ func NewClientWithURL(url string) *Client { // Create a new Rest client with a synchronous HTTP handler and a custom nonce generaotr func NewClientWithSynchronousNonce(sync Synchronous, nonce utils.NonceGenerator) *Client { - return NewClientWithSynchronousURLNonce(sync, productionBaseURL, nonce) + return NewClientWithSynchronousURLNonce(sync, nonce) } // Create a new Rest client with a synchronous HTTP handler and a custom base url and nonce generator -func NewClientWithSynchronousURLNonce(sync Synchronous, url string, nonce utils.NonceGenerator) *Client { +func NewClientWithSynchronousURLNonce(sync Synchronous, nonce utils.NonceGenerator) *Client { c := &Client{ Synchronous: sync, nonce: nonce,