diff --git a/php-binance-api.php b/php-binance-api.php index d3d5c02c..d154d3c4 100755 --- a/php-binance-api.php +++ b/php-binance-api.php @@ -692,9 +692,6 @@ public function exchangeInfo($symbols = null) { if (!$this->exchangeInfo) { $arr = array(); - $arr['symbols'] = array(); - $parameters = []; - if ($symbols) { if (gettype($symbols) == "string") { $parameters["symbol"] = $symbols; @@ -706,7 +703,11 @@ public function exchangeInfo($symbols = null) } else { $arr = $this->httpRequest("v3/exchangeInfo"); } - + if ((is_array($arr) === false) || empty($arr)) { + echo "Error: unable to fetch spot exchange info" . PHP_EOL; + $arr = array(); + $arr['symbols'] = array(); + } $this->exchangeInfo = $arr; $this->exchangeInfo['symbols'] = null; @@ -921,13 +922,16 @@ public function depositAddress(string $asset, $network = null) $return = $this->httpRequest("v1/capital/deposit/address", "GET", $params, true); // Adding for backwards compatibility with wapi - $return['asset'] = $return['coin']; - $return['addressTag'] = $return['tag']; - - if (!empty($return['address'])) { - $return['success'] = 1; + if (is_array($return) && !empty($return)) { + $return['asset'] = $return['coin']; + $return['addressTag'] = $return['tag']; + if (!empty($return['address'])) { + $return['success'] = 1; + } else { + $return['success'] = 0; + } } else { - $return['success'] = 0; + echo "Error: no deposit address found" . PHP_EOL; } return $return; @@ -955,8 +959,12 @@ public function depositHistory(string $asset = null, array $params = []) $return = $this->httpRequest("v1/capital/deposit/hisrec", "GET", $params, true); // Adding for backwards compatibility with wapi - foreach ($return as $key=>$item) { - $return[$key]['asset'] = $item['coin']; + if (is_array($return) && !empty($return)) { + foreach ($return as $key=>$item) { + $return[$key]['asset'] = $item['coin']; + } + } else { + echo "Error: no deposit history found" . PHP_EOL; } return $return; @@ -1091,7 +1099,7 @@ public function transfer(string $type, string $asset, string $amount, $fromSymbo * * @property int $weight 1 * - * @param string $type (optional) type of transfer, e.g. MAIN_MARGIN (@see transfer()) + * @param string $type (mandatory) type of transfer, e.g. MAIN_MARGIN (@see transfer()) * @param string $startTime (optional) start time in milliseconds * @param string $endTime (optional) end time in milliseconds * @param int $limit (optional) the number of records to return (default 10, max 100) @@ -1158,7 +1166,10 @@ public function prices() public function price(string $symbol) { $ticker = $this->httpRequest("v3/ticker/price", "GET", ["symbol" => $symbol]); - + if (!isset($ticker['price'])) { + echo "Error: unable to fetch price for $symbol" . PHP_EOL; + return null; + } return $ticker['price']; } @@ -1283,6 +1294,14 @@ public function depth(string $symbol, int $limit = 100) "symbol" => $symbol, "limit" => $limit, ]); + if (is_array($json) === false) { + echo "Error: unable to fetch depth" . PHP_EOL; + $json = []; + } + if (empty($json)) { + echo "Error: depth were empty" . PHP_EOL; + return $json; + } if (isset($this->info[$symbol]) === false) { $this->info[$symbol] = []; } @@ -3112,7 +3131,7 @@ public function accountSnapshot($type, $nbrDays = 5, $startTime = 0, $endTime = if ($startTime > 0) $params['startTime'] = $startTime; if ($endTime > 0) - $params['endTime'] = $startTime; + $params['endTime'] = $endTime; if ($nbrDays != 5) $params['limit'] = $nbrDays; @@ -3249,6 +3268,14 @@ public function ocoOrder(string $side, string $symbol, $quantity, $price, $stopp public function avgPrice(string $symbol) { $ticker = $this->httpRequest("v3/avgPrice", "GET", ["symbol" => $symbol]); + if (is_array($ticker) === false) { + echo "Error: unable to fetch avg price" . PHP_EOL; + $ticker = []; + } + if (empty($ticker)) { + echo "Error: avg price was empty" . PHP_EOL; + return null; + } return $ticker['price']; } @@ -3320,11 +3347,12 @@ public function futuresTime() public function futuresExchangeInfo() { if (!$this->futuresExchangeInfo) { - $arr = array(); - $arr['symbols'] = array(); - $arr = $this->httpRequest("v1/exchangeInfo", "GET", [ 'fapi' => true ]); - + if ((is_array($arr) === false) || empty($arr)) { + echo "Error: unable to fetch futures exchange info" . PHP_EOL; + $arr = array(); + $arr['symbols'] = array(); + } $this->futuresExchangeInfo = $arr; $this->futuresExchangeInfo['symbols'] = null; @@ -3369,6 +3397,14 @@ public function futuresDepth(string $symbol, int $limit = null) $params['limit'] = $limit; } $json = $this->httpRequest("v1/depth", "GET", $params); + if (is_array($json) === false) { + echo "Error: unable to fetch futures depth" . PHP_EOL; + $json = []; + } + if (empty($json)) { + echo "Error: futures depth were empty" . PHP_EOL; + return $json; + } if (isset($this->info[$symbol]) === false) { $this->info[$symbol] = []; $this->info[$symbol]['futures'] = []; @@ -3588,12 +3624,12 @@ public function futuresMarkPriceCandlesticks(string $symbol, string $interval = } /** - * futuresPremiumIndexKlines get the candles for the given intervals + * futuresPremiumIndexCandlesticks get the candles for the given intervals * 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M * * @link https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Premium-Index-Kline-Data * - * $candles = $api->futuresPremiumIndexKlines("ETHBTC", "5m"); + * $candles = $api->futuresPremiumIndexCandlesticks("ETHBTC", "5m"); * * @property int $weight 5 * for limit < 100 - weight 1 @@ -3610,7 +3646,7 @@ public function futuresMarkPriceCandlesticks(string $symbol, string $interval = * @return array containing the response * @throws \Exception */ - public function futuresPremiumIndexKlines(string $symbol, string $interval = '5m', int $limit = null, $startTime = null, $endTime = null) + public function futuresPremiumIndexCandlesticks(string $symbol, string $interval = '5m', int $limit = null, $startTime = null, $endTime = null) { return $this->futuresCandlesticksHelper($symbol, $interval, $limit, $startTime, $endTime, 'premiumIndexKlines'); } @@ -3627,11 +3663,11 @@ private function futuresCandlesticksHelper($symbol, $interval, $limit, $startTim if (!isset($this->charts['futures'][$symbol])) { $this->charts['futures'][$symbol] = []; } - if (!isset($this->charts['futures'][$symbol][$type])) { - $this->charts['futures'][$symbol][$type] = []; + if (!isset($this->charts['futures'][$symbol][$contractType])) { + $this->charts['futures'][$symbol][$contractType] = []; } - if (!isset($this->charts['futures'][$symbol][$type][$interval])) { - $this->charts['futures'][$symbol][$type][$interval] = []; + if (!isset($this->charts['futures'][$symbol][$contractType][$interval])) { + $this->charts['futures'][$symbol][$contractType][$interval] = []; } $params = [ 'interval' => $interval, @@ -3800,6 +3836,10 @@ public function futuresPrice(string $symbol) 'fapi' => true, ]; $ticker = $this->httpRequest("v1/ticker/price", "GET", $parameters); + if (!isset($ticker['price'])) { + echo "Error: unable to fetch futures price for $symbol" . PHP_EOL; + return null; + } return $ticker['price']; } @@ -3844,6 +3884,10 @@ public function futuresPriceV2(string $symbol) 'fapi' => true, ]; $ticker = $this->httpRequest("v2/ticker/price", "GET", $parameters); + if (!isset($ticker['price'])) { + echo "Error: unable to fetch futures price for $symbol" . PHP_EOL; + return null; + } return $ticker['price']; } @@ -3943,7 +3987,7 @@ public function futuresOpenInterest(string $symbol): array * symbolPeriodLimitStartEndRequest * helper for routing GET methods that require symbol, period, limit, startTime and endTime */ - private function symbolPeriodLimitStartEndContractTypeRequest($symbol, $period, $limit, $startTime, $endTime, $url, $base = 'fapi', $contractType = null) + private function symbolPeriodLimitStartEndRequest($symbol, $period, $limit, $startTime, $endTime, $url, $base = 'fapi', $contractType = null) { $parameters = [ 'symbol' => $symbol, @@ -4477,7 +4521,7 @@ public function futuresSellTest(string $symbol, $quantity = null, $price = null, * @return array containing the request * @throws \Exception */ - protected function createBatchOrdersRequest(array $orders) + protected function createBatchOrdersRequest(array $orders, bool $edit = false) { $formatedOrders = []; for ($index = 0; $index < count($orders); $index++) { @@ -4491,6 +4535,9 @@ protected function createBatchOrdersRequest(array $orders) if (!isset($order['flags'])) { $order['flags'] = []; } + if (!isset($order['type'])) { + $order['type'] = 'LIMIT'; + } $formatedOrder = $this->createFuturesOrderRequest( $order['side'], $order['symbol'], @@ -4503,11 +4550,15 @@ protected function createBatchOrdersRequest(array $orders) // remove recvWindow from the order unset($formatedOrder['recvWindow']); } - if (isset($order['orderId'])) { - $formatedOrder['orderId'] = $order['orderId']; - } - if (isset($order['origClientOrderId'])) { - $formatedOrder['origClientOrderId'] = $order['origClientOrderId']; + if ($edit) { + if (isset($order['orderId'])) { + $formatedOrder['orderId'] = $order['orderId']; + } + if (isset($order['origClientOrderId'])) { + $formatedOrder['origClientOrderId'] = $order['origClientOrderId']; + } + unset($formatedOrder['type']); + unset($formatedOrder['newClientOrderId']); } $formatedOrders[$index] = $formatedOrder; } @@ -4580,6 +4631,7 @@ public function futuresEditOrder(string $symbol, string $side, string $quantity, $opt['orderId'] = $orderId; } unset($opt['type']); + unset($opt['newClientOrderId']); $opt['fapi'] = true; return $this->httpRequest("v1/order", 'PUT', $opt, true); } @@ -4601,14 +4653,13 @@ public function futuresEditOrders(array $orders, $recvWindow = null) $params = [ 'fapi' => true, ]; - $formatedOrders = $this->createBatchOrdersRequest($orders); + $formatedOrders = $this->createBatchOrdersRequest($orders, true); if ($recvWindow) { $params['recvWindow'] = $recvWindow; } // current endpoint accepts orders list as a json string in the query string - $encodedOrders = json_encode($formatedOrders); - $url = 'v1/batchOrders?batchOrders=' . $encodedOrders; - return $this->httpRequest($url, 'PUT', $params, true); + $params['batchOrders'] = json_encode($formatedOrders); + return $this->httpRequest("v1/batchOrders", 'PUT', $params, true); } /** @@ -4710,8 +4761,8 @@ public function futuresCancelBatchOrders(string $symbol, $orderIdList = null, $o // remove quotes and spaces $params['orderIdList'] = str_replace(' ', '', str_replace('"', '', str_replace("'", '', $idsString))); } else if ($origClientOrderIdList) { - // remove spaces - $params['origClientOrderIdList'] = str_replace(' ', '', json_encode($origClientOrderIdList)); + // remove spaces between the ids + $params['origClientOrderIdList'] = str_replace(', ', ',', json_encode($origClientOrderIdList)); } else { throw new \Exception('futuresCancelBatchOrders: either orderIdList or origClientOrderIdList must be set'); } @@ -6054,7 +6105,7 @@ public function convertAccept(string $quoteId, int $recvWindow = null, array $pa $request = [ 'quoteId' => $quoteId, ]; - return $this->fapiRequest("v1/cconvert/acceptQuote", 'POST', array_merge($request, $params), true, $recvWindow); + return $this->fapiRequest("v1/convert/acceptQuote", 'POST', array_merge($request, $params), true, $recvWindow); } /** @@ -6098,4 +6149,4 @@ public function convertStatus($orderId = null, $quoteId = null) } return $this->httpRequest("v1/convert/orderStatus", 'GET', $params, true); } -} \ No newline at end of file +} diff --git a/tests/BinanceStaticTests.php b/tests/BinanceStaticTests.php index b44c1ea9..bdacdba5 100644 --- a/tests/BinanceStaticTests.php +++ b/tests/BinanceStaticTests.php @@ -4,7 +4,6 @@ require_once __DIR__ . '/../php-binance-api.php'; // Adjust path if needed - class MockBinanceAPI extends Binance\API { public function curl_exec($handler) @@ -32,9 +31,67 @@ class BinanceStaticTests extends TestCase private $SPOT_ORDER_PREFIX = "x-HNA2TXFJ"; private $CONTRACT_ORDER_PREFIX = "x-Cb7ytekJ"; + // Default values for the tests + private $symbol = 'ETHUSDT'; + private $quantity = '1.234'; + private $price = '1000'; + private $stopprice = '1100'; + private $stoplimitprice = '900'; + private $type = 'LIMIT'; + private $orderid = '000'; + private $orderId = '1234567890'; + private $limit = 2; + private $fromOrderId = 1; + private $fromTradeId = 2; + private $startTime = 1; + private $endTime = 6; + private $symbols = ['ETHUSDT','BTCUSDT']; + private $asset = 'USDT'; + private $assets = ['IOST','AAVE','CHZ']; + private $address = '0x1234567890abcdef1234567890abcdef12345678'; + private $amount = 10.1; + private $addressTag = '123456'; + private $addressName = 'MyAddress'; + private $transactionFeeFlag = true; + private $network = 'TESTNetwork'; + private $fromSymbol = 'USDT'; + private $toSymbol = 'BNB'; + private $recvWindow = 1000; + private $current = 2; + private $tradeId = 3; + private $side = 'BUY'; + private $test = false; + private $interval = '15m'; + private $nbrDays = 6; + private $baseAsset = 'ETH'; + private $quoteAsset = 'USDT'; + private $quoteQty = 10.3; + private $fromId = 1; + private $contractType = 'CURRENT_QUARTER'; + private $period = '15m'; + private $origClientOrderId = 'test client order id'; + private $orderIdList = ['123456', '654321']; + private $origClientOrderIdList = ['test client order id 1', 'test client order id 2']; + private $countdownTime = 100; + private $autoCloseType = 'LIQUIDATION'; + private $marginType = 'CROSSED'; + private $dualSidePosition = true; + private $leverage = 10; + private $multiAssetsMarginMode = true; + private $positionSide = 'SHORT'; + private $incomeType = 'COMMISSION_REBATE'; + private $page = 3; + private $downloadId = 'testDownloadId'; + private $fromAsset = 'USDT'; + private $toAsset = 'BNB'; + private $fromAmount = '100'; + private $validTime = '10s'; + private $quoteId = 'testQuoteId'; + public function setUp(): void { $this->binance = new MockBinanceAPI('api_key', 'api_secret'); } + public function testPricesSpot() { try { @@ -66,24 +123,2767 @@ public function testSpotOrder() $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); } - public function testFuturesOrder() + public function testSpotBuy() { try { - $this->binance->futuresOrder('BUY', 'BTCUSDT', 1, 1000); - } catch(\Throwable $e) { + $this->binance->buy($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { } - $this->assertEquals("https://fapi.binance.com/fapi/v1/order", self::$capturedUrl); + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); parse_str(self::$capturedBody, $params); - print_r($params); - $this->assertEquals("BTCUSDT", $params['symbol']); - $this->assertEquals("BUY", $params['side']); - $this->assertEquals("LIMIT", $params['type']); - $this->assertEquals(1, $params['quantity']); - $this->assertEquals(1000, $params['price']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); $this->assertEquals("GTC", $params['timeInForce']); - $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotBuyTest() + { + try { + $this->binance->buyTest($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotSell() + { + try { + $this->binance->sell($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotSellTest() + { + try { + $this->binance->sellTest($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketQuoteBuy() + { + try { + $this->binance->marketQuoteBuy($this->symbol, $this->quantity); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quoteOrderQty']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketQuoteBuyTest() + { + try { + $this->binance->marketQuoteBuyTest($this->symbol, $this->quantity); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quoteOrderQty']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketBuy() + { + try { + $this->binance->marketBuy($this->symbol, $this->quantity); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketBuyTest() + { + try { + $this->binance->marketBuyTest($this->symbol, $this->quantity); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketQuoteSell() + { + try { + $this->binance->marketQuoteSell($this->symbol, '1'); + + } catch (\Throwable $e) { + + } + // warns here cuz method needs information fetched by exchangeInfo + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals('SELL', $params['side']); + $this->assertEquals('MARKET', $params['type']); + $this->assertEquals(1, $params['quoteOrderQty']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketQuoteSellTest() + { + try { + $this->binance->marketQuoteSellTest($this->symbol, 1); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals(1, $params['quoteOrderQty']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketSell() + { + try { + $this->binance->marketSell($this->symbol, 1); + + } catch (\Throwable $e) { + + } + // warns here cuz method needs information fetched by exchangeInfo + $this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals(1, $params['quantity']); + $this->assertEquals('SELL', $params['side']); + $this->assertEquals('MARKET', $params['type']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotMarketSellTest() + { + try { + $this->binance->marketSellTest($this->symbol, $this->quantity); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/test", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX)); + } + + public function testSpotCancel() + { + try { + $this->binance->cancel($this->symbol, $this->orderid); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderid, $params['orderId']); + + } + + public function testSpotOrderStatus() + { + try { + $this->binance->orderStatus($this->symbol, $this->orderid); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderid, $params['orderId']); + + } + + public function testSpotOpenOrders() + { + try { + $this->binance->openOrders($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/openOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testSpotCancelOpenOrders() + { + try { + $this->binance->cancelOpenOrders($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/openOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testSpotOrders() + { + try { + $this->binance->orders($this->symbol, $this->limit, $this->fromOrderId); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/allOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->fromOrderId, $params['orderId']); + + } + + public function testSpotHistory() + { + try { + $this->binance->history($this->symbol, $this->limit, $this->fromTradeId, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/myTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->fromTradeId, $params['fromId']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testSpotMyTrades() + { + try { + $this->binance->myTrades($this->symbol, $this->limit, $this->fromTradeId, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/myTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->fromTradeId, $params['fromId']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testUseServerTime() + { + try { + $this->binance->useServerTime(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/time", self::$capturedUrl); + } + + public function testTime() + { + try { + $this->binance->time(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/time", self::$capturedUrl); + } + + public function testSpotExchangeInfo() + { + try { + $this->binance->exchangeInfo($this->symbols); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/exchangeInfo?"; + $this->assertTrue(str_starts_with (self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + $this->assertTrue(!empty($params['symbols'])); + $symbols = $params['symbols']; + $this->assertTrue(str_contains($symbols, $this->symbols[0])); + $this->assertTrue(str_contains($symbols, $this->symbols[1])); + } + + public function testAssetDetail() + { + try { + $this->binance->assetDetail($this->asset); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/asset/assetDetail?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->asset, $params['asset']); + + } + + public function testSpotDustLog() + { + try { + $this->binance->dustLog($this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/asset/dribblet?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testSpotTradeFee() + { + try { + $this->binance->tradeFee($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/asset/tradeFee?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testSpotCommissionFee() + { + try { + $this->binance->commissionFee($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/asset/tradeFee?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testWithdraw() + { + try { + $this->binance->withdraw($this->asset, $this->address, $this->amount, $this->addressTag, $this->addressName, $this->transactionFeeFlag, $this->network, $this->orderId); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/sapi/v1/capital/withdraw/apply", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->asset, $params['coin']); + $this->assertEquals($this->address, $params['address']); + $this->assertEquals($this->amount, $params['amount']); + $this->assertEquals($this->addressTag, $params['addressTag']); + $this->assertEquals($this->addressName, $params['name']); + $this->assertEquals($this->transactionFeeFlag, $params['transactionFeeFlag']); + $this->assertEquals($this->network, $params['network']); + $this->assertEquals($this->orderId, $params['withdrawOrderId']); + } + + public function testDepositAddress() + { + try { + $this->binance->depositAddress($this->asset, $this->network); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/capital/deposit/address?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->asset, $params['coin']); + $this->assertEquals($this->network, $params['network']); + } + + public function testDepositHistory() + { + try { + $this->binance->depositHistory($this->asset); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/capital/deposit/hisrec?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->asset, $params['coin']); + } + + public function testWithdrawHistory() + { + try { + $this->binance->withdrawHistory($this->asset); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/capital/withdraw/history?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->asset, $params['coin']); + + } + + public function testWithdrawFee() + { + try { + $this->binance->withdrawFee($this->asset); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/asset/assetDetail"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + } + + public function testTransfer() + { + try { + $this->binance->transfer($this->type, $this->asset, $this->amount, $this->fromSymbol, $this->toSymbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v1/asset/transfer", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->type, $params['type']); + $this->assertEquals($this->asset, $params['asset']); + $this->assertEquals($this->amount, $params['amount']); + $this->assertEquals($this->fromSymbol, $params['fromSymbol']); + $this->assertEquals($this->toSymbol, $params['toSymbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testTransfersHistory() + { + try { + $this->binance->transfersHistory($this->type, $this->startTime, $this->endTime, $this->limit, $this->current, $this->fromSymbol, $this->toSymbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v1/asset/transfer?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->type, $params['type']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['size']); + $this->assertEquals($this->current, $params['current']); + $this->assertEquals($this->fromSymbol, $params['fromSymbol']); + $this->assertEquals($this->toSymbol, $params['toSymbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testSpotPrices() + { + try { + $this->binance->prices(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/ticker/price", self::$capturedUrl); + } + + public function testSpotPrice() + { + try { + $this->binance->price($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/ticker/price?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + } + + public function testSpotBookPrices() + { + try { + $this->binance->bookPrices(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/ticker/bookTicker", self::$capturedUrl); + } + + public function testSpotAccount() + { + try { + $this->binance->account(); + + } catch (\Throwable $e) { + + } + $this->assertTrue(str_starts_with(self::$capturedUrl, "https://api.binance.com/api/v3/account")); + } + + public function testSpotPrevDay() + { + try { + $this->binance->prevDay($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v1/ticker/24hr?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testSotAggTrades() + { + try { + $this->binance->aggTrades($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v1/aggTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testSpotHistoricalTrades() + { + try { + $this->binance->historicalTrades($this->symbol, $this->limit); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/trades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + + } + + public function testSpotHistoricalTradesWithTradeId() + { + try { + $this->binance->historicalTrades($this->symbol, $this->limit, $this->tradeId); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/historicalTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->tradeId, $params['fromId']); + + } + + public function testSpotDepth() + { + try { + $this->binance->depth($this->symbol, $this->limit); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v1/depth?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + } + + public function testSpotBalances() + { + try { + $this->binance->balances(); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/account"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + parse_str(self::$capturedBody, $params); + } + + public function testFuturesBalances() + { + try { + $this->binance->balances('futures', $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v2/balance?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesBalancesV3() + { + try { + $this->binance->balances('futures', $this->recvWindow, 'v3'); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/balance?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testCoins() + { + try { + $this->binance->coins(); + + } catch (\Throwable $e) { + + } + $this->assertTrue(str_starts_with(self::$capturedUrl, "https://api.binance.com/sapi/v1/capital/config/getall")); + } + + public function testSpotCandlesticks() + { + try { + $this->binance->candlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v1/klines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testSpotAccountSnapshot() + { + try { + $this->binance->accountSnapshot('SPOT', $this->nbrDays, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/accountSnapshot?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals('SPOT', $params['type']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->nbrDays, $params['limit']); + + } + + public function testMarginAccountSnapshot() + { + try { + $this->binance->accountSnapshot('MARGIN', $this->nbrDays, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/accountSnapshot?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals('MARGIN', $params['type']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->nbrDays, $params['limit']); + + } + + public function testFuturesAccountSnapshot() + { + try { + $this->binance->accountSnapshot('FUTURES', $this->nbrDays, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/accountSnapshot?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals('FUTURES', $params['type']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->nbrDays, $params['limit']); + + } + + public function testAccountStatus() + { + try { + $this->binance->accountStatus(); + + } catch (\Throwable $e) { + + } + $this->assertTrue(str_starts_with(self::$capturedUrl, "https://api.binance.com/sapi/v1/account/status")); + } + + public function testApiRestrictions() + { + try { + $this->binance->apiRestrictions(); + + } catch (\Throwable $e) { + + } + $this->assertTrue(str_starts_with(self::$capturedUrl, "https://api.binance.com/sapi/v1/account/apiRestrictions")); + } + + public function testApiTradingStatus() + { + try { + $this->binance->apiTradingStatus(); + + } catch (\Throwable $e) { + + } + $this->assertTrue(str_starts_with(self::$capturedUrl, "https://api.binance.com/sapi/v1/account/apiTradingStatus")); + } + + public function testOcoOrder() + { + try { + $this->binance->ocoOrder($this->side, $this->symbol, $this->quantity, $this->price, $this->stopprice, $this->stoplimitprice); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://api.binance.com/api/v3/order/oco", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->side, $params['side']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->stopprice, $params['stopPrice']); + $this->assertEquals($this->stoplimitprice, $params['stopLimitPrice']); + $this->assertEquals('GTC', $params['stopLimitTimeInForce']); + } + + public function testSpotAvgPrice() + { + try { + $this->binance->avgPrice($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/api/v3/avgPrice?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + } + + public function testBswapQuote() + { + try { + $this->binance->bswapQuote($this->baseAsset, $this->quoteAsset, $this->quoteQty); + + } catch (\Throwable $e) { + + } + $endpoint = "https://api.binance.com/sapi/v1/bswap/quote?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->quoteAsset, $params['quoteAsset']); + $this->assertEquals($this->baseAsset, $params['baseAsset']); + $this->assertEquals($this->quoteQty, $params['quoteQty']); + + } + + public function testFuturesTime() + { + try { + $this->binance->futuresTime(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/time", self::$capturedUrl); + } + + public function testFuturesExchangeInfo() + { + try { + $this->binance->futuresExchangeInfo(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/exchangeInfo", self::$capturedUrl); + } + + public function testFuturesDepth() + { + try { + $this->binance->futuresDepth($this->symbol, $this->limit); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/depth?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + } + + public function testFuturesRecentTrades() + { + try { + $this->binance->futuresRecentTrades($this->symbol, $this->limit); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/trades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + + } + + public function testFuturesHistoricalTrades() + { + try { + $this->binance->futuresHistoricalTrades($this->symbol, $this->limit, $this->tradeId); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/historicalTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->tradeId, $params['fromId']); + + } + + public function testFuturesAggTrades() + { + try { + $this->binance->futuresAggTrades($this->symbol, $this->fromId, $this->startTime, $this->endTime, $this->limit); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/aggTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->fromId, $params['fromId']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + + } + + public function testFuturesCandlesticks() + { + try { + $this->binance->futuresCandlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/klines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesContinuousCandlesticks() + { + try { + $this->binance->futuresContinuousCandlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime, $this->contractType); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/continuousKlines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->symbol, $params['pair']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->contractType, $params['contractType']); + + } + + public function testFuturesIndexPriceCandlesticks() + { + try { + $this->binance->futuresIndexPriceCandlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/indexPriceKlines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->symbol, $params['pair']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesMarkPriceCandlesticks() + { + try { + $this->binance->futuresMarkPriceCandlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/markPriceKlines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesPremiumIndexCandlesticks() + { + try { + $this->binance->futuresPremiumIndexCandlesticks($this->symbol, $this->interval, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/premiumIndexKlines?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->interval, $params['interval']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + } + + public function testFuturesMarkPrice() + { + try { + $this->binance->futuresMarkPrice($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/premiumIndex?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesFundingRateHistory() + { + try { + $this->binance->futuresFundingRateHistory($this->symbol, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/fundingRate?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesFundingInfo() + { + try { + $this->binance->futuresFundingInfo(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/fundingInfo", self::$capturedUrl); + } + + public function testFuturesPrevDay() + { + try { + $this->binance->futuresPrevDay($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/ticker/24hr?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesPrice() + { + try { + $this->binance->futuresPrice($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/ticker/price?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesPrices() + { + try { + $this->binance->futuresPrices(); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/ticker/price", self::$capturedUrl); + } + + public function testFuturesPriceV2() + { + try { + $this->binance->futuresPriceV2($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v2/ticker/price?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + } + + public function testFuturesSymbolOrderBookTicker() + { + try { + $this->binance->futuresSymbolOrderBookTicker($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/ticker/bookTicker?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesDeliveryPrice() + { + try { + $this->binance->futuresDeliveryPrice($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/delivery-price?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['pair']); + + } + + public function testFuturesOpenInterest() + { + try { + $this->binance->futuresOpenInterest($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/openInterest?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesOpenInterestHistory() + { + try { + $this->binance->futuresOpenInterestHistory($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/openInterestHist?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesTopLongShortPositionRatio() + { + try { + $this->binance->futuresTopLongShortPositionRatio($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/topLongShortPositionRatio?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesTopLongShortAccountRatio() + { + try { + $this->binance->futuresTopLongShortAccountRatio($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/topLongShortAccountRatio?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesGlobalLongShortAccountRatio() + { + try { + $this->binance->futuresGlobalLongShortAccountRatio($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/globalLongShortAccountRatio?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesTakerLongShortRatio() + { + try { + $this->binance->futuresTakerLongShortRatio($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/takerlongshortRatio?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesBasis() + { + try { + $this->binance->futuresBasis($this->symbol, $this->period, $this->limit, $this->startTime, $this->endTime, $this->contractType); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/futures/data/basis?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['pair']); + $this->assertEquals($this->period, $params['period']); + $this->assertEquals($this->contractType, $params['contractType']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + + } + + public function testFuturesIndexInfo() + { + try { + $this->binance->futuresIndexInfo($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/indexInfo?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesAssetIndex() + { + try { + $this->binance->futuresAssetIndex($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/assetIndex?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesConstituents() + { + try { + $this->binance->futuresConstituents($this->symbol); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/indexInfo?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + + } + + public function testFuturesOrder() + { + try { + $this->binance->futuresOrder('BUY', 'BTCUSDT', 1, 1000); + } catch(\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/order", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals("BTCUSDT", $params['symbol']); + $this->assertEquals("BUY", $params['side']); + $this->assertEquals("LIMIT", $params['type']); + $this->assertEquals(1, $params['quantity']); + $this->assertEquals(1000, $params['price']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + } + + public function testFuturesBuy() + { + try { + $this->binance->futuresBuy($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + + $endpoint = "https://fapi.binance.com/fapi/v1/order"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("BUY", $params['side']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + } + + public function testFuturesBuyTest() + { + try { + $this->binance->futuresBuyTest($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + + $endpoint = "https://fapi.binance.com/fapi/v1/order/test"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("BUY", $params['side']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + } + + public function testFuturesSell() + { + try { + $this->binance->futuresSell($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + + $endpoint = "https://fapi.binance.com/fapi/v1/order"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("SELL", $params['side']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + } + + public function testFuturesSellTest() + { + try { + $this->binance->futuresSellTest($this->symbol, $this->quantity, $this->price, $this->type); + + } catch (\Throwable $e) { + + } + + $endpoint = "https://fapi.binance.com/fapi/v1/order/test"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->type, $params['type']); + $this->assertEquals("SELL", $params['side']); + $this->assertEquals("GTC", $params['timeInForce']); + $this->assertTrue(str_starts_with($params['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + } + + public function testFuturesBatchOrders() + { + $order = [ + 'symbol' => $this->symbol, + 'side' => $this->side, + 'quantity' => $this->quantity, + 'price' => $this->price, + 'type' => $this->type, + ]; + + try { + $this->binance->futuresBatchOrders([ $order ], $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?batchOrders="; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $ordersString = substr(self::$capturedUrl, strlen($endpoint)); + + $orders = json_decode(urldecode($ordersString), true); + $this->assertEquals($this->symbol, $orders[0]['symbol']); + $this->assertEquals($this->side, $orders[0]['side']); + $this->assertEquals($this->quantity, $orders[0]['quantity']); + $this->assertEquals($this->price, $orders[0]['price']); + $this->assertEquals($this->type, $orders[0]['type']); + $this->assertEquals("GTC", $orders[0]['timeInForce']); + $this->assertTrue(str_starts_with($orders[0]['newClientOrderId'], $this->CONTRACT_ORDER_PREFIX)); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesEditOrder() + { + try { + $this->binance->futuresEditOrder($this->symbol, $this->side, $this->quantity, $this->price, $this->orderId); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $orderString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($orderString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->side, $params['side']); + $this->assertEquals($this->quantity, $params['quantity']); + $this->assertEquals($this->price, $params['price']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals('GTC', $params['timeInForce']); + } + + public function testFuturesEditOrders() + { + $order = [ + 'symbol' => $this->symbol, + 'side' => $this->side, + 'quantity' => $this->quantity, + 'price' => $this->price, + 'orderId' => $this->orderId, + ]; + + try { + $this->binance->futuresEditOrders([ $order ], $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + $orders = json_decode($params['batchOrders'], true); + $this->assertEquals($this->symbol, $orders[0]['symbol']); + $this->assertEquals($this->side, $orders[0]['side']); + $this->assertEquals($this->quantity, $orders[0]['quantity']); + $this->assertEquals($this->price, $orders[0]['price']); + $this->assertEquals("GTC", $orders[0]['timeInForce']); + } + + public function testFuturesOrderAmendment() + { + try { + $this->binance->futuresOrderAmendment($this->symbol, $this->orderId, $this->origClientOrderId, $this->startTime, $this->endTime, $this->limit, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/orderAmendment?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->origClientOrderId, $params['origClientOrderId']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesCancel() + { + try { + $this->binance->futuresCancel($this->symbol, $this->orderid); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderid, $params['orderId']); + + } + + public function testFuturesCancelBatchOrdersByOrderIds() + { + try { + $this->binance->futuresCancelBatchOrders($this->symbol, $this->orderIdList, null, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals('[123456,654321]', $params['orderIdList']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesCancelBatchOrdersByClientOrderIds() + { + try { + $this->binance->futuresCancelBatchOrders($this->symbol, null, $this->origClientOrderIdList, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals('["test client order id 1","test client order id 2"]', $params['origClientOrderIdList']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesCancelOpenOrders() + { + try { + $this->binance->futuresCancelOpenOrders($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/allOpenOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesCountdownCancelAllOrders() + { + try { + $this->binance->futuresCountdownCancelAllOrders($this->symbol, $this->countdownTime, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/countdownCancelAll", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->countdownTime, $params['countdownTime']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesOrderStatusByOrderId() + { + try { + $this->binance->futuresOrderStatus($this->symbol, $this->orderId, null, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesOrderStatusByClientOrderId() + { + try { + $this->binance->futuresOrderStatus($this->symbol, null, $this->origClientOrderId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->origClientOrderId, $params['origClientOrderId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesAllOrders() + { + try { + $this->binance->futuresAllOrders($this->symbol, $this->startTime, $this->endTime, $this->limit, $this->orderId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/allOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesOpenOrders() + { + try { + $this->binance->futuresOpenOrders($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/openOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesOpenOrderByOrderId() + { + try { + $this->binance->futuresOpenOrder($this->symbol, $this->orderId, null, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/openOrder?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesOpenOrderByClientOrderId() + { + try { + $this->binance->futuresOpenOrder($this->symbol, null, $this->origClientOrderId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/openOrder?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->origClientOrderId, $params['origClientOrderId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesForceOrders() + { + try { + $this->binance->futuresForceOrders($this->symbol, $this->startTime, $this->endTime, $this->limit, $this->autoCloseType, $this->recvWindow); + + } catch (\Throwable $e) { + + } + + $endpoint = "https://fapi.binance.com/fapi/v1/forceOrders?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->autoCloseType, $params['autoCloseType']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesMyTrades() + { + try { + $this->binance->futuresMyTrades($this->symbol, $this->startTime, $this->endTime, $this->limit, $this->orderId, $this->fromId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/userTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->fromId, $params['fromId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesHistory() + { + try { + $this->binance->futuresHistory($this->symbol, $this->startTime, $this->endTime, $this->limit, $this->orderId, $this->fromId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/userTrades?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->orderId, $params['orderId']); + $this->assertEquals($this->fromId, $params['fromId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesSetMarginMode() + { + try { + $this->binance->futuresSetMarginMode($this->symbol, $this->marginType, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/marginType", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->marginType, $params['marginType']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionMode() + { + try { + $this->binance->futuresPositionMode($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/positionSide/dual?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesSetPositionMode() + { + try { + $this->binance->futuresSetPositionMode($this->dualSidePosition, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/positionSide/dual", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->dualSidePosition, $params['dualSidePosition']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesSetLeverage() + { + try { + $this->binance->futuresSetLeverage($this->leverage, $this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/leverage", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->leverage, $params['leverage']); + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesMultiAssetsMarginMode() + { + try { + $this->binance->futuresMultiAssetsMarginMode($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/multiAssetsMargin?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + + } + + public function testFuturesSetMultiAssetsMarginMode() + { + try { + $this->binance->futuresSetMultiAssetsMarginMode($this->multiAssetsMarginMode, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/multiAssetsMarginMode", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->multiAssetsMarginMode, $params['multiAssetsMarginMode']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAddMargin() + { + try { + $this->binance->futuresAddMargin($this->symbol, $this->amount, $this->positionSide, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/positionMargin"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->amount, $params['amount']); + $this->assertEquals($this->positionSide, $params['positionSide']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + $this->assertEquals(1, $params['type']); + } + + public function testFuturesReduceMargin() + { + try { + $this->binance->futuresReduceMargin($this->symbol, $this->amount, $this->positionSide, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/positionMargin"; + $this->assertEquals($endpoint, self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->amount, $params['amount']); + $this->assertEquals($this->positionSide, $params['positionSide']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + $this->assertEquals(2, $params['type']); + } + + public function testFuturesPositions() + { + try { + $this->binance->futuresPositions($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionsV2() + { + try { + $this->binance->futuresPositionsV2($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v2/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionsV3() + { + try { + $this->binance->futuresPositionsV3($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPosition() + { + try { + $this->binance->futuresPosition($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionV2() + { + try { + $this->binance->futuresPositionV2($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v2/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionV3() + { + try { + $this->binance->futuresPositionV3($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/positionRisk?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAdlQuantile() + { + try { + $this->binance->futuresAdlQuantile($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/adlQuantile?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesPositionMarginChangeHistory() + { + try { + $this->binance->futuresPositionMarginChangeHistory($this->symbol, $this->startTime, $this->endTime, $this->limit, 'ADD', $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/positionMargin/history?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals(1, $params['addOrReduce']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAccount() + { + try { + $this->binance->futuresAccount($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/account?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAccountV2() + { + try { + $this->binance->futuresAccountV2($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v2/account?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAccountV3() + { + try { + $this->binance->futuresAccountV3($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v3/account?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesTradeFee() + { + try { + $this->binance->futuresTradeFee($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/commissionRate?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesAccountConfig() + { + try { + $this->binance->futuresAccountConfig($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/accountConfig?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesMarginModes() + { + try { + $this->binance->futuresMarginModes($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/symbolConfig?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesOrderRateLimit() + { + try { + $this->binance->futuresOrderRateLimit($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/rateLimit/order?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesLeverages() + { + try { + $this->binance->futuresLeverages($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/leverageBracket?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesLedger() + { + try { + $this->binance->futuresLedger($this->symbol, $this->incomeType, $this->startTime, $this->endTime, $this->limit, $this->page, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/income?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->incomeType, $params['incomeType']); + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->limit, $params['limit']); + $this->assertEquals($this->page, $params['page']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesTradingStatus() + { + try { + $this->binance->futuresTradingStatus($this->symbol, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/apiTradingStatus?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->symbol, $params['symbol']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadIdForTransactions() + { + try { + $this->binance->futuresDownloadIdForTransactions($this->startTime, $this->endTime, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/income/asyn?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadTransactionsByDownloadId() + { + try { + $this->binance->futuresDownloadTransactionsByDownloadId($this->downloadId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/income/asyn/id?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->downloadId, $params['downloadId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadIdForOrders() + { + try { + $this->binance->futuresDownloadIdForOrders($this->startTime, $this->endTime, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order/asyn?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadOrdersByDownloadId() + { + try { + $this->binance->futuresDownloadOrdersByDownloadId($this->downloadId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/order/asyn/id?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->downloadId, $params['downloadId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadIdForTrades() + { + try { + $this->binance->futuresDownloadIdForTrades($this->startTime, $this->endTime, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/trade/asyn?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->startTime, $params['startTime']); + $this->assertEquals($this->endTime, $params['endTime']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesDownloadTradesByDownloadId() + { + try { + $this->binance->futuresDownloadTradesByDownloadId($this->downloadId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/trade/asyn/id?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->downloadId, $params['downloadId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesFeeBurn() + { + try { + $this->binance->futuresFeeBurn(true, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/feeBurn", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals('true', $params['feeBurn']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testFuturesFeeBurnStatus() + { + try { + $this->binance->futuresFeeBurnStatus($this->recvWindow); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/feeBurn?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testConvertExchangeInfo() + { + try { + $this->binance->convertExchangeInfo($this->fromAsset, $this->toAsset); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/convert/exchangeInfo?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->fromAsset, $params['fromAsset']); + $this->assertEquals($this->toAsset, $params['toAsset']); + } + + public function testConvertSend() + { + try { + $this->binance->convertSend($this->fromAsset, $this->toAsset, $this->fromAmount, null, $this->validTime, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/convert/getQuote", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->fromAsset, $params['fromAsset']); + $this->assertEquals($this->toAsset, $params['toAsset']); + $this->assertEquals($this->fromAmount, $params['fromAmount']); + $this->assertEquals($this->validTime, $params['validTime']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testConvertAccept() + { + try { + $this->binance->convertAccept($this->quoteId, $this->recvWindow); + + } catch (\Throwable $e) { + + } + $this->assertEquals("https://fapi.binance.com/fapi/v1/convert/acceptQuote", self::$capturedUrl); + + parse_str(self::$capturedBody, $params); + + $this->assertEquals($this->quoteId, $params['quoteId']); + $this->assertEquals($this->recvWindow, $params['recvWindow']); + } + + public function testConvertStatusByOrderId() + { + try { + $this->binance->convertStatus($this->orderId, null); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/convert/orderStatus?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->orderId, $params['orderId']); + } + + public function testConvertStatusByQuoteId() + { + try { + $this->binance->convertStatus(null, $this->quoteId); + + } catch (\Throwable $e) { + + } + $endpoint = "https://fapi.binance.com/fapi/v1/convert/orderStatus?"; + $this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint)); + + $queryString = substr(self::$capturedUrl, strlen($endpoint)); + parse_str($queryString, $params); + + $this->assertEquals($this->quoteId, $params['quoteId']); } }