|
1
|
|
|
<?php |
|
2
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Tests; |
|
3
|
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder; |
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode; |
|
6
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection; |
|
7
|
|
|
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler; |
|
8
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Response\FundingRateHistoryResponse; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class FundingRateHistoryTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
private static string $fundingRateHistory = '{"retCode":0,"retMsg":"OK","result":{"category":"linear","list":[{"symbol":"BTCUSDT","fundingRate":"0.0001","fundingRateTimestamp":"1683993600000"},{"symbol":"BTCUSDT","fundingRate":"0.00009144","fundingRateTimestamp":"1683964800000"},{"symbol":"BTCUSDT","fundingRate":"0.0008453","fundingRateTimestamp":"1683936000000"}]},"retExtInfo":{},"time":1684004110974}'; |
|
14
|
|
|
|
|
15
|
|
|
public function testFundingRateHistoryResponse() |
|
16
|
|
|
{ |
|
17
|
|
|
$fundingRateHistoryData = ResponseHandlerBuilder::make(self::$fundingRateHistory, |
|
18
|
|
|
CurlResponseHandler::class, FundingRateHistoryResponse::class, EnumOutputMode::MODE_ENTITY); |
|
19
|
|
|
|
|
20
|
|
|
$this->assertInstanceOf(EntityCollection::class, $fundingRateHistoryData->getBody()); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertNotEmpty($fundingRateHistoryData->getBody()->count()); |
|
23
|
|
|
|
|
24
|
|
|
/** @var FundingRateHistoryResponse $historyItem */ |
|
25
|
|
|
while(!empty($historyItem = $fundingRateHistoryData->getBody()->fetch())) { |
|
26
|
|
|
$this->assertInstanceOf(FundingRateHistoryResponse::class, $historyItem); |
|
27
|
|
|
$this->assertIsString($historyItem->getSymbol()); |
|
28
|
|
|
$this->assertIsFloat($historyItem->getFundingRate()); |
|
29
|
|
|
$this->assertInstanceOf(\DateTime::class, $historyItem->getFundingRateTimestamp()); |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
} |