Passed
Push — master ( f32712...07732c )
by Vladislav
04:33 queued 01:39
created

SetTradingStopRequest::setSlOrderType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetTradingStop\Request;
3
4
use Carpenstar\ByBitAPI\Core\Objects\AbstractParameters;
5
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetTradingStop\Interfaces\ISetTradingStopRequestInterface;
6
7
class SetTradingStopRequest extends AbstractParameters implements ISetTradingStopRequestInterface
8
{
9
    /**
10
     * Symbol name
11
     * @var string $symbol
12
     */
13
    protected string $symbol;
14
15
    /**
16
     * Cannot be less than 0, 0 means cancel TP. Partial TP/SL cannot be cancelled by set it 0
17
     * @var float $takeProfit
18
     */
19
    protected float $takeProfit;
20
21
    /**
22
     * Cannot be less than 0, 0 means cancel SL. Partial TP/SL cannot be cancelled by set it 0
23
     * @var float $stopLoss
24
     */
25
    protected float $stopLoss;
26
27
    /**
28
     * TP/SL mode. Full: entire position TP/SL, Partial: partial position TP/SL.
29
     * As each contract has an initial full TP/SL mode, if it has been modified before, it may be partial.
30
     * Therefore, if not provided, the system will automatically retrieve the current TP/SL mode configuration for the contract.
31
     * @var string $tpslMode
32
     */
33
    protected string $tpslMode;
34
35
    /**
36
     * Take profit size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal
37
     * @var float $tpSize
38
     */
39
    protected float $tpSize;
40
41
    /**
42
     * Stop loss size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal
43
     * @var float $slSize
44
     */
45
    protected float $slSize;
46
47
    /**
48
     * Take profit trigger price type. default: LastPrice
49
     * @var string $tpTriggerBy
50
     */
51
    protected string $tpTriggerBy;
52
53
    /**
54
     * Stop loss trigger price type. default: LastPrice
55
     * @var string $slTriggerBy
56
     */
57
    protected string $slTriggerBy;
58
59
    /**
60
     * Cannot be less than 0, 0 means cancel TS
61
     * @var float $trailingStop
62
     */
63
    protected float $trailingStop;
64
65
    /**
66
     * Trailing stop trigger price. Trailing stop will be triggered when this price is reached only
67
     * @var float $activePrice
68
     */
69
    protected float $activePrice;
70
71
    /**
72
     * The limit order price when take profit price is triggered. Only works when tpslMode=Partial and tpOrderType=Limit
73
     * @var float $tpLimitPrice
74
     */
75
    protected float $tpLimitPrice;
76
77
    /**
78
     * The limit order price when stop loss price is triggered. Only works when tpslMode=Partial and slOrderType=Limit
79
     * @var float $slLimitPrice
80
     */
81
    protected float $slLimitPrice;
82
83
    /**
84
     * The order type when take profit is triggered. Market(default), Limit. For tpslMode=Full, it only supports tpOrderType=Market
85
     * @var string $tpOrderType
86
     */
87
    protected string $tpOrderType;
88
89
    /**
90
     * The order type when stop loss is triggered. Market(default), Limit. For tpslMode=Full, it only supports slOrderType=Market
91
     * @var string $slOrderType
92
     */
93
    protected string $slOrderType;
94
95
    /**
96
     * Used to identify positions in different position modes. For hedge-mode, this param is required
97
     *  0: one-way mode
98
     *  1: hedge-mode Buy side
99
     *  2: hedge-mode Sell side
100
     */
101
    protected int $positionIdx;
102
103
    public function __construct()
104
    {
105
        $this->setRequiredField("symbol");
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getSymbol(): string
112
    {
113
        return $this->symbol;
114
    }
115
116
    /**
117
     * @param string $symbol
118
     * @return SetTradingStopRequest
119
     */
120
    public function setSymbol(string $symbol): self
121
    {
122
        $this->symbol = $symbol;
123
        return $this;
124
    }
125
126
    /**
127
     * @return float
128
     */
129
    public function getTakeProfit(): float
130
    {
131
        return $this->takeProfit;
132
    }
133
134
    /**
135
     * @param float $takeProfit
136
     * @return SetTradingStopRequest
137
     */
138
    public function setTakeProfit(float $takeProfit): self
139
    {
140
        $this->takeProfit = $takeProfit;
141
        return $this;
142
    }
143
144
    /**
145
     * @return float
146
     */
147
    public function getStopLoss(): float
148
    {
149
        return $this->stopLoss;
150
    }
151
152
    /**
153
     * @param float $stopLoss
154
     * @return SetTradingStopRequest
155
     */
156
    public function setStopLoss(float $stopLoss): self
157
    {
158
        $this->stopLoss = $stopLoss;
159
        return $this;
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    public function getTpslMode(): string
166
    {
167
        return $this->tpslMode;
168
    }
169
170
    /**
171
     * @param string $tpslMode
172
     * @return SetTradingStopRequest
173
     */
174
    public function setTpslMode(string $tpslMode): self
175
    {
176
        $this->tpslMode = $tpslMode;
177
        return $this;
178
    }
179
180
    /**
181
     * @return float
182
     */
183
    public function getTpSize(): float
184
    {
185
        return $this->tpSize;
186
    }
187
188
    /**
189
     * @param float $tpSize
190
     * @return SetTradingStopRequest
191
     */
192
    public function setTpSize(float $tpSize): self
193
    {
194
        $this->tpSize = $tpSize;
195
        return $this;
196
    }
197
198
    /**
199
     * @return float
200
     */
201
    public function getSlSize(): float
202
    {
203
        return $this->slSize;
204
    }
205
206
    /**
207
     * @param float $slSize
208
     * @return SetTradingStopRequest
209
     */
210
    public function setSlSize(float $slSize): self
211
    {
212
        $this->slSize = $slSize;
213
        return $this;
214
    }
215
216
    /**
217
     * @return string
218
     */
219
    public function getTpTriggerBy(): string
220
    {
221
        return $this->tpTriggerBy;
222
    }
223
224
    /**
225
     * @param string $tpTriggerBy
226
     * @return SetTradingStopRequest
227
     */
228
    public function setTpTriggerBy(string $tpTriggerBy): self
229
    {
230
        $this->tpTriggerBy = $tpTriggerBy;
231
        return $this;
232
    }
233
234
    /**
235
     * @return string
236
     */
237
    public function getSlTriggerBy(): string
238
    {
239
        return $this->slTriggerBy;
240
    }
241
242
    /**
243
     * @param string $slTriggerBy
244
     * @return SetTradingStopRequest
245
     */
246
    public function setSlTriggerBy(string $slTriggerBy): self
247
    {
248
        $this->slTriggerBy = $slTriggerBy;
249
        return $this;
250
    }
251
252
    /**
253
     * @return float
254
     */
255
    public function getTrailingStop(): float
256
    {
257
        return $this->trailingStop;
258
    }
259
260
    /**
261
     * @param float $trailingStop
262
     * @return SetTradingStopRequest
263
     */
264
    public function setTrailingStop(float $trailingStop): self
265
    {
266
        $this->trailingStop = $trailingStop;
267
        return $this;
268
    }
269
270
    /**
271
     * @return float
272
     */
273
    public function getActivePrice(): float
274
    {
275
        return $this->activePrice;
276
    }
277
278
    /**
279
     * @param float $activePrice
280
     * @return SetTradingStopRequest
281
     */
282
    public function setActivePrice(float $activePrice): self
283
    {
284
        $this->activePrice = $activePrice;
285
        return $this;
286
    }
287
288
    /**
289
     * @return float
290
     */
291
    public function getTpLimitPrice(): float
292
    {
293
        return $this->tpLimitPrice;
294
    }
295
296
    /**
297
     * @param float $tpLimitPrice
298
     * @return SetTradingStopRequest
299
     */
300
    public function setTpLimitPrice(float $tpLimitPrice): self
301
    {
302
        $this->tpLimitPrice = $tpLimitPrice;
303
        return $this;
304
    }
305
306
    /**
307
     * @return float
308
     */
309
    public function getSlLimitPrice(): float
310
    {
311
        return $this->slLimitPrice;
312
    }
313
314
    /**
315
     * @param float $slLimitPrice
316
     * @return SetTradingStopRequest
317
     */
318
    public function setSlLimitPrice(float $slLimitPrice): self
319
    {
320
        $this->slLimitPrice = $slLimitPrice;
321
        return $this;
322
    }
323
324
    /**
325
     * @return string
326
     */
327
    public function getTpOrderType(): string
328
    {
329
        return $this->tpOrderType;
330
    }
331
332
    /**
333
     * @param string $tpOrderType
334
     * @return SetTradingStopRequest
335
     */
336
    public function setTpOrderType(string $tpOrderType): self
337
    {
338
        $this->tpOrderType = $tpOrderType;
339
        return $this;
340
    }
341
342
    /**
343
     * @return string
344
     */
345
    public function getSlOrderType(): string
346
    {
347
        return $this->slOrderType;
348
    }
349
350
    /**
351
     * @param string $slOrderType
352
     * @return SetTradingStopRequest
353
     */
354
    public function setSlOrderType(string $slOrderType): self
355
    {
356
        $this->slOrderType = $slOrderType;
357
        return $this;
358
    }
359
360
    /**
361
     * @return int
362
     */
363
    public function getPositionIdx(): int
364
    {
365
        return $this->positionIdx;
366
    }
367
368
    /**
369
     * @param int $positionIdx
370
     * @return SetTradingStopRequest
371
     */
372
    public function setPositionIdx(int $positionIdx): self
373
    {
374
        $this->positionIdx = $positionIdx;
375
        return $this;
376
    }
377
}