@@ -1968,6 +1968,44 @@ protected function createSpotOrderRequest(string $side, string $symbol, $quantit
1968
1968
return array_merge ($ request , $ params );
1969
1969
}
1970
1970
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
+
1971
2009
/**
1972
2010
* sorOrder creates an order using the SOR endpoint
1973
2011
*
0 commit comments