1
|
|
|
<?php |
2
|
|
|
namespace Spot; |
3
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder; |
5
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder; |
7
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumOrderType; |
8
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode; |
9
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumSide; |
10
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection; |
11
|
|
|
use Carpenstar\ByBitAPI\Core\Overrides\Spot\TestCancelOrder; |
12
|
|
|
use Carpenstar\ByBitAPI\Core\Overrides\Spot\TestGetOrder; |
13
|
|
|
use Carpenstar\ByBitAPI\Core\Overrides\Spot\TestOrderHistory; |
14
|
|
|
use Carpenstar\ByBitAPI\Core\Overrides\Spot\TestPlaceOrder; |
15
|
|
|
use Carpenstar\ByBitAPI\Core\Overrides\Spot\TestTradeHistory; |
16
|
|
|
use Carpenstar\ByBitAPI\Core\Response\CurlResponseDto; |
17
|
|
|
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler; |
18
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\CancelOrder\Request\CancelOrderRequest; |
19
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\CancelOrder\Response\CancelOrderResponse; |
20
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\GetOrder\Request\GetOrderRequest; |
21
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\GetOrder\Response\GetOrderResponse; |
22
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\OrderHistory\Request\OrderHistoryRequest; |
23
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\OrderHistory\Response\OrderHistoryResponse; |
24
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Request\PlaceOrderRequest; |
25
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Response\PlaceOrderResponse; |
26
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\TradeHistory\Request\TradeHistoryRequest; |
27
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\TradeHistory\Response\TradeHistoryResponse; |
28
|
|
|
use PHPUnit\Framework\TestCase; |
29
|
|
|
|
30
|
|
|
class TradeTest extends TestCase |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* SPOT - Trade |
34
|
|
|
* Place order |
35
|
|
|
*/ |
36
|
|
|
static private string $placeOrderResponse = '{"retCode":0,"retMsg":"OK","result":{"orderId":"1477137337600322304","orderLinkId":"64c7ef2bdf040","symbol":"BTCUSDT","createTime":"1690824492584","orderPrice":"1000","orderQty":"0.001","orderType":"LIMIT","side":"BUY","status":"NEW","timeInForce":"GTC","accountId":"1111837","execQty":"0","orderCategory":0,"smpType":"None"},"retExtInfo":{},"time":1690824492593}'; |
37
|
|
|
|
38
|
|
|
public function testPlaceOrderDTOBuilder() |
39
|
|
|
{ |
40
|
|
|
$dto = ResponseDtoBuilder::make(PlaceOrderResponse::class, json_decode(self::$placeOrderResponse, true)['result']); |
41
|
|
|
$this->assertInstanceOf(PlaceOrderResponse::class, $dto); |
42
|
|
|
$this->assertIsInt($dto->getOrderId()); |
43
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
44
|
|
|
$this->assertIsString($dto->getSymbol()); |
45
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
46
|
|
|
|
47
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
48
|
|
|
$this->assertNotEmpty($dto->getOrderPrice()); |
49
|
|
|
|
50
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
51
|
|
|
$this->assertNotEmpty($dto->getOrderQty()); |
52
|
|
|
|
53
|
|
|
$this->assertIsString($dto->getSide()); |
54
|
|
|
$this->assertNotEmpty($dto->getSide()); |
55
|
|
|
|
56
|
|
|
$this->assertIsString($dto->getStatus()); |
57
|
|
|
$this->assertNotEmpty($dto->getStatus()); |
58
|
|
|
|
59
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
60
|
|
|
$this->assertNotEmpty($dto->getTimeInForce()); |
61
|
|
|
|
62
|
|
|
$this->assertIsString($dto->getAccountId()); |
63
|
|
|
$this->assertNotEmpty($dto->getAccountId()); |
64
|
|
|
|
65
|
|
|
$this->assertIsInt($dto->getOrderCategory()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testPlaceOrderResponseHandlerBuilder() |
69
|
|
|
{ |
70
|
|
|
$handler = ResponseHandlerBuilder::make(self::$placeOrderResponse, CurlResponseHandler::class, PlaceOrderResponse::class); |
71
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
72
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testPlaceOrderEndpoint() |
76
|
|
|
{ |
77
|
|
|
$endpoint = RestBuilder::make(TestPlaceOrder::class, (new PlaceOrderRequest()) |
78
|
|
|
->setSymbol("BTCUSDT") |
79
|
|
|
->setOrderQty(0.001) |
80
|
|
|
->setSide(EnumSide::BUY) |
81
|
|
|
->setOrderType(EnumOrderType::MARKET) |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$placeOrderResponse); |
85
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
86
|
|
|
$body = $entityResponse->getBody(); |
87
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
88
|
|
|
|
89
|
|
|
foreach ($body->fetch() as $order) { |
90
|
|
|
$dto = ResponseDtoBuilder::make(PlaceOrderResponse::class, $order); |
91
|
|
|
$this->assertInstanceOf(PlaceOrderResponse::class, $dto); |
92
|
|
|
$this->assertIsInt($dto->getOrderId()); |
93
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
94
|
|
|
$this->assertIsString($dto->getSymbol()); |
95
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
96
|
|
|
|
97
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
98
|
|
|
$this->assertNotEmpty($dto->getOrderPrice()); |
99
|
|
|
|
100
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
101
|
|
|
$this->assertNotEmpty($dto->getOrderQty()); |
102
|
|
|
|
103
|
|
|
$this->assertIsString($dto->getSide()); |
104
|
|
|
$this->assertNotEmpty($dto->getSide()); |
105
|
|
|
|
106
|
|
|
$this->assertIsString($dto->getStatus()); |
107
|
|
|
$this->assertNotEmpty($dto->getStatus()); |
108
|
|
|
|
109
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
110
|
|
|
$this->assertNotEmpty($dto->getTimeInForce()); |
111
|
|
|
|
112
|
|
|
$this->assertIsString($dto->getAccountId()); |
113
|
|
|
$this->assertNotEmpty($dto->getAccountId()); |
114
|
|
|
|
115
|
|
|
$this->assertIsInt($dto->getOrderCategory()); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* SPOT - Trade |
121
|
|
|
* Get order |
122
|
|
|
*/ |
123
|
|
|
static private string $getOrderResponse = '{"retCode":0,"retMsg":"OK","result":{"accountId":"1111837","symbol":"BTCUSDT","orderLinkId":"64c7ef2bdf040","orderId":"1477137337600322304","orderPrice":"1000","orderQty":"0.001","execQty":"0","cummulativeQuoteQty":"0","avgPrice":"0","status":"NEW","timeInForce":"GTC","orderType":"LIMIT","side":"BUY","stopPrice":"0.0","icebergQty":"0.0","createTime":"1690824492584","updateTime":"1690824492595","isWorking":"1","locked":"1","orderCategory":0,"blockTradeId":"","smpType":"None","cancelType":"UNKNOWN","smpGroup":0,"smpOrderId":""},"retExtInfo":{},"time":1690834565801}'; |
124
|
|
|
|
125
|
|
|
public function testGetOrderDTOBuilder() |
126
|
|
|
{ |
127
|
|
|
$dto = ResponseDtoBuilder::make(GetOrderResponse::class, json_decode(self::$getOrderResponse, true)['result']); |
128
|
|
|
$this->assertInstanceOf(GetOrderResponse::class, $dto); |
129
|
|
|
|
130
|
|
|
$this->assertIsInt($dto->getAccountId()); |
131
|
|
|
$this->assertIsString($dto->getSymbol()); |
132
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
133
|
|
|
$this->assertIsInt($dto->getOrderId()); |
134
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
135
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
136
|
|
|
$this->assertIsFloat($dto->getExecQty()); |
137
|
|
|
$this->assertIsFloat($dto->getCummulativeQuoteQty()); |
138
|
|
|
$this->assertIsFloat($dto->getAvgPrice()); |
139
|
|
|
$this->assertIsString($dto->getStatus()); |
140
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
141
|
|
|
$this->assertIsString($dto->getOrderType()); |
142
|
|
|
$this->assertIsString($dto->getSide()); |
143
|
|
|
$this->assertIsFloat($dto->getStopPrice()); |
144
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
145
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getUpdateTime()); |
146
|
|
|
$this->assertIsInt($dto->getIsWorking()); |
147
|
|
|
$this->assertIsFloat($dto->getLocked()); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function testGetOrderResponseHandlerBuilder() |
151
|
|
|
{ |
152
|
|
|
$handler = ResponseHandlerBuilder::make(self::$getOrderResponse, CurlResponseHandler::class, GetOrderResponse::class); |
153
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
154
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function testGetOrderEndpoint() |
158
|
|
|
{ |
159
|
|
|
$endpoint = RestBuilder::make(TestGetOrder::class, (new GetOrderRequest())->setOrderId('1477137337600322304')); |
160
|
|
|
|
161
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$getOrderResponse); |
162
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
163
|
|
|
$body = $entityResponse->getBody(); |
164
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
165
|
|
|
|
166
|
|
|
$dto = $body->fetch(); |
167
|
|
|
|
168
|
|
|
$this->assertIsInt($dto->getAccountId()); |
169
|
|
|
$this->assertIsString($dto->getSymbol()); |
170
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
171
|
|
|
$this->assertIsInt($dto->getOrderId()); |
172
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
173
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
174
|
|
|
$this->assertIsFloat($dto->getExecQty()); |
175
|
|
|
$this->assertIsFloat($dto->getCummulativeQuoteQty()); |
176
|
|
|
$this->assertIsFloat($dto->getAvgPrice()); |
177
|
|
|
$this->assertIsString($dto->getStatus()); |
178
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
179
|
|
|
$this->assertIsString($dto->getOrderType()); |
180
|
|
|
$this->assertIsString($dto->getSide()); |
181
|
|
|
$this->assertIsFloat($dto->getStopPrice()); |
182
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
183
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getUpdateTime()); |
184
|
|
|
$this->assertIsInt($dto->getIsWorking()); |
185
|
|
|
$this->assertIsFloat($dto->getLocked()); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* SPOT - Trade |
191
|
|
|
* Get order |
192
|
|
|
*/ |
193
|
|
|
static private string $cancelOrderResponse = '{"retCode":0,"retMsg":"OK","result":{"orderId":"1477137337600322304","orderLinkId":"64c7ef2bdf040","symbol":"BTCUSDT","createTime":"1690824492584","orderPrice":"1000","orderQty":"0.001","orderType":"LIMIT","side":"BUY","status":"NEW","timeInForce":"GTC","accountId":"1111837","execQty":"0","orderCategory":0,"smpType":"None"},"retExtInfo":{},"time":1690824492593}'; |
194
|
|
|
|
195
|
|
|
public function testCancelOrderDTOBuilder() |
196
|
|
|
{ |
197
|
|
|
$dto = ResponseDtoBuilder::make(CancelOrderResponse::class, json_decode(self::$cancelOrderResponse, true)['result']); |
198
|
|
|
$this->assertInstanceOf(CancelOrderResponse::class, $dto); |
199
|
|
|
|
200
|
|
|
$this->assertIsInt($dto->getOrderId()); |
201
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
202
|
|
|
$this->assertIsString($dto->getSymbol()); |
203
|
|
|
$this->assertIsString($dto->getStatus()); |
204
|
|
|
$this->assertIsInt($dto->getAccountId()); |
205
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
206
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
207
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
208
|
|
|
$this->assertIsFloat($dto->getExecQty()); |
209
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
210
|
|
|
$this->assertIsString($dto->getOrderType()); |
211
|
|
|
$this->assertIsString($dto->getSide()); |
212
|
|
|
|
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public function testCancelOrderResponseHandlerBuilder() |
216
|
|
|
{ |
217
|
|
|
$handler = ResponseHandlerBuilder::make(self::$cancelOrderResponse, CurlResponseHandler::class, CancelOrderResponse::class); |
218
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
219
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function testCancelOrderEndpoint() |
223
|
|
|
{ |
224
|
|
|
$endpoint = RestBuilder::make(TestCancelOrder::class, (new CancelOrderRequest())->setOrderId('1477137337600322304')); |
|
|
|
|
225
|
|
|
|
226
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$cancelOrderResponse); |
227
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
228
|
|
|
$body = $entityResponse->getBody(); |
229
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
230
|
|
|
|
231
|
|
|
$dto = $body->fetch(); |
232
|
|
|
|
233
|
|
|
$this->assertIsInt($dto->getOrderId()); |
234
|
|
|
$this->assertIsString($dto->getOrderLinkId()); |
235
|
|
|
$this->assertIsString($dto->getSymbol()); |
236
|
|
|
$this->assertIsString($dto->getStatus()); |
237
|
|
|
$this->assertIsInt($dto->getAccountId()); |
238
|
|
|
$this->assertIsFloat($dto->getOrderPrice()); |
239
|
|
|
$this->assertInstanceOf(\DateTime::class, $dto->getCreateTime()); |
240
|
|
|
$this->assertIsFloat($dto->getOrderQty()); |
241
|
|
|
$this->assertIsFloat($dto->getExecQty()); |
242
|
|
|
$this->assertIsString($dto->getTimeInForce()); |
243
|
|
|
$this->assertIsString($dto->getOrderType()); |
244
|
|
|
$this->assertIsString($dto->getSide()); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* SPOT - Trade |
250
|
|
|
* Trade History |
251
|
|
|
*/ |
252
|
|
|
static private string $tradeHistoryResponse = '{"retCode":0,"retMsg":"OK","result":{"list":[{"symbol":"BTCUSDT","id":"1210346127973428992","orderId":"1210073515485572864","tradeId":"2100000000001769786","orderPrice":"20500","orderQty":"0.02","execFee":"0.00002","feeTokenId":"BTC","creatTime":"1659020488738","isBuyer": "0","isMaker":"0", "matchOrderId":"1210346015893229312","makerRebate":"0","executionTime":"1659020502026","blockTradeId":""},{"symbol":"BTCUSDT","id":"1208702504949264128","orderId":"1208702504731160320","tradeId":"2100000000001753197","orderPrice":"20240","orderQty":"0.009881","execFee":"0.000009881","feeTokenId":"BTC","creatTime":"1658824566874","isBuyer":"0","isMaker":"1","matchOrderId":"1208677465155702529","makerRebate":"0","executionTime":"1658824566893","blockTradeId":""}]}, "retExtMap": {},"retExtInfo": {},"time":1659084254366}'; |
253
|
|
|
|
254
|
|
|
public function testTradeHistoryDTOBuilder() |
255
|
|
|
{ |
256
|
|
|
foreach (json_decode(self::$tradeHistoryResponse, true)['result']['list'] as $trade) { |
257
|
|
|
$dto = ResponseDtoBuilder::make(TradeHistoryResponse::class, $trade); |
258
|
|
|
$this->assertInstanceOf(TradeHistoryResponse::class, $dto); |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function testTradeHistoryResponseHandlerBuilder() |
263
|
|
|
{ |
264
|
|
|
$handler = ResponseHandlerBuilder::make(self::$tradeHistoryResponse, CurlResponseHandler::class, TradeHistoryResponse::class); |
265
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
266
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function testTradeHistoryEndpoint() |
270
|
|
|
{ |
271
|
|
|
$endpoint = RestBuilder::make(TestTradeHistory::class, (new TradeHistoryRequest())); |
272
|
|
|
|
273
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$tradeHistoryResponse); |
274
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
275
|
|
|
$body = $entityResponse->getBody(); |
276
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
277
|
|
|
|
278
|
|
|
while (!empty($trade = $body->fetch())) { |
279
|
|
|
$this->assertIsString($trade->getSymbol()); |
280
|
|
|
$this->assertIsInt($trade->getId()); |
281
|
|
|
$this->assertIsInt($trade->getOrderId()); |
282
|
|
|
$this->assertIsInt($trade->getTradeId()); |
283
|
|
|
$this->assertIsFloat($trade->getOrderPrice()); |
284
|
|
|
$this->assertIsFloat($trade->getOrderQty()); |
285
|
|
|
$this->assertIsFloat($trade->getExecFee()); |
286
|
|
|
$this->assertIsString($trade->getFeeTokenId()); |
287
|
|
|
$this->assertInstanceOf(\DateTime::class, $trade->getCreatTime()); |
288
|
|
|
$this->assertIsInt($trade->getIsBuyer()); |
289
|
|
|
$this->assertIsInt($trade->getIsMaker()); |
290
|
|
|
$this->assertIsInt($trade->getMatchOrderId()); |
291
|
|
|
$this->assertIsInt($trade->getMakerRebate()); |
292
|
|
|
$this->assertInstanceOf(\DateTime::class, $trade->getExecutionTime()); |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* SPOT - Trade |
298
|
|
|
* Order History |
299
|
|
|
*/ |
300
|
|
|
static private string $orderHistoryResponse = '{"retCode":0,"retMsg":"OK","result":{"list":[{"accountId":"533287","symbol":"BTCUSDT","orderLinkId":"spotx003","orderId":"1210856408331857664","orderPrice":"23800","orderQty":"0.02","execQty":"0","cummulativeQuoteQty":"0","avgPrice":"0","status":"REJECTED","timeInForce":"GTC","orderType":"LIMIT_MAKER","side":"BUY","stopPrice":"0.0","icebergQty":"0.0","createTime":1659081332185,"updateTime":1659081332225,"isWorking":"1","blockTradeId":"","cancelType":"UNKNOWN","smpGroup":0,"smpOrderId":"","smpType":"None"}]},"retExtInfo":{},"time":1659082630638}'; |
301
|
|
|
|
302
|
|
|
public function testOrderHistoryDTOBuilder() |
303
|
|
|
{ |
304
|
|
|
foreach (json_decode(self::$orderHistoryResponse, true)['result']['list'] as $order) { |
305
|
|
|
$dto = ResponseDtoBuilder::make(OrderHistoryResponse::class, $order); |
306
|
|
|
$this->assertInstanceOf(OrderHistoryResponse::class, $dto); |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
public function testOrderHistoryResponseHandlerBuilder() |
311
|
|
|
{ |
312
|
|
|
$handler = ResponseHandlerBuilder::make(self::$orderHistoryResponse, CurlResponseHandler::class, OrderHistoryResponse::class); |
313
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
314
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public function testOrderHistoryEndpoint() |
318
|
|
|
{ |
319
|
|
|
$endpoint = RestBuilder::make(TestOrderHistory::class, (new OrderHistoryRequest())); |
320
|
|
|
|
321
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$orderHistoryResponse); |
322
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
323
|
|
|
$body = $entityResponse->getBody(); |
324
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
325
|
|
|
|
326
|
|
|
while (!empty($order = $body->fetch())) { |
327
|
|
|
$this->assertIsInt($order->getAccountId()); |
328
|
|
|
$this->assertIsString($order->getSymbol()); |
329
|
|
|
$this->assertIsString($order->getOrderLinkId()); |
330
|
|
|
$this->assertIsInt($order->getOrderId()); |
331
|
|
|
$this->assertIsFloat($order->getOrderPrice()); |
332
|
|
|
$this->assertIsFloat($order->getOrderQty()); |
333
|
|
|
$this->assertIsFloat($order->getExecQty()); |
334
|
|
|
$this->assertIsFloat($order->getCummulativeQuoteQty()); |
335
|
|
|
$this->assertIsFloat($order->getAvgPrice()); |
336
|
|
|
$this->assertIsString($order->getStatus()); |
337
|
|
|
$this->assertIsString($order->getTimeInForce()); |
338
|
|
|
$this->assertIsString($order->getOrderType()); |
339
|
|
|
$this->assertIsString($order->getSide()); |
340
|
|
|
$this->assertIsFloat($order->getStopPrice()); |
341
|
|
|
$this->assertInstanceOf(\DateTime::class, $order->getCreateTime()); |
342
|
|
|
$this->assertInstanceOf(\DateTime::class, $order->getUpdateTime()); |
343
|
|
|
$this->assertIsInt($order->getIsWorking()); |
344
|
|
|
$this->assertIsInt($order->getOrderCategory()); |
345
|
|
|
if (!is_null($order->getTriggerPrice())) { |
346
|
|
|
$this->assertIsFloat($order->getTriggerPrice()); |
347
|
|
|
} |
348
|
|
|
} |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
|