Skip to content

Commit 6d8559f

Browse files
authored
changed bool types to string in reduceOnly, closePosition, priceProtect. (#506)
* changed bool types to string in reduceOnly, closePosition, priceProtect fields * updated tests
1 parent dc7abf8 commit 6d8559f

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

v2/delivery/order_service.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"net/http"
7+
"strconv"
78
)
89

910
// CreateOrderService create order
@@ -15,15 +16,15 @@ type CreateOrderService struct {
1516
orderType OrderType
1617
timeInForce *TimeInForceType
1718
quantity string
18-
reduceOnly *bool
19+
reduceOnly *string
1920
price *string
2021
newClientOrderID *string
2122
stopPrice *string
22-
closePosition *bool
23+
closePosition *string
2324
activationPrice *string
2425
callbackRate *string
2526
workingType *WorkingType
26-
priceProtect *bool
27+
priceProtect *string
2728
newOrderRespType NewOrderRespType
2829
}
2930

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

6667
// ReduceOnly set reduceOnly
6768
func (s *CreateOrderService) ReduceOnly(reduceOnly bool) *CreateOrderService {
68-
s.reduceOnly = &reduceOnly
69+
reduceOnlyStr := strconv.FormatBool(reduceOnly)
70+
s.reduceOnly = &reduceOnlyStr
6971
return s
7072
}
7173

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

108110
// PriceProtect set priceProtect
109111
func (s *CreateOrderService) PriceProtect(priceProtect bool) *CreateOrderService {
110-
s.priceProtect = &priceProtect
112+
priceProtectStr := strconv.FormatBool(priceProtect)
113+
s.priceProtect = &priceProtectStr
111114
return s
112115
}
113116

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

120123
// ClosePosition set closePosition
121124
func (s *CreateOrderService) ClosePosition(closePosition bool) *CreateOrderService {
122-
s.closePosition = &closePosition
125+
closePositionStr := strconv.FormatBool(closePosition)
126+
s.closePosition = &closePositionStr
123127
return s
124128
}
125129

v2/delivery/order_service_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package delivery
22

33
import (
4+
"strconv"
45
"testing"
56

67
"github.com/stretchr/testify/suite"
@@ -71,15 +72,15 @@ func (s *orderServiceTestSuite) TestCreateOrder() {
7172
"type": orderType,
7273
"timeInForce": timeInForce,
7374
"quantity": quantity,
74-
"reduceOnly": reduceOnly,
75+
"reduceOnly": strconv.FormatBool(reduceOnly),
7576
"price": price,
7677
"newClientOrderId": newClientOrderID,
7778
"stopPrice": stopPrice,
78-
"closePosition": closePosition,
79+
"closePosition": strconv.FormatBool(closePosition),
7980
"activationPrice": activationPrice,
8081
"callbackRate": callbackRate,
8182
"workingType": workingType,
82-
"priceProtect": priceProtect,
83+
"priceProtect": strconv.FormatBool(priceProtect),
8384
"newOrderRespType": newOrderResponseType,
8485
})
8586
s.assertRequestEqual(e, r)

v2/futures/order_service.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9+
"strconv"
910
"strings"
1011

1112
"github.com/adshao/go-binance/v2/common"
@@ -20,16 +21,16 @@ type CreateOrderService struct {
2021
orderType OrderType
2122
timeInForce *TimeInForceType
2223
quantity string
23-
reduceOnly *bool
24+
reduceOnly *string
2425
price *string
2526
newClientOrderID *string
2627
stopPrice *string
2728
workingType *WorkingType
2829
activationPrice *string
2930
callbackRate *string
30-
priceProtect *bool
31+
priceProtect *string
3132
newOrderRespType NewOrderRespType
32-
closePosition *bool
33+
closePosition *string
3334
}
3435

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

7172
// ReduceOnly set reduceOnly
7273
func (s *CreateOrderService) ReduceOnly(reduceOnly bool) *CreateOrderService {
73-
s.reduceOnly = &reduceOnly
74+
reduceOnlyStr := strconv.FormatBool(reduceOnly)
75+
s.reduceOnly = &reduceOnlyStr
7476
return s
7577
}
7678

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

113115
// PriceProtect set priceProtect
114116
func (s *CreateOrderService) PriceProtect(priceProtect bool) *CreateOrderService {
115-
s.priceProtect = &priceProtect
117+
priceProtectStr := strconv.FormatBool(priceProtect)
118+
s.priceProtect = &priceProtectStr
116119
return s
117120
}
118121

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

125128
// ClosePosition set closePosition
126129
func (s *CreateOrderService) ClosePosition(closePosition bool) *CreateOrderService {
127-
s.closePosition = &closePosition
130+
closePositionStr := strconv.FormatBool(closePosition)
131+
s.closePosition = &closePositionStr
128132
return s
129133
}
130134

v2/futures/order_service_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package futures
22

33
import (
44
"context"
5+
"strconv"
56
"testing"
67

78
"github.com/adshao/go-binance/v2/common"
@@ -69,16 +70,16 @@ func (s *orderServiceTestSuite) TestCreateOrder() {
6970
"timeInForce": timeInForce,
7071
"positionSide": positionSide,
7172
"quantity": quantity,
72-
"reduceOnly": reduceOnly,
73+
"reduceOnly": strconv.FormatBool(reduceOnly),
7374
"price": price,
7475
"newClientOrderId": newClientOrderID,
7576
"stopPrice": stopPrice,
7677
"workingType": workingType,
7778
"activationPrice": activationPrice,
7879
"callbackRate": callbackRate,
79-
"priceProtect": priceProtect,
80+
"priceProtect": strconv.FormatBool(priceProtect),
8081
"newOrderRespType": newOrderResponseType,
81-
"closePosition": closePosition,
82+
"closePosition": strconv.FormatBool(closePosition),
8283
})
8384
s.assertRequestEqual(e, r)
8485
})

0 commit comments

Comments
 (0)