Skip to content

Commit

Permalink
Merge pull request #1437 from frosty00/broker-codes-minor-edit
Browse files Browse the repository at this point in the history
add x- to broker prefix
  • Loading branch information
frosty00 authored Oct 21, 2024
2 parents d443a76 + 9832706 commit 2b31c7c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
26 changes: 13 additions & 13 deletions binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class BaseClient:
MINING_TO_FIAT = "MINING_C2C"

## order ids
SPOT_ORDER_PREFIX = "HNA2TXFJ"
CONTRACT_ORDER_PREFIX = "Cb7ytekJ"
SPOT_ORDER_PREFIX = "x-HNA2TXFJ"
CONTRACT_ORDER_PREFIX = "x-Cb7ytekJ"

def __init__(
self, api_key: Optional[str] = None, api_secret: Optional[str] = None,
Expand Down Expand Up @@ -2830,7 +2830,7 @@ def get_asset_details(self, **params):

def get_spot_delist_schedule(self, **params):
"""Get symbols delist schedule for spot
https://binance-docs.github.io/apidocs/spot/en/#get-symbols-delist-schedule-for-spot-market_data
:param recvWindow: optional - the number of milliseconds the request is valid for
Expand Down Expand Up @@ -3370,7 +3370,7 @@ def disable_isolated_margin_account(self, **params):

def get_enabled_isolated_margin_account_limit(self, **params):
"""Query enabled isolated margin account limit.
https://binance-docs.github.io/apidocs/spot/en/#query-enabled-isolated-margin-account-limit-user_data
:returns: API response
Expand Down Expand Up @@ -4027,7 +4027,7 @@ def get_isolated_margin_tier_data(self, **params):
:type recvWindow:
:returns: API response
.. code-block:: python
[
{
Expand All @@ -4049,7 +4049,7 @@ def margin_manual_liquidation(self, **params):
https://binance-docs.github.io/apidocs/spot/en/#margin-manual-liquidation-margin
:param type: required
:type symbol: str: When type selected is "ISOLATED", symbol must be filled in
Expand Down Expand Up @@ -7211,7 +7211,7 @@ def futures_api_trading_status(self, **params):
"""Get quantitative trading rules for order placement, such as Unfilled Ratio (UFR), Good-Til-Canceled Ratio (GCR),
Immediate-or-Cancel (IOC) & Fill-or-Kill (FOK) Expire Ratio (IFER), among others.
https://www.binance.com/en/support/faq/binance-futures-trading-quantitative-rules-4f462ebe6ff445d4a170be7d9e897272
https://binance-docs.github.io/apidocs/futures/en/#futures-trading-quantitative-rules-indicators-user_data
:param symbol: optional
Expand Down Expand Up @@ -7481,25 +7481,25 @@ def futures_countdown_cancel_all(self, **params):
"""Cancel all open orders of the specified symbol at the end of the specified countdown.
https://binance-docs.github.io/apidocs/futures/en/#auto-cancel-all-open-orders-trade
:param symbol: required
:type symbol: str
:param countdownTime: required
:type countdownTime: int
:param recvWindow: optional - the number of milliseconds the request is valid for
:type recvWindow: int
:returns: API response
.. code-block:: python
{
"symbol": "BTCUSDT",
"symbol": "BTCUSDT",
"countdownTime": "100000"
}
"""
return self._request_futures_api('post', 'countdownCancelAll', True, data=params)

def futures_account_balance(self, **params):
"""Get futures account balance
Expand Down Expand Up @@ -10754,7 +10754,7 @@ async def get_margin_capital_flow(self, **params):
async def get_margin_delist_schedule(self, **params):
return await self._request_margin_api('get', 'margin/delist-schedule', True, data=params)
get_margin_delist_schedule.__doc__ = Client.get_margin_delist_schedule.__doc__

async def get_margin_asset(self, **params):
return await self._request_margin_api('get', 'margin/asset', data=params)
get_margin_asset.__doc__ = Client.get_margin_asset.__doc__
Expand Down Expand Up @@ -12405,4 +12405,4 @@ async def papi_get_margin_repay_debt(self, **params):
:returns: API response
"""
return await self._request_papi_api('post', 'margin/repay-debt', signed=True, data=params)
return await self._request_papi_api('post', 'margin/repay-debt', signed=True, data=params)
20 changes: 10 additions & 10 deletions tests/test_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ def test_spot_id():
assert url_dict['side'] == 'BUY'
assert url_dict['type'] == 'MARKET'
assert url_dict['quantity'] == '0.1'
assert url_dict['newClientOrderId'].startswith('HNA2TXFJ')
assert url_dict['newClientOrderId'].startswith('x-HNA2TXFJ')

def test_spot_limit_id():
with requests_mock.mock() as m:
m.post("https://api.binance.com/api/v3/order", json={}, status_code=200)
client.order_limit_buy(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
url_dict = dict(pair.split('=') for pair in m.last_request.text.split('&'))
assert url_dict['newClientOrderId'].startswith('HNA2TXFJ')
assert url_dict['newClientOrderId'].startswith('x-HNA2TXFJ')

def test_spot_market_id():
with requests_mock.mock() as m:
m.post("https://api.binance.com/api/v3/order", json={}, status_code=200)
client.order_market_buy(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
url_dict = dict(pair.split('=') for pair in m.last_request.text.split('&'))
assert url_dict['newClientOrderId'].startswith('HNA2TXFJ')
assert url_dict['newClientOrderId'].startswith('x-HNA2TXFJ')

def test_swap_id():
with requests_mock.mock() as m:
Expand All @@ -41,7 +41,7 @@ def test_swap_id():
assert url_dict['side'] == 'buy'
assert url_dict['type'] == 'market'
assert url_dict['quantity'] == '0.1'
assert url_dict['newClientOrderId'.lower()].startswith('Cb7ytekJ'.lower())
assert url_dict['newClientOrderId'.lower()].startswith('x-Cb7ytekJ'.lower())


def test_papi_um_id():
Expand All @@ -54,7 +54,7 @@ def test_papi_um_id():
assert url_dict['side'] == 'BUY'
assert url_dict['type'] == 'MARKET'
assert url_dict['quantity'] == '0.1'
assert url_dict['newClientOrderId'].startswith('Cb7ytekJ')
assert url_dict['newClientOrderId'].startswith('x-Cb7ytekJ')


def test_papi_cm_id():
Expand All @@ -67,7 +67,7 @@ def test_papi_cm_id():
assert url_dict['side'] == 'BUY'
assert url_dict['type'] == 'MARKET'
assert url_dict['quantity'] == '0.1'
assert url_dict['newClientOrderId'].startswith('Cb7ytekJ')
assert url_dict['newClientOrderId'].startswith('x-Cb7ytekJ')


@pytest.mark.asyncio()
Expand All @@ -76,7 +76,7 @@ async def test_spot_id_async():
with aioresponses() as m:
def handler(url, **kwargs):
client_order_id = kwargs['data'][0][1]
assert client_order_id.startswith('HNA2TXFJ')
assert client_order_id.startswith('x-HNA2TXFJ')
m.post("https://api.binance.com/api/v3/order", payload={'id': 1}, status=200, callback=handler)
await clientAsync.create_order(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
await clientAsync.close_connection()
Expand All @@ -88,7 +88,7 @@ async def test_swap_id_async():
with aioresponses() as m:
def handler(url, **kwargs):
client_order_id = kwargs['data'][0][1]
assert client_order_id.startswith('Cb7ytekJ')
assert client_order_id.startswith('x-Cb7ytekJ')
m.post("https://fapi.binance.com/fapi/v1/order", payload={'id': 1}, status=200, callback=handler)
await clientAsync.futures_create_order(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
await clientAsync.close_connection()
Expand All @@ -99,7 +99,7 @@ async def test_papi_um_id_async():
with aioresponses() as m:
def handler(url, **kwargs):
client_order_id = kwargs['data'][0][1]
assert client_order_id.startswith('Cb7ytekJ')
assert client_order_id.startswith('x-Cb7ytekJ')
m.post("https://papi.binance.com/papi/v1/um/order", payload={'id': 1}, status=200, callback=handler)
await clientAsync.papi_create_um_order(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
await clientAsync.close_connection()
Expand All @@ -111,7 +111,7 @@ async def test_papi_cm_id_async():
with aioresponses() as m:
def handler(url, **kwargs):
client_order_id = kwargs['data'][0][1]
assert client_order_id.startswith('Cb7ytekJ')
assert client_order_id.startswith('x-Cb7ytekJ')
m.post("https://papi.binance.com/papi/v1/cm/order", payload={'id': 1}, status=200, callback=handler)
await clientAsync.papi_create_cm_order(symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
await clientAsync.close_connection()

0 comments on commit 2b31c7c

Please sign in to comment.