async def cancel(self, order: Order) -> typing.CancelledOrder: success, response = await self.get( '/market/cancel', uuid=order.id_on_exchange, tbs=['apikey', 'uuid'], ) return typing.CancelledOrder( success=success and bool(response['success']), response=str(response), )
async def cancel(self, order: Order) -> typing.CancelledOrder: success, response = await self.post( '/order/cancel', api_key=self.key, order_id=int(order.id_on_exchange), ) is_cancelled = success and bool(response.get('is_cancelled', False)) return typing.CancelledOrder( success=is_cancelled, response=str(response), )
async def cancel(self, order: Order) -> typing.CancelledOrder: if order.is_closed: message = 'Can not cancel closed order.' self.logger.warning(f'{message}\n{order}\n') return typing.CancelledOrder(response=message) if not order.id_on_exchange: raise ValueError(f'Order doesn\'t have exchange ID. {order}') result = await self.session.cancel(order) if result.success: self.logger.info( f'Order cancelled. Order: {order}. Response: {result.response}' ) else: # exchange can refuse order cancelling by it's inner reasons. # For example order can be partially executed. # That's why "INFO" is good log level. self.logger.info(f'Can not cancel order {order}.' f' Exchange\'s response: {result.response}.') return result
async def cancel(self, order: Order) -> typing.CancelledOrder: success, response = await self.rest_call(f'/order/{order.id_on_exchange}', method='delete') return typing.CancelledOrder(success=success, response=str(response))
async def cancel(self, order: Order) -> typing.CancelledOrder: return typing.CancelledOrder( success=self.is_success, response='ok', )