Skip to content

Commit b854f33

Browse files
authored
v4.0.0rc2 Release (#103)
1 parent c0472bb commit b854f33

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 4.0.0rc2 - 2023-05-25
4+
5+
### Added
6+
- Implemented Modify Order (`PUT /fapi/v1/order`) - `modify_order` for UM Futures.
7+
38
## 4.0.0rc1 - 2023-05-18
49

510
### Changed

binance/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.0.0rc1"
1+
__version__ = "4.0.0rc2"

binance/um_futures/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(self, key=None, secret=None, **kwargs):
4141
from binance.um_futures.account import get_multi_asset_mode
4242
from binance.um_futures.account import new_order
4343
from binance.um_futures.account import new_order_test
44+
from binance.um_futures.account import modify_order
4445
from binance.um_futures.account import new_batch_order
4546
from binance.um_futures.account import query_order
4647
from binance.um_futures.account import cancel_order

binance/um_futures/account.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,68 @@ def new_order_test(self, symbol: str, side: str, type: str, **kwargs):
148148
return self.sign_request("POST", url_path, params)
149149

150150

151+
def modify_order(
152+
self,
153+
symbol: str,
154+
side: str,
155+
quantity: float,
156+
price: float,
157+
orderId: int = None,
158+
origClientOrderId: str = None,
159+
**kwargs
160+
):
161+
"""
162+
|
163+
| **Modify Order (TRADE)**
164+
| *Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue*
165+
166+
:API endpoint: ``PUT /fapi/v1/order``
167+
:API doc: https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
168+
169+
:parameter symbol: string
170+
:parameter side: string
171+
:parameter quantity: float
172+
:parameter price: float
173+
:parameter orderId: optional int
174+
:parameter origClientOrderId: optional string. Either orderId or origClientOrderId must be sent, and the orderId will prevail if both are sent.
175+
:parameter recvWindow: optional int
176+
|
177+
"""
178+
check_required_parameters(
179+
[
180+
[symbol, "symbol"],
181+
[side, "side"],
182+
[quantity, "quantity"],
183+
[price, "price"],
184+
]
185+
)
186+
if (orderId is None) and (origClientOrderId is None):
187+
check_required_parameters(
188+
[
189+
[orderId, "orderId"],
190+
]
191+
)
192+
elif orderId:
193+
params = {
194+
"symbol": symbol,
195+
"side": side,
196+
"quantity": quantity,
197+
"orderId": orderId,
198+
**kwargs,
199+
}
200+
else:
201+
params = {
202+
"symbol": symbol,
203+
"side": side,
204+
"quantity": quantity,
205+
"origClientOrderId": origClientOrderId,
206+
**kwargs,
207+
}
208+
209+
url_path = "/fapi/v1/order"
210+
return self.sign_request("PUT", url_path, params)
211+
212+
151213
def new_batch_order(self, batchOrders: list):
152214
"""
153215
|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
import logging
3+
from binance.um_futures import UMFutures
4+
from binance.lib.utils import config_logging
5+
from binance.error import ClientError
6+
7+
config_logging(logging, logging.DEBUG)
8+
9+
key = ""
10+
secret = ""
11+
12+
um_futures_client = UMFutures(key=key, secret=secret)
13+
14+
try:
15+
response = um_futures_client.modify_order(
16+
symbol="BTCUSDT", side="BUY", orderId=1123323, price=23000.00, quantity=0.01
17+
)
18+
logging.info(response)
19+
except ClientError as error:
20+
logging.error(
21+
"Found error. status: {}, error code: {}, error message: {}".format(
22+
error.status_code, error.error_code, error.error_message
23+
)
24+
)

0 commit comments

Comments
 (0)