Skip to content

Commit

Permalink
add reduce only flag to order request
Browse files Browse the repository at this point in the history
  • Loading branch information
evzpav committed Mar 4, 2023
1 parent 9e0b26f commit 3a72c7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/models/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
const (
OrderFlagHidden int = 64
OrderFlagClose int = 512
OrderFlagReduceOnly int = 1024
OrderFlagPostOnly int = 4096
OrderFlagOCO int = 16384
Checksum int = 131072
Expand Down
5 changes: 5 additions & 0 deletions pkg/models/order/orderrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions v2/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type Client struct {
Pulse PulseService
Invoice InvoiceService
Market MarketService

Synchronous
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3a72c7e

Please sign in to comment.