|
1
|
|
|
<?php |
|
2
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Tests; |
|
3
|
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\BybitAPI; |
|
5
|
|
|
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\MyPosition; |
|
6
|
|
|
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Request\MyPositionRequest; |
|
7
|
|
|
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Response\MyPositionResponse; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class MyPositionTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testSuccessPosition() |
|
13
|
|
|
{ |
|
14
|
|
|
$bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ'); |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
$positionsEndpointResponse = $bybit->privateEndpoint(MyPosition::class, (new MyPositionRequest())->setSymbol('BTCUSDT'))->execute(); |
|
17
|
|
|
|
|
18
|
|
|
echo "Return Code: {$positionsEndpointResponse->getReturnCode()}\n"; |
|
19
|
|
|
echo "Return Message: {$positionsEndpointResponse->getReturnMessage()}\n"; |
|
20
|
|
|
|
|
21
|
|
|
/** @var MyPositionResponse $positionsListInfoResponse */ |
|
22
|
|
|
$positionsListInfoResponse = $positionsEndpointResponse->getResult(); |
|
23
|
|
|
|
|
24
|
|
|
echo "Category: {$positionsListInfoResponse->getCategory()}\n"; |
|
25
|
|
|
echo "Next Page Cursor: {$positionsListInfoResponse->getNextPageCursor()}\n"; |
|
26
|
|
|
|
|
27
|
|
|
foreach ($positionsListInfoResponse->getPositionList() as $position) { |
|
28
|
|
|
echo "-----\n"; |
|
29
|
|
|
echo "Symbol: {$position->getSymbol()}\n"; |
|
30
|
|
|
echo "Side: {$position->getSide()}\n"; |
|
31
|
|
|
echo "Size: {$position->getSize()}\n"; |
|
32
|
|
|
echo "Entry Price: {$position->getEntryPrice()}\n"; |
|
33
|
|
|
echo "Leverage: {$position->getLeverage()}\n"; |
|
34
|
|
|
echo "Position Value: {$position->getPositionValue()}\n"; |
|
35
|
|
|
echo "Position Index: {$position->getPositionIdx()}\n"; |
|
36
|
|
|
echo "Risk ID: {$position->getRiskId()}\n"; |
|
37
|
|
|
echo "Risk Limit Value: {$position->getRiskLimitValue()}\n"; |
|
38
|
|
|
echo "Trade ModeL {$position->getTradeMode()}\n"; |
|
39
|
|
|
echo "Auto Add Margin: {$position->getAutoAddMargin()}\n"; |
|
40
|
|
|
echo "Position Balance: {$position->getPositionBalance()}\n"; |
|
41
|
|
|
echo "Liquidation Price: {$position->getLiqPrice()}\n"; |
|
42
|
|
|
echo "Bust Price: {$position->getBustPrice()}\n"; |
|
43
|
|
|
echo "TP/SL Mode: {$position->getTpSlMode()}\n"; |
|
44
|
|
|
echo "Take Profit: {$position->getTakeProfit()}\n"; |
|
45
|
|
|
echo "Stop-Loss: {$position->getStopLoss()}\n"; |
|
46
|
|
|
echo "Created time: {$position->getCreatedTime()->format('Y-m-d H:i:s')}\n"; |
|
47
|
|
|
echo "Update Time: {$position->getUpdatedTime()->format('Y-m-d H:i:s')}\n"; |
|
48
|
|
|
echo "Trailing Stop: {$position->getTrailingStop()}\n"; |
|
49
|
|
|
echo "Active Price: {$position->getActivePrice()}\n"; |
|
50
|
|
|
echo "Mark Price: {$position->getMarkPrice()}\n"; |
|
51
|
|
|
echo "Unrealised PnL: {$position->getUnrealisedPnl()}\n"; |
|
52
|
|
|
echo "Cumulative Realised PnL: {$position->getCumRealisedPnl()}\n"; |
|
53
|
|
|
echo "Maintenance Margin: {$position->getPositionMM()}\n"; |
|
54
|
|
|
echo "Initial Margin: {$position->getPositionIM()}\n"; |
|
55
|
|
|
echo "Position Status: {$position->getPositionStatus()}\n"; |
|
56
|
|
|
echo "Settlement Price: {$position->getSessionAvgPrice()}\n"; |
|
57
|
|
|
echo "Pre-occupancy Closing Fee: {$position->getOccClosingFee()}\n"; |
|
58
|
|
|
echo "Auto-deleverage Rank Indicator: {$position->getAdlRankIndicator()}\n"; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$this->assertTrue(true); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less 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.