@@ -1862,18 +1862,31 @@ public function get_headers_from_curl_response(string $header)
18621862 * You can call this function directly or use the helper functions
18631863 *
18641864 * @link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints
1865+ * @link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#sor
18651866 *
18661867 * @see buy()
18671868 * @see sell()
18681869 * @see marketBuy()
18691870 * @see marketSell() $this->httpRequest( "https://api.binance.com/api/v1/ticker/24hr");
18701871 *
1871- * @param $side string typically "BUY" or "SELL"
1872- * @param $symbol string to buy or sell
1873- * @param $quantity string in the order
1874- * @param $price string for the order
1875- * @param $type string is determined by the symbol bu typicall LIMIT, STOP_LOSS_LIMIT etc.
1876- * @param $params array additional transaction options
1872+ * @param string $side (mandatory) typically "BUY" or "SELL"
1873+ * @param string $symbol (mandatory) to buy or sell
1874+ * @param string $quantity (mandatory) in the order
1875+ * @param string $price (optional) for the order
1876+ * @param string $type (optional) is determined by the symbol bu typicall LIMIT, STOP_LOSS_LIMIT etc. (default is LIMIT)
1877+ * @param array $params (optional) additional transaction options
1878+ * - @param string $params['timeInForce'] - GTC, IOC, FOK
1879+ * - @param bool $params['isQuoteOrder'] - if true, quantity is in the quote asset (not for sor orders)
1880+ * - @param string $params['newClientOrderId'] - custom client order id
1881+ * - @param string $params['strategyId']
1882+ * - @param int $params['strategyType']
1883+ * - @param string $params['stopPrice'] - stop price for STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders (not for SOR orders)
1884+ * - @param string $params['trailingDelta'] - for STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders (not for SOR orders)
1885+ * - @param string $params['icebergQty'] - used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order
1886+ * - @param string $params['newOrderRespType'] - set the response type of the order (ACK, RESULT, FULL)
1887+ * - @param string $params['selfTradePreventionMode'] - NONE, EXPIRE_MAKER, EXPIRE_TAKER, EXPIRE_BOTH or DECREMENT (default is NONE)
1888+ * - @param bool $params['sor'] - if true, order will be sent to SOR endpoint
1889+ * - @param bool $params
18771890 * @param $test bool whether to test or not, test only validates the query
18781891 * @return array containing the response
18791892 * @throws \Exception
@@ -1933,9 +1946,48 @@ public function order(string $side, string $symbol, $quantity, $price, string $t
19331946 } else {
19341947 $ request ['newClientOrderId ' ] = $ this ->generateSpotClientOrderId ();
19351948 }
1949+ $ sor = false ;
1950+ if (isset ($ params ['sor ' ])) {
1951+ $ sor = $ params ['sor ' ];
1952+ unset($ params ['sor ' ]);
1953+ }
1954+ $ url = $ sor ? "v3/sor/order " : "v3/order " ;
1955+ if ($ test ) {
1956+ $ url = $ url . "/test " ;
1957+ }
1958+ return $ this ->apiRequest ($ url , "POST " , array_merge ($ request , $ params ), true );
1959+ }
19361960
1937- $ qstring = ($ test === false ) ? "v3/order " : "v3/order/test " ;
1938- return $ this ->apiRequest ($ qstring , "POST " , array_merge ($ request , $ params ), true );
1961+ /**
1962+ * sorOrder creates an order using the SOR endpoint
1963+ *
1964+ * @link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#sor
1965+ * @link https://developers.binance.com/docs/binance-spot-api-docs/faqs/sor_faq
1966+ *
1967+ * @param string $side (mandatory) typically "BUY" or "SELL"
1968+ * @param string $symbol (mandatory) to buy or sell
1969+ * @param string $quantity (mandatory) in the order
1970+ * @param string $price (optional) for the order
1971+ * @param string $type (optional) is determined by the symbol bu typicall LIMIT, STOP_LOSS_LIMIT etc. (default is LIMIT)
1972+ * @param array $params (optional) additional transaction options
1973+ * - @param string $params['timeInForce'] - GTC, IOC, FOK
1974+ * - @param string $params['newClientOrderId'] - custom client order id
1975+ * - @param string $params['strategyId']
1976+ * - @param int $params['strategyType']
1977+ * - @param string $params['icebergQty'] - used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order
1978+ * - @param string $params['newOrderRespType'] - set the response type of the order (ACK, RESULT, FULL)
1979+ * - @param string $params['selfTradePreventionMode'] - NONE, EXPIRE_MAKER, EXPIRE_TAKER, EXPIRE_BOTH or DECREMENT (default is NONE)
1980+ * - @param bool $params['sor'] - if true, order will be sent to SOR endpoint
1981+ * - @param bool $params
1982+ * @param $test bool whether to test or not, test only validates the query
1983+ *
1984+ * @return array containing the response
1985+ * @throws \Exception
1986+ */
1987+ public function sorOrder (string $ side , string $ symbol , $ quantity , $ price , string $ type = "LIMIT " , array $ params = [], bool $ test = false )
1988+ {
1989+ $ params ['sor ' ] = true ;
1990+ return $ this ->order ($ side , $ symbol , $ quantity , $ price , $ type , $ params , $ test );
19391991 }
19401992
19411993 /**
0 commit comments