Skip to content

Commit

Permalink
[Tests] add test_cancel_uncancellable_order
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Jan 8, 2025
1 parent 663fd88 commit d32178e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class AbstractAuthenticatedExchangeTester:
bool, # trigger above (on higher price than order price)
)
] = {} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, trading_enums.TraderOrderType] = None
ORDER_SIZE = 10 # % of portfolio to include in test orders
PORTFOLIO_TYPE_FOR_SIZE = trading_constants.CONFIG_PORTFOLIO_FREE
CONVERTS_ORDER_SIZE_BEFORE_PUSHING_TO_EXCHANGES = False
Expand Down Expand Up @@ -384,6 +386,7 @@ async def inner_test_get_special_orders(self):

async def test_create_and_cancel_limit_orders(self):
async with self.local_exchange_manager():
await self.inner_test_cancel_uncancellable_order()
await self.inner_test_create_and_cancel_limit_orders()

async def inner_test_create_and_cancel_limit_orders(self, symbol=None, settlement_currency=None, margin_type=None):
Expand Down Expand Up @@ -451,6 +454,12 @@ async def inner_test_create_and_cancel_limit_orders(self, symbol=None, settlemen
assert await self.order_not_in_open_orders(open_orders, buy_limit, symbol=symbol)
assert await self.order_in_cancelled_orders(cancelled_orders, buy_limit, symbol=symbol)

async def inner_test_cancel_uncancellable_order(self):
if self.UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE:
order_id, symbol, order_type = self.UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE
with pytest.raises(trading_errors.ExchangeOrderCancelError):
await self.exchange_manager.exchange.cancel_order(order_id, symbol, order_type)

async def test_create_and_fill_market_orders(self):
async with self.local_exchange_manager():
await self.inner_test_create_and_fill_market_orders()
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class TestBinanceAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.STOP_LOSS.value, octobot_trading.enums.TradeOrderSide.SELL.value, False
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"6799798838", "BNB/USDT", octobot_trading.enums.TraderOrderType.BUY_LIMIT.value
)


async def test_get_portfolio(self):
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_binance_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class TestBinanceFuturesAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.STOP_LOSS.value, octobot_trading.enums.TradeOrderSide.SELL.value, False
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"4076521927", "BTC/USDT:USDT", octobot_trading.enums.TraderOrderType.BUY_LIMIT.value
)

async def _set_account_types(self, account_types):
# todo remove this and use both types when exchange-side multi portfolio is enabled
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_bingx.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class TestBingxAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.UNSUPPORTED.value, octobot_trading.enums.TradeOrderSide.SELL.value, None
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"1877004292053696512", "TAO/USDT", octobot_trading.enums.TraderOrderType.SELL_LIMIT.value
)

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_coinbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class TestCoinbaseAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.LIMIT.value, octobot_trading.enums.TradeOrderSide.BUY.value, False
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"f4016e50-1f0b-4caa-abe5-1ec00af18be9", "ETH/BTC", octobot_trading.enums.TraderOrderType.BUY_LIMIT.value
)

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_kucoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class TestKucoinAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.STOP_LOSS.value, octobot_trading.enums.TradeOrderSide.BUY.value, True
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"vs93gpruc69s00cs003tat0g", "BTC/USDT", octobot_trading.enums.TraderOrderType.BUY_LIMIT.value
)

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_kucoin_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TestKucoinFuturesAuthenticatedExchange(
octobot_trading.enums.TradeOrderType.STOP_LOSS.value, octobot_trading.enums.TradeOrderSide.SELL.value, False
),
} # stop loss / take profit and other special order types to be successfully parsed
# details of an order that exists but can"t be cancelled
UNCANCELLABLE_ORDER_ID_SYMBOL_TYPE: tuple[str, str, octobot_trading.enums.TraderOrderType] = (
"266424798085668865", "ETH/USDT:USDT", octobot_trading.enums.TraderOrderType.BUY_LIMIT.value
)

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand Down

0 comments on commit d32178e

Please sign in to comment.