1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Request; |
4
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\StringHelper; |
7
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractParameters; |
8
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Interfaces\IKlineRequestInterface; |
9
|
|
|
|
10
|
|
|
class KlineRequest extends AbstractParameters implements IKlineRequestInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Product type. linear only at now |
14
|
|
|
* @var string $category |
15
|
|
|
*/ |
16
|
|
|
protected string $category = "linear"; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Symbol name |
20
|
|
|
* @var string $symbol |
21
|
|
|
*/ |
22
|
|
|
protected string $symbol; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Kline interval. 1 3 5 15 30 60 120 240 360 720 D M W |
26
|
|
|
* @var string $interval |
27
|
|
|
*/ |
28
|
|
|
protected string $interval; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The start timestamp (ms) |
32
|
|
|
* @var int $start |
33
|
|
|
*/ |
34
|
|
|
protected int $start; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* The end timestamp (ms) |
38
|
|
|
* @var int $end |
39
|
|
|
*/ |
40
|
|
|
protected int $end; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Limit for data size per page. [1, 200]. Default: 200 |
44
|
|
|
* @var int $limit |
45
|
|
|
*/ |
46
|
|
|
protected int $limit = 200; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getCategory(): string |
52
|
|
|
{ |
53
|
|
|
return $this->category; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $symbol |
58
|
|
|
* @return KlineRequest |
59
|
|
|
*/ |
60
|
|
|
public function setSymbol(string $symbol): self |
61
|
|
|
{ |
62
|
|
|
$this->symbol = $symbol; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function getSymbol(): string |
70
|
|
|
{ |
71
|
|
|
return $this->symbol; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $interval |
76
|
|
|
* @return KlineRequest |
77
|
|
|
*/ |
78
|
|
|
public function setInterval(string $interval): self |
79
|
|
|
{ |
80
|
|
|
$this->interval = StringHelper::clearInterval($interval); |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getInterval(): string |
88
|
|
|
{ |
89
|
|
|
return $this->interval; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $start |
94
|
|
|
* @return KlineRequest |
95
|
|
|
*/ |
96
|
|
|
public function setStart(string $start): self |
97
|
|
|
{ |
98
|
|
|
$this->start = DateTimeHelper::makeTimestampFromDateString($start); |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return int |
104
|
|
|
*/ |
105
|
|
|
public function getStart(): int |
106
|
|
|
{ |
107
|
|
|
return $this->start; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $end |
112
|
|
|
* @return KlineRequest |
113
|
|
|
*/ |
114
|
|
|
public function setEnd(string $end): self |
115
|
|
|
{ |
116
|
|
|
$this->end = DateTimeHelper::makeTimestampFromDateString($end); |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return int |
122
|
|
|
*/ |
123
|
|
|
public function getEnd(): int |
124
|
|
|
{ |
125
|
|
|
return $this->end; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param int $limit |
130
|
|
|
* @return KlineRequest |
131
|
|
|
*/ |
132
|
|
|
public function setLimit(int $limit): self |
133
|
|
|
{ |
134
|
|
|
$this->limit = $limit; |
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return int |
140
|
|
|
*/ |
141
|
|
|
public function getLimit(): int |
142
|
|
|
{ |
143
|
|
|
return $this->limit; |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|