Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(binance) - cancelOrders implementation (contract only) #19108

Merged
merged 6 commits into from
Sep 25, 2023

Conversation

samgermain
Copy link
Member

@samgermain samgermain commented Sep 6, 2023

% binance cancelOrders '["28946490144", "28946547126"]' SOL/USDT:USDT
2023-09-18T18:36:48.896Z
Node.js: v18.15.0
CCXT v4.0.83
binance.cancelOrders (28946490144,28946547126, SOL/USDT:USDT)
2023-09-18T18:36:54.269Z iteration 0 passed in 479 ms

         id |                    clientOrderId |     timestamp |                 datetime | lastTradeTimestamp | lastUpdateTimestamp |        symbol |  type | timeInForce | postOnly | reduceOnly | side | price | triggerPrice | amount | cost | average | filled | remaining |   status | fee | trades | fees | stopPrice | takeProfitPrice | stopLossPrice
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
28946490144 | x-xcKtGhcu0d8e0654a67b47b4bdc556 | 1695062214277 | 2023-09-18T18:36:54.277Z |                    |       1695062214277 | SOL/USDT:USDT | limit |         GTC |    false |      false |  buy |    17 |              |      1 |    0 |         |      0 |         1 | canceled |  {} |     [] | [{}] |           |                 |              
28946547126 | x-xcKtGhcu6ac4f27dea1a4390b6d985 | 1695062214277 | 2023-09-18T18:36:54.277Z |                    |       1695062214277 | SOL/USDT:USDT | limit |         GTC |    false |      false |  buy |    16 |              |      1 |    0 |         |      0 |         1 | canceled |  {} |     [] | [{}] |           |                 |              
2 objects
2023-09-18T18:36:54.269Z iteration 1 passed in 479 ms
2023-09-18T18:53:56.730Z
Node.js: v18.15.0
CCXT v4.0.83
binancecoinm.cancelOrders (8613510178,8613510652, ADA/USD:ADA)
2023-09-18T18:54:02.068Z iteration 0 passed in 632 ms

        id |            clientOrderId |     timestamp |                 datetime | lastTradeTimestamp | lastUpdateTimestamp |      symbol |  type | timeInForce | postOnly | reduceOnly | side | price | triggerPrice | amount | cost | average | filled | remaining |   status | fee | trades | fees | stopPrice | takeProfitPrice | stopLossPrice
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8613510178 | ios_SWh6oju1C2zolVK8HUPf | 1695063241967 | 2023-09-18T18:54:01.967Z |                    |       1695063241967 | ADA/USD:ADA | limit |         GTC |    false |      false |  buy |  0.22 |              |      5 |    0 |         |      0 |         5 | canceled |  {} |     [] | [{}] |           |                 |              
8613510652 | ios_mqM1lgxItqM3NPD43NZt | 1695063241967 | 2023-09-18T18:54:01.967Z |                    |       1695063241967 | ADA/USD:ADA | limit |         GTC |    false |      false |  buy |  0.23 |              |      3 |    0 |         |      0 |         3 | canceled |  {} |     [] | [{}] |           |                 |              
2 objects
2023-09-18T18:54:02.068Z iteration 1 passed in 632 ms
% py binancecoinm cancelOrders '["8613512457", "8613512369"]' ADA/USD:ADA
Python v3.11.3
CCXT v4.0.83
binancecoinm.cancelOrders(['8613512457', '8613512369'],ADA/USD:ADA)
[{'amount': 3.0,
  'average': None,
  'clientOrderId': 'ios_gfqLSBnGRowk5X413E5C',
  'cost': 0.0,
  'datetime': '2023-09-18T18:57:20.839Z',
  'fee': {'cost': None, 'currency': None, 'rate': None},
  'fees': [{'cost': None, 'currency': None, 'rate': None}],
  'filled': 0.0,
  'id': '8613512457',
  'info': {'avgPrice': '0.00000',
           'clientOrderId': 'ios_gfqLSBnGRowk5X413E5C',
           'closePosition': False,
           'cumBase': '0',
           'cumQty': '0',
           'executedQty': '0',
           'orderId': '8613512457',
           'origQty': '3',
           'origType': 'LIMIT',
           'pair': 'ADAUSD',
           'positionSide': 'BOTH',
           'price': '0.23000',
           'priceProtect': False,
           'reduceOnly': False,
           'side': 'BUY',
           'status': 'CANCELED',
           'stopPrice': '0',
           'symbol': 'ADAUSD_PERP',
           'timeInForce': 'GTC',
           'type': 'LIMIT',
           'updateTime': '1695063440839',
           'workingType': 'CONTRACT_PRICE'},
  'lastTradeTimestamp': None,
  'lastUpdateTimestamp': 1695063440839,
  'postOnly': False,
  'price': 0.23,
  'reduceOnly': False,
  'remaining': 3.0,
  'side': 'buy',
  'status': 'canceled',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'ADA/USD:ADA',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1695063440839,
  'trades': [],
  'triggerPrice': None,
  'type': 'limit'},
 {'amount': 5.0,
  'average': None,
  'clientOrderId': 'ios_clOSTrAIlxvRZIeMWya8',
  'cost': 0.0,
  'datetime': '2023-09-18T18:57:20.839Z',
  'fee': {'cost': None, 'currency': None, 'rate': None},
  'fees': [{'cost': None, 'currency': None, 'rate': None}],
  'filled': 0.0,
  'id': '8613512369',
  'info': {'avgPrice': '0.00000',
           'clientOrderId': 'ios_clOSTrAIlxvRZIeMWya8',
           'closePosition': False,
           'cumBase': '0',
           'cumQty': '0',
           'executedQty': '0',
           'orderId': '8613512369',
           'origQty': '5',
           'origType': 'LIMIT',
           'pair': 'ADAUSD',
           'positionSide': 'BOTH',
           'price': '0.22000',
           'priceProtect': False,
           'reduceOnly': False,
           'side': 'BUY',
           'status': 'CANCELED',
           'stopPrice': '0',
           'symbol': 'ADAUSD_PERP',
           'timeInForce': 'GTC',
           'type': 'LIMIT',
           'updateTime': '1695063440839',
           'workingType': 'CONTRACT_PRICE'},
  'lastTradeTimestamp': None,
  'lastUpdateTimestamp': 1695063440839,
  'postOnly': False,
  'price': 0.22,
  'reduceOnly': False,
  'remaining': 5.0,
  'side': 'buy',
  'status': 'canceled',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'ADA/USD:ADA',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1695063440839,
  'trades': [],
  'triggerPrice': None,
  'type': 'limit'}]

@samgermain samgermain marked this pull request as ready for review September 18, 2023 19:01
@samgermain samgermain changed the title binance.cancelOrders feat(binance) - cancelOrders implementation (contract only) Sep 18, 2023
ts/src/binance.ts Outdated Show resolved Hide resolved
@carlosmiei
Copy link
Collaborator

LGTM

p binanceusdm cancelOrders '["640609445"]' "LTC/USDT:USDT" --sandbox          
Python v3.11.5
CCXT v4.0.83
binanceusdm.cancelOrders(['640609445'],LTC/USDT:USDT)
[{'amount': 0.2,
  'average': None,
  'clientOrderId': 'x-xcKtGhcu3667c96ef6d5559fece022',
  'cost': 0.0,
  'datetime': '2023-09-25T11:00:31.863Z',
  'fee': {'cost': None, 'currency': None, 'rate': None},
  'fees': [{'cost': None, 'currency': None, 'rate': None}],
  'filled': 0.0,
  'id': '640609445',
  'info': {'avgPrice': '0.00',
           'clientOrderId': 'x-xcKtGhcu3667c96ef6d5559fece022',
           'closePosition': False,
           'cumQty': '0.000',
           'cumQuote': '0.00000',
           'executedQty': '0.000',
           'goodTillDate': '0',
           'orderId': '640609445',
           'origQty': '0.200',
           'origType': 'LIMIT',
           'positionSide': 'BOTH',
           'price': '50.00',
           'priceMatch': 'NONE',
           'priceProtect': False,
           'reduceOnly': False,
           'selfTradePreventionMode': 'NONE',
           'side': 'BUY',
           'status': 'CANCELED',
           'stopPrice': '0.00',
           'symbol': 'LTCUSDT',
           'timeInForce': 'GTC',
           'type': 'LIMIT',
           'updateTime': '1695639631863',
           'workingType': 'CONTRACT_PRICE'},
  'lastTradeTimestamp': None,
  'lastUpdateTimestamp': 1695639631863,
  'postOnly': False,
  'price': 50.0,
  'reduceOnly': False,
  'remaining': 0.2,
  'side': 'buy',
  'status': 'canceled',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'LTC/USDT:USDT',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1695639631863,
  'trades': [],
  'triggerPrice': None,
  'type': 'limit'}]
 p binanceusdm cancelOrders '["640609445423423432"]' "LTC/USDT:USDT" --sandbox          
Python v3.11.5
CCXT v4.0.83
binanceusdm.cancelOrders(['640609445423423432'],LTC/USDT:USDT)
Traceback (most recent call last):
  File "/Users/cjg/Git/ccxt10/ccxt/examples/py/cli.py", line 239, in <module>
    asyncio.run(main())
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/cjg/Git/ccxt10/ccxt/examples/py/cli.py", line 216, in main
    result = await method(*args)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/binance.py", line 4663, in cancel_orders
    response = await self.fapiPrivateDeleteBatchOrders(self.extend(request, params))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/binance.py", line 7707, in request
    response = await self.fetch2(path, api, method, params, headers, body, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/base/exchange.py", line 1836, in fetch2
    return await self.fetch(request['url'], request['method'], request['headers'], request['body'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/base/exchange.py", line 221, in fetch
    self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/binance.py", line 7687, in handle_errors
    self.throw_exactly_matched_exception(self.exceptions['exact'], error, self.id + ' ' + body)
  File "/Users/cjg/Git/ccxt10/ccxt/python/ccxt/async_support/base/exchange.py", line 2202, in throw_exactly_matched_exception
    raise exact[string](message)
ccxt.base.errors.OrderNotFound: binanceusdm [{"code":-2011,"msg":"Unknown order sent."}]

@carlosmiei carlosmiei self-assigned this Sep 25, 2023
@kroitor kroitor merged commit bbb119a into ccxt:master Sep 25, 2023
1 of 2 checks passed
kroitor pushed a commit that referenced this pull request Sep 25, 2023
feat(binance) - cancelOrders implementation (contract only)

[ci skip]
@samgermain samgermain deleted the binance-cancel-orders branch September 26, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants