Skip to content

Commit

Permalink
v4.0.0rc2 Release (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonte-z committed May 26, 2023
1 parent c0472bb commit b854f33
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.0rc2 - 2023-05-25

### Added
- Implemented Modify Order (`PUT /fapi/v1/order`) - `modify_order` for UM Futures.

## 4.0.0rc1 - 2023-05-18

### Changed
Expand Down
2 changes: 1 addition & 1 deletion binance/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.0.0rc1"
__version__ = "4.0.0rc2"
1 change: 1 addition & 0 deletions binance/um_futures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, key=None, secret=None, **kwargs):
from binance.um_futures.account import get_multi_asset_mode
from binance.um_futures.account import new_order
from binance.um_futures.account import new_order_test
from binance.um_futures.account import modify_order
from binance.um_futures.account import new_batch_order
from binance.um_futures.account import query_order
from binance.um_futures.account import cancel_order
Expand Down
62 changes: 62 additions & 0 deletions binance/um_futures/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,68 @@ def new_order_test(self, symbol: str, side: str, type: str, **kwargs):
return self.sign_request("POST", url_path, params)


def modify_order(
self,
symbol: str,
side: str,
quantity: float,
price: float,
orderId: int = None,
origClientOrderId: str = None,
**kwargs
):
"""
|
| **Modify Order (TRADE)**
| *Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue*
:API endpoint: ``PUT /fapi/v1/order``
:API doc: https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
:parameter symbol: string
:parameter side: string
:parameter quantity: float
:parameter price: float
:parameter orderId: optional int
:parameter origClientOrderId: optional string. Either orderId or origClientOrderId must be sent, and the orderId will prevail if both are sent.
:parameter recvWindow: optional int
|
"""
check_required_parameters(
[
[symbol, "symbol"],
[side, "side"],
[quantity, "quantity"],
[price, "price"],
]
)
if (orderId is None) and (origClientOrderId is None):
check_required_parameters(
[
[orderId, "orderId"],
]
)
elif orderId:
params = {
"symbol": symbol,
"side": side,
"quantity": quantity,
"orderId": orderId,
**kwargs,
}
else:
params = {
"symbol": symbol,
"side": side,
"quantity": quantity,
"origClientOrderId": origClientOrderId,
**kwargs,
}

url_path = "/fapi/v1/order"
return self.sign_request("PUT", url_path, params)


def new_batch_order(self, batchOrders: list):
"""
|
Expand Down
24 changes: 24 additions & 0 deletions examples/um_futures/trade/modify_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import logging
from binance.um_futures import UMFutures
from binance.lib.utils import config_logging
from binance.error import ClientError

config_logging(logging, logging.DEBUG)

key = ""
secret = ""

um_futures_client = UMFutures(key=key, secret=secret)

try:
response = um_futures_client.modify_order(
symbol="BTCUSDT", side="BUY", orderId=1123323, price=23000.00, quantity=0.01
)
logging.info(response)
except ClientError as error:
logging.error(
"Found error. status: {}, error code: {}, error message: {}".format(
error.status_code, error.error_code, error.error_message
)
)

0 comments on commit b854f33

Please sign in to comment.