1
|
|
|
<?php |
2
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Request; |
3
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\StringHelper; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractParameters; |
7
|
|
|
|
8
|
|
|
class OpenInterestRequest extends AbstractParameters |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* |
12
|
|
|
* @var string $category |
13
|
|
|
*/ |
14
|
|
|
protected string $category = "linear"; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Symbol name |
18
|
|
|
* @var string $symbol |
19
|
|
|
*/ |
20
|
|
|
protected string $symbol; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Interval. 5min 15min 30min 1h 4h 1d |
24
|
|
|
* @var string $interval |
25
|
|
|
*/ |
26
|
|
|
protected string $interval; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The start timestamp |
30
|
|
|
* @var \DateTime $startTime |
31
|
|
|
*/ |
32
|
|
|
protected \DateTime $startTime; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The end timestamp |
36
|
|
|
* @var \DateTime $endTime |
37
|
|
|
*/ |
38
|
|
|
protected \DateTime $endTime; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Limit for data size per page. [1, 200]. Default: 50 |
42
|
|
|
* @var int $limit |
43
|
|
|
*/ |
44
|
|
|
protected int $limit = 50; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Cursor. Used for pagination |
48
|
|
|
* @var string $cursor |
49
|
|
|
*/ |
50
|
|
|
protected string $cursor; |
51
|
|
|
|
52
|
|
|
public function __construct() |
53
|
|
|
{ |
54
|
|
|
$this |
55
|
|
|
->setRequiredField('symbol') |
56
|
|
|
->setRequiredField('interval'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function getCategory(): string |
63
|
|
|
{ |
64
|
|
|
return $this->category; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $symbol |
69
|
|
|
* @return OpenInterestRequest |
70
|
|
|
*/ |
71
|
|
|
public function setSymbol(string $symbol): self |
72
|
|
|
{ |
73
|
|
|
$this->symbol = $symbol; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
|
public function getSymbol(): string |
81
|
|
|
{ |
82
|
|
|
return $this->symbol; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param string $interval |
87
|
|
|
* @return OpenInterestRequest |
88
|
|
|
*/ |
89
|
|
|
public function setInterval(string $interval): self |
90
|
|
|
{ |
91
|
|
|
$this->interval = StringHelper::clearInterval($interval) . "min"; |
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
public function getInterval(): string |
99
|
|
|
{ |
100
|
|
|
return $this->interval; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param int $startTime |
105
|
|
|
* @return OpenInterestRequest |
106
|
|
|
*/ |
107
|
|
|
public function setStartTime(int $startTime): self |
108
|
|
|
{ |
109
|
|
|
$this->startTime = DateTimeHelper::makeFromTimestamp($startTime); |
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return \DateTime |
115
|
|
|
*/ |
116
|
|
|
public function getStartTime(): \DateTime |
117
|
|
|
{ |
118
|
|
|
return $this->startTime; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param int $endTime |
123
|
|
|
* @return OpenInterestRequest |
124
|
|
|
*/ |
125
|
|
|
public function setEndTime(int $endTime): self |
126
|
|
|
{ |
127
|
|
|
$this->endTime = DateTimeHelper::makeFromTimestamp($endTime); |
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return \DateTime |
133
|
|
|
*/ |
134
|
|
|
public function getEndTime(): \DateTime |
135
|
|
|
{ |
136
|
|
|
return $this->endTime; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param int $limit |
141
|
|
|
* @return OpenInterestRequest |
142
|
|
|
*/ |
143
|
|
|
public function setLimit(int $limit): self |
144
|
|
|
{ |
145
|
|
|
$this->limit = $limit; |
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return int |
151
|
|
|
*/ |
152
|
|
|
public function getLimit(): int |
153
|
|
|
{ |
154
|
|
|
return $this->limit; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param string $cursor |
159
|
|
|
* @return OpenInterestRequest |
160
|
|
|
*/ |
161
|
|
|
public function setCursor(string $cursor): self |
162
|
|
|
{ |
163
|
|
|
$this->cursor = $cursor; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return string |
169
|
|
|
*/ |
170
|
|
|
public function getCursor(): string |
171
|
|
|
{ |
172
|
|
|
return $this->cursor; |
173
|
|
|
} |
174
|
|
|
} |