Test Failed
Push — master ( 1fab6c...a74bfc )
by Vladislav
17:54 queued 15:22
created

TickerInfoTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
dl 0
loc 69
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRiskLimitEndpoint() 0 67 1
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())
0 ignored issues
show
Unused Code introduced by
The call to Carpenstar\ByBitAPI\BybitAPI::publicEndpoint() has too many arguments starting with new Carpenstar\ByBitAPI\...)->setSymbol('BTCUSDT'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $endpointResponse = $bybit->/** @scrutinizer ignore-call */ publicEndpoint(

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.

Loading history...
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();
0 ignored issues
show
Bug introduced by
The method getTickerInfo() does not exist on Carpenstar\ByBitAPI\Core\Objects\AbstractResponse. It seems like you code against a sub-type of Carpenstar\ByBitAPI\Core\Objects\AbstractResponse such as Carpenstar\ByBitAPI\Deri...onse\TickerInfoResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $tickerInfo = $endpointResponse->getResult()->/** @scrutinizer ignore-call */ getTickerInfo();
Loading history...
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