Skip to content

Commit

Permalink
added order flag consts and fixed order flag order new flag serializa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
brobits committed Apr 20, 2018
1 parent 72a16fb commit 42e56d6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ type bookFrequency string
// BookFrequency provides a typed book frequency.
type BookFrequency bookFrequency

const (
OrderFlagHidden int = 64
OrderFlagClose = 512
OrderFlagPostOnly = 4096
OrderFlagOCO = 16384
)

// OrderNewRequest represents an order to be posted to the bitfinex websocket
// service.
type OrderNewRequest struct {
Expand Down Expand Up @@ -139,8 +146,7 @@ func (o *OrderNewRequest) MarshalJSON() ([]byte, error) {
Price float64 `json:"price,string"`
PriceTrailing float64 `json:"price_trailing,string,omitempty"`
PriceAuxLimit float64 `json:"price_aux_limit,string,omitempty"`
Hidden int `json:"hidden,omitempty"`
PostOnly int `json:"postonly,omitempty"`
Flags int `json:"flags,omitempty"`
}{
GID: o.GID,
CID: o.CID,
Expand All @@ -153,11 +159,11 @@ func (o *OrderNewRequest) MarshalJSON() ([]byte, error) {
}

if o.Hidden {
aux.Hidden = 1
aux.Flags = aux.Flags + OrderFlagHidden
}

if o.PostOnly {
aux.PostOnly = 1
aux.Flags = aux.Flags + OrderFlagPostOnly
}

body := []interface{}{0, "on", nil, aux}
Expand Down

0 comments on commit 42e56d6

Please sign in to comment.