1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Tests; |
4
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\BybitAPI; |
6
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\InstrumentInfo; |
7
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IInstrumentInfoResponseItemInterface; |
8
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Request\InstrumentInfoRequest; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class InstrumentInfoTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public function testInstrumentInfoResponse() |
14
|
|
|
{ |
15
|
|
|
echo "\n //// --- //// \n"; |
16
|
|
|
|
17
|
|
|
$bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com'); |
18
|
|
|
|
19
|
|
|
$response = $bybit->publicEndpoint( |
20
|
|
|
InstrumentInfo::class, |
21
|
|
|
(new InstrumentInfoRequest()) |
22
|
|
|
->setSymbol('BTCUSDT') |
23
|
|
|
)->execute(); |
24
|
|
|
|
25
|
|
|
if ($response->getReturnCode() == 0) { |
26
|
|
|
echo "CODE: {$response->getReturnCode()}\n"; |
27
|
|
|
echo "MESSAGE: {$response->getReturnMessage()}\n"; |
28
|
|
|
|
29
|
|
|
/** @var IInstrumentInfoResponseItemInterface $instrumentInfo */ |
30
|
|
|
$instrumentInfo = $response->getResult()->getInstrumentInfoList(); |
|
|
|
|
31
|
|
|
|
32
|
|
|
echo "Next Page Cursor: {$instrumentInfo->getNextPageCursor()} \n"; |
33
|
|
|
echo "Symbol: {$instrumentInfo->getSymbol()}\n"; |
34
|
|
|
echo "Contract Type: {$instrumentInfo->getContractType()}\n"; |
35
|
|
|
echo "Status: {$instrumentInfo->getStatus()}\n"; |
36
|
|
|
echo "Base Coin: {$instrumentInfo->getBaseCoin()}\n"; |
37
|
|
|
echo "Settle Coin: {$instrumentInfo->getSettleCoin()} \n"; |
38
|
|
|
echo "Quote Coin: {$instrumentInfo->getQuoteCoin()}\n"; |
39
|
|
|
echo "Launch Time: {$instrumentInfo->getLaunchTime()->format('Y-m-d H:i:s')}\n"; |
40
|
|
|
echo "Delivery Time: {$instrumentInfo->getDeliveryTime()->format('Y-m-d H:i:s')} {}\n"; |
41
|
|
|
echo "Delivery Fee Rate: {$instrumentInfo->getDeliveryFeeRate()} {}\n"; |
42
|
|
|
echo "Price Scale: {$instrumentInfo->getPriceScale()}\n"; |
43
|
|
|
echo "Unified Margin Trade: {$instrumentInfo->getUnifiedMarginTrade()}\n"; |
44
|
|
|
echo "Funding Interval: {$instrumentInfo->getFundingInterval()}\n"; |
45
|
|
|
echo "Leverage Filter: \n"; |
46
|
|
|
foreach ($instrumentInfo->getLeverageFilter()->all() as $filterItem) { |
47
|
|
|
echo " - Minimal Leverage: {$filterItem->getMinLeverage()} \n"; |
48
|
|
|
echo " - Maximal Leverage: {$filterItem->getMaxLeverage()} \n"; |
49
|
|
|
echo " - Leverage Step: {$filterItem->getLeverageStep()} \n"; |
50
|
|
|
} |
51
|
|
|
echo "Price Filter: \n"; |
52
|
|
|
foreach ($instrumentInfo->getPriceFilter()->all() as $priceFilter) { |
53
|
|
|
echo " - Minimal Price: {$priceFilter->getMinPrice()} \n"; |
54
|
|
|
echo " - Maximal Price: {$priceFilter->getMaxPrice()} \n"; |
55
|
|
|
echo " - Tick Size: {$priceFilter->getTickSize()} \n"; |
56
|
|
|
} |
57
|
|
|
echo "Lot Size Filter: \n"; |
58
|
|
|
foreach ($instrumentInfo->getLotSizeFilter()->all() as $lotSizeFilter) { |
59
|
|
|
echo " - Maximal Order Quantity: {$lotSizeFilter->getMaxOrderQty()} \n"; |
60
|
|
|
echo " - Minimal Order Quantity: {$lotSizeFilter->getMinOrderQty()} \n"; |
61
|
|
|
echo " - Quantity Step: {$lotSizeFilter->getQtyStep()} \n"; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$this->assertTrue(true); |
65
|
|
|
} else { |
66
|
|
|
echo "API ERORR: " . get_class($this) . "\n"; |
67
|
|
|
echo "CODE: {$response->getReturnCode()} \n"; |
68
|
|
|
echo "MESSAGE: {$response->getReturnMessage()} \n"; |
69
|
|
|
echo "EXTENDED:" . implode(";\n", $response->getExtendedInfo()) . "\n"; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|