Skip to content

Commit

Permalink
changed bool types to string in reduceOnly, closePosition, priceProte…
Browse files Browse the repository at this point in the history
…ct. (#506)

* changed bool types to string in reduceOnly, closePosition, priceProtect fields

* updated tests
  • Loading branch information
size12 committed Jun 3, 2024
1 parent dc7abf8 commit 6d8559f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
16 changes: 10 additions & 6 deletions v2/delivery/order_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"net/http"
"strconv"
)

// CreateOrderService create order
Expand All @@ -15,15 +16,15 @@ type CreateOrderService struct {
orderType OrderType
timeInForce *TimeInForceType
quantity string
reduceOnly *bool
reduceOnly *string
price *string
newClientOrderID *string
stopPrice *string
closePosition *bool
closePosition *string
activationPrice *string
callbackRate *string
workingType *WorkingType
priceProtect *bool
priceProtect *string
newOrderRespType NewOrderRespType
}

Expand Down Expand Up @@ -65,7 +66,8 @@ func (s *CreateOrderService) Quantity(quantity string) *CreateOrderService {

// ReduceOnly set reduceOnly
func (s *CreateOrderService) ReduceOnly(reduceOnly bool) *CreateOrderService {
s.reduceOnly = &reduceOnly
reduceOnlyStr := strconv.FormatBool(reduceOnly)
s.reduceOnly = &reduceOnlyStr
return s
}

Expand Down Expand Up @@ -107,7 +109,8 @@ func (s *CreateOrderService) CallbackRate(callbackRate string) *CreateOrderServi

// PriceProtect set priceProtect
func (s *CreateOrderService) PriceProtect(priceProtect bool) *CreateOrderService {
s.priceProtect = &priceProtect
priceProtectStr := strconv.FormatBool(priceProtect)
s.priceProtect = &priceProtectStr
return s
}

Expand All @@ -119,7 +122,8 @@ func (s *CreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderR

// ClosePosition set closePosition
func (s *CreateOrderService) ClosePosition(closePosition bool) *CreateOrderService {
s.closePosition = &closePosition
closePositionStr := strconv.FormatBool(closePosition)
s.closePosition = &closePositionStr
return s
}

Expand Down
7 changes: 4 additions & 3 deletions v2/delivery/order_service_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package delivery

import (
"strconv"
"testing"

"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -71,15 +72,15 @@ func (s *orderServiceTestSuite) TestCreateOrder() {
"type": orderType,
"timeInForce": timeInForce,
"quantity": quantity,
"reduceOnly": reduceOnly,
"reduceOnly": strconv.FormatBool(reduceOnly),
"price": price,
"newClientOrderId": newClientOrderID,
"stopPrice": stopPrice,
"closePosition": closePosition,
"closePosition": strconv.FormatBool(closePosition),
"activationPrice": activationPrice,
"callbackRate": callbackRate,
"workingType": workingType,
"priceProtect": priceProtect,
"priceProtect": strconv.FormatBool(priceProtect),
"newOrderRespType": newOrderResponseType,
})
s.assertRequestEqual(e, r)
Expand Down
16 changes: 10 additions & 6 deletions v2/futures/order_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
"strings"

"github.com/adshao/go-binance/v2/common"
Expand All @@ -20,16 +21,16 @@ type CreateOrderService struct {
orderType OrderType
timeInForce *TimeInForceType
quantity string
reduceOnly *bool
reduceOnly *string
price *string
newClientOrderID *string
stopPrice *string
workingType *WorkingType
activationPrice *string
callbackRate *string
priceProtect *bool
priceProtect *string
newOrderRespType NewOrderRespType
closePosition *bool
closePosition *string
}

// Symbol set symbol
Expand Down Expand Up @@ -70,7 +71,8 @@ func (s *CreateOrderService) Quantity(quantity string) *CreateOrderService {

// ReduceOnly set reduceOnly
func (s *CreateOrderService) ReduceOnly(reduceOnly bool) *CreateOrderService {
s.reduceOnly = &reduceOnly
reduceOnlyStr := strconv.FormatBool(reduceOnly)
s.reduceOnly = &reduceOnlyStr
return s
}

Expand Down Expand Up @@ -112,7 +114,8 @@ func (s *CreateOrderService) CallbackRate(callbackRate string) *CreateOrderServi

// PriceProtect set priceProtect
func (s *CreateOrderService) PriceProtect(priceProtect bool) *CreateOrderService {
s.priceProtect = &priceProtect
priceProtectStr := strconv.FormatBool(priceProtect)
s.priceProtect = &priceProtectStr
return s
}

Expand All @@ -124,7 +127,8 @@ func (s *CreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderR

// ClosePosition set closePosition
func (s *CreateOrderService) ClosePosition(closePosition bool) *CreateOrderService {
s.closePosition = &closePosition
closePositionStr := strconv.FormatBool(closePosition)
s.closePosition = &closePositionStr
return s
}

Expand Down
7 changes: 4 additions & 3 deletions v2/futures/order_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package futures

import (
"context"
"strconv"
"testing"

"github.com/adshao/go-binance/v2/common"
Expand Down Expand Up @@ -69,16 +70,16 @@ func (s *orderServiceTestSuite) TestCreateOrder() {
"timeInForce": timeInForce,
"positionSide": positionSide,
"quantity": quantity,
"reduceOnly": reduceOnly,
"reduceOnly": strconv.FormatBool(reduceOnly),
"price": price,
"newClientOrderId": newClientOrderID,
"stopPrice": stopPrice,
"workingType": workingType,
"activationPrice": activationPrice,
"callbackRate": callbackRate,
"priceProtect": priceProtect,
"priceProtect": strconv.FormatBool(priceProtect),
"newOrderRespType": newOrderResponseType,
"closePosition": closePosition,
"closePosition": strconv.FormatBool(closePosition),
})
s.assertRequestEqual(e, r)
})
Expand Down

0 comments on commit 6d8559f

Please sign in to comment.