@@ -1968,6 +1968,44 @@ protected function createSpotOrderRequest(string $side, string $symbol, $quantit
19681968 return array_merge ($ request , $ params );
19691969 }
19701970
1971+ /**
1972+ * editOrder - edits a quantity of an existing order
1973+ *
1974+ * @link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#order-amend-keep-priority-trade
1975+ * @link https://developers.binance.com/docs/binance-spot-api-docs/faqs/order_amend_keep_priority
1976+ *
1977+ * @param string $symbol (mandatory) market symbol
1978+ * @param string $quantity (mandatory) new quantity (must be greater than 0 and less than the original order quantity)
1979+ * @param string $orderId (optional) order id to be amended (mandatory if origClientOrderId is not set)
1980+ * @param string $origClientOrderId (optional) original client order id to be amended (mandatory if orderId is not set)
1981+ * @param array $params (optional) additional transaction options
1982+ * - @param string $params['newClientOrderId'] - custom client order id
1983+ *
1984+ * @return array containing the response
1985+ * @throws \Exception
1986+ */
1987+ public function editOrder (string $ symbol , $ quantity , ?string $ orderId = null , ?string $ origClientOrderId = null , array $ params = [])
1988+ {
1989+ $ request = [
1990+ "symbol " => $ symbol ,
1991+ "newQty " => $ quantity ,
1992+ ];
1993+
1994+ if (!is_null ($ orderId )) {
1995+ $ request ['orderId ' ] = $ orderId ;
1996+ } else if (is_null ($ origClientOrderId )) {
1997+ throw new \Exception ('editOrder(): Either orderId or origClientOrderId must be set ' );
1998+ } else {
1999+ $ request ['origClientOrderId ' ] = $ origClientOrderId ;
2000+ }
2001+ if (isset ($ params ['newClientOrderId ' ])) {
2002+ $ request ['newClientOrderId ' ] = $ params ['newClientOrderId ' ];
2003+ } else {
2004+ $ request ['newClientOrderId ' ] = $ this ->generateSpotClientOrderId ();
2005+ }
2006+ return $ this ->apiRequest ("v3/order/amend/keepPriority " , "PUT " , array_merge ($ request , $ params ), true );
2007+ }
2008+
19712009 /**
19722010 * sorOrder creates an order using the SOR endpoint
19732011 *
0 commit comments