Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reduce only flag to order request #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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