|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\BybitAPI; |
|
6
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Interfaces\ITickerInfoResponseItemInterface; |
|
7
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Request\TickerInfoRequest; |
|
8
|
|
|
use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\TickerInfo; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class TickerInfoTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function testRiskLimitEndpoint() |
|
14
|
|
|
{ |
|
15
|
|
|
$bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com'); |
|
16
|
|
|
|
|
17
|
|
|
$endpointResponse = $bybit->publicEndpoint( |
|
18
|
|
|
TickerInfo::class, |
|
19
|
|
|
(new TickerInfoRequest()) |
|
|
|
|
|
|
20
|
|
|
->setSymbol('BTCUSDT') |
|
21
|
|
|
)->execute(); |
|
22
|
|
|
|
|
23
|
|
|
echo "Return code: {$endpointResponse->getReturnCode()}\n"; |
|
24
|
|
|
echo "Return message: {$endpointResponse->getReturnMessage()}\n"; |
|
25
|
|
|
|
|
26
|
|
|
/** @var ITickerInfoResponseItemInterface $tickerInfo */ |
|
27
|
|
|
$tickerInfo = $endpointResponse->getResult()->getTickerInfo(); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
echo "Symbol: {$tickerInfo->getSymbol()}\n"; |
|
30
|
|
|
echo "Bid Price: {$tickerInfo->getBidPrice()}\n"; |
|
31
|
|
|
echo "Ask Price: {$tickerInfo->getAskPrice()}\n"; |
|
32
|
|
|
echo "Last Price: {$tickerInfo->getLastPrice()}\n"; |
|
33
|
|
|
echo "Last Tick Direction: {$tickerInfo->getLastTickDirection()}\n"; |
|
34
|
|
|
echo "Prev Price 24 hours: {$tickerInfo->getPrevPrice24h()}\n"; |
|
35
|
|
|
echo "Prev Price 24 hours(%): {$tickerInfo->getPrice24hPcnt()}\n"; |
|
36
|
|
|
echo "High Price 24 hours: {$tickerInfo->getHighPrice24h()}\n"; |
|
37
|
|
|
echo "Low Price 24 hours: {$tickerInfo->getLowPrice24h()}\n"; |
|
38
|
|
|
echo "Prev price 1 hour: {$tickerInfo->getPrevPrice1h()}\n"; |
|
39
|
|
|
echo "Mark Price: {$tickerInfo->getMarkPrice()}\n"; |
|
40
|
|
|
echo "Index Price: {$tickerInfo->getIndexPrice()}\n"; |
|
41
|
|
|
echo "Open Interest: {$tickerInfo->getOpenInterests()}\n"; |
|
42
|
|
|
echo "Open Interest Value: {$tickerInfo->getOpenInterestValue()}\n"; |
|
43
|
|
|
echo "Turnover 24 hours: {$tickerInfo->getTurnover24h()}\n"; |
|
44
|
|
|
echo "Volume 24 hours: {$tickerInfo->getVolume24h()}\n"; |
|
45
|
|
|
echo "Funding Rate: {$tickerInfo->getFundingRate()}\n"; |
|
46
|
|
|
echo "Next Funding Time: {$tickerInfo->getNextFundingTime()->format("Y-m-d H:i:s")}\n"; |
|
47
|
|
|
echo "Predicted Delivery Price: {$tickerInfo->getPredictedDeliveryPrice()}\n"; |
|
48
|
|
|
echo "Basis Rate: {$tickerInfo->getBasisRate()}\n"; |
|
49
|
|
|
echo "Delivery Fee Rate: {$tickerInfo->getDeliveryFeeRate()}\n"; |
|
50
|
|
|
echo "Open Interests Value: {$tickerInfo->getOpenInterestValue()}\n"; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
*Return code: 0 |
|
54
|
|
|
Return message: OK |
|
55
|
|
|
Symbol: BTCUSDT |
|
56
|
|
|
Bid Price: 59933.6 |
|
57
|
|
|
Ask Price: 59935.7 |
|
58
|
|
|
Last Price: 59938 |
|
59
|
|
|
Last Tick Direction: ZeroMinusTick |
|
60
|
|
|
Prev Price 24 hours: 58627.5 |
|
61
|
|
|
Prev Price 24 hours(%): 0.022352 |
|
62
|
|
|
High Price 24 hours: 63074.5 |
|
63
|
|
|
Low Price 24 hours: 58267.4 |
|
64
|
|
|
Prev price 1 hour: 59997 |
|
65
|
|
|
Mark Price: 59938 |
|
66
|
|
|
Index Price: 59957.26 |
|
67
|
|
|
Open Interest: 208384.158 |
|
68
|
|
|
Open Interest Value: 12490129662.2 |
|
69
|
|
|
Turnover 24 hours: 2907929540.5417 |
|
70
|
|
|
Volume 24 hours: 48504.964 |
|
71
|
|
|
Funding Rate: 8.407E-5 |
|
72
|
|
|
Next Funding Time: 2024-07-15 00:00:00 |
|
73
|
|
|
Predicted Delivery Price: 0 |
|
74
|
|
|
Basis Rate: 0 |
|
75
|
|
|
Delivery Fee Rate: 0 |
|
76
|
|
|
Open Interests Value: 12490129662.2 |
|
77
|
|
|
*/ |
|
78
|
|
|
|
|
79
|
|
|
$this->assertTrue(true); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.