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