Passed
Push — master ( 7a134a...be08d2 )
by Vladislav
02:35 queued 13s
created

PlaceOrderRequestOptions   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 236
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 19
eloc 42
dl 0
loc 236
rs 10
c 0
b 0
f 0

19 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrderLinkId() 0 4 1
A getSymbol() 0 3 1
A setOrderQty() 0 4 1
A getTriggerPrice() 0 3 1
A getOrderPrice() 0 3 1
A setOrderType() 0 4 1
A setTriggerPrice() 0 4 1
A getOrderQty() 0 3 1
A getOrderCategory() 0 3 1
A setSide() 0 4 1
A getSide() 0 3 1
A getOrderLinkId() 0 3 1
A setSymbol() 0 4 1
A getOrderType() 0 3 1
A setOrderCategory() 0 4 1
A getTimeInForce() 0 3 1
A setOrderPrice() 0 4 1
A __construct() 0 7 1
A setTimeInForce() 0 4 1
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Request;
3
4
use Carpenstar\ByBitAPI\Core\Enums\EnumOrderType;
5
use Carpenstar\ByBitAPI\Core\Objects\OptionsEntity;
6
7
/**
8
 * Warning: Do not use the duplicate orderLinkId in normal order & TP/SL order
9
 */
10
class PlaceOrderRequestOptions extends OptionsEntity
11
{
12
    /**
13
     * Name of the trading pair
14
     * @var string $symbol
15
     * @required true
16
     */
17
    protected string $symbol;
18
19
    /**
20
     * Order type
21
     * @var string $orderType
22
     * @required true
23
     */
24
    protected string $orderType = EnumOrderType::MARKET;
25
26
    /**
27
     * Side. BUY, SELL
28
     * @var string $side
29
     * @required true
30
     */
31
    protected string $side;
32
33
    /**
34
     * User-generated order ID
35
     * @var string $orderLinkId
36
     * @required false
37
     */
38
    protected string $orderLinkId;
39
40
    /**
41
     * Order price. When the type field is MARKET, the price field is optional.
42
     * When the type field is LIMIT or LIMIT_MAKER, the price field is required
43
     * @var float $orderPrice
44
     * @required false
45
     */
46
    protected float $orderPrice;
47
48
    /**
49
     * Time in force. E.q. EnumTimeInForce::GOOD_TILL_CANCELED
50
     * @var string $timeInForce
51
     * @required false
52
     */
53
    protected string $timeInForce;
54
55
    /**
56
     * Order qty. When you place a MARKET BUY order, this param means quote amount. e.g.,
57
     * MARKET BUY BTCUSDT, orderQty should be 200 USDT
58
     * @var float $orderQty
59
     * @required true
60
     */
61
    protected float $orderQty;
62
63
    /**
64
     * Order category. 0:normal order by default; 1:TP/SL order, Required for TP/SL order.
65
     * @var string
66
     * @required false
67
     */
68
    protected string $orderCategory;
69
70
    /**
71
     * Trigger price. Used for TP/SL order
72
     * @var float $triggerPrice
73
     * @required false
74
     */
75
    protected float $triggerPrice;
76
77
    public function __construct()
78
    {
79
        $this
80
            ->setRequiredField('symbol')
81
            ->setRequiredField('orderQty')
82
            ->setRequiredField('side')
83
            ->setRequiredField('orderType');
84
    }
85
86
    /**
87
     * @param string $symbol
88
     * @return $this
89
     */
90
    public function setSymbol(string $symbol): self
91
    {
92
        $this->symbol = $symbol;
93
        return $this;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getSymbol(): ?string
100
    {
101
        return $this->symbol;
102
    }
103
104
    /**
105
     * @param string $orderType
106
     * @return $this
107
     */
108
    public function setOrderType(string $orderType): self
109
    {
110
        $this->orderType = $orderType;
111
        return $this;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getOrderType(): ?string
118
    {
119
        return $this->orderType;
120
    }
121
122
    /**
123
     * @param string $side
124
     * @return $this
125
     */
126
    public function setSide(string $side): self
127
    {
128
        $this->side = $side;
129
        return $this;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getSide(): ?string
136
    {
137
        return $this->side;
138
    }
139
140
    /**
141
     * @param string $orderLinkId
142
     * @return $this
143
     */
144
    public function setOrderLinkId(string $orderLinkId): self
145
    {
146
        $this->orderLinkId = $orderLinkId;
147
        return $this;
148
    }
149
150
    /**
151
     * @return string
152
     */
153
    public function getOrderLinkId(): ?string
154
    {
155
        return $this->orderLinkId;
156
    }
157
158
    /**
159
     * @param float $orderQty
160
     * @return $this
161
     */
162
    public function setOrderQty(float $orderQty): self
163
    {
164
        $this->orderQty = $orderQty;
165
        return $this;
166
    }
167
168
    /**
169
     * @return string
170
     */
171
    public function getOrderQty(): ?string
172
    {
173
        return $this->orderQty;
174
    }
175
176
    /**
177
     * @param float $orderPrice
178
     * @return $this
179
     */
180
    public function setOrderPrice(float $orderPrice): self
181
    {
182
        $this->orderPrice = $orderPrice;
183
        return $this;
184
    }
185
186
    /**
187
     * @return float
188
     */
189
    public function getOrderPrice(): ?float
190
    {
191
        return $this->orderPrice;
192
    }
193
194
    /**
195
     * @param string $timeInForce
196
     * @return $this
197
     */
198
    public function setTimeInForce(string $timeInForce): self
199
    {
200
        $this->timeInForce = $timeInForce;
201
        return $this;
202
    }
203
204
    /**
205
     * @return string
206
     */
207
    public function getTimeInForce(): ?string
208
    {
209
        return $this->timeInForce;
210
    }
211
212
    /**
213
     * @param string $orderCategory
214
     * @return PlaceOrderRequestOptions
215
     */
216
    public function setOrderCategory(string $orderCategory): self
217
    {
218
        $this->orderCategory = $orderCategory;
219
        return $this;
220
    }
221
222
    /**
223
     * @return string
224
     */
225
    public function getOrderCategory(): ?string
226
    {
227
        return $this->orderCategory;
228
    }
229
230
    /**
231
     * @param float $triggerPrice
232
     * @return PlaceOrderRequestOptions
233
     */
234
    public function setTriggerPrice(float $triggerPrice): self
235
    {
236
        $this->triggerPrice = $triggerPrice;
237
        return $this;
238
    }
239
240
    /**
241
     * @return float
242
     */
243
    public function getTriggerPrice(): ?float
244
    {
245
        return $this->triggerPrice;
246
    }
247
}