mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Invalid orders should be removed from pending_orders (#126)
* Invalid orders should be removed from pending_orders * If an EXCHANGE_FILL_OR_KILL order is unfilled and cancelled, confirm_order_new will not get called. This can leave lots of pending orders remaining in the order_manager. However, confirm_order_closed will get called, and therefore we should delete pending orders from that method as well. * updated CHANGELOG
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
1.1.12
|
||||
-) Invalid orders are now removed from pending_orders
|
||||
-) FOK orders cancelled are now removed from pending_orders
|
||||
|
||||
1.1.11
|
||||
-) Removed pendingOrders from BfxWebsocket() (it was not used anywhere)
|
||||
-) Fixed issue in confirm_order_new() (the keys of the dict pending_orders are the cids of the orders, and not the ids)
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
This module contains the current version of the bfxapi lib
|
||||
"""
|
||||
|
||||
__version__ = '1.1.11'
|
||||
__version__ = '1.1.12'
|
||||
|
||||
@@ -314,6 +314,7 @@ class BfxWebsocket(GenericWebsocket):
|
||||
notificationText = nInfo[7]
|
||||
if notificationType == 'ERROR':
|
||||
# self._emit('error', notificationText)
|
||||
await self._order_error_handler(data)
|
||||
self.logger.error(
|
||||
"Notification ERROR: {}".format(notificationText))
|
||||
else:
|
||||
@@ -327,6 +328,9 @@ class BfxWebsocket(GenericWebsocket):
|
||||
async def _order_closed_handler(self, data):
|
||||
await self.orderManager.confirm_order_closed(data)
|
||||
|
||||
async def _order_error_handler(self, data):
|
||||
await self.orderManager.confirm_order_error(data)
|
||||
|
||||
async def _order_update_handler(self, data):
|
||||
await self.orderManager.confirm_order_update(data)
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ class OrderManager:
|
||||
order.set_open_state(False)
|
||||
if order.id in self.open_orders:
|
||||
del self.open_orders[order.id]
|
||||
if order.cid in self.pending_orders:
|
||||
del self.pending_orders[order.cid]
|
||||
self.closed_orders[order.id] = order
|
||||
if not order.is_confirmed():
|
||||
order.set_confirmed()
|
||||
@@ -87,6 +89,12 @@ class OrderManager:
|
||||
self.logger.info("Order new: {}".format(order))
|
||||
self.bfxapi._emit('order_new', order)
|
||||
|
||||
async def confirm_order_error(self, raw_ws_data):
|
||||
cid = raw_ws_data[2][4][2]
|
||||
if cid in self.pending_orders:
|
||||
del self.pending_orders[cid]
|
||||
self.logger.info("Deleted Order CID {} from pending orders".format(cid))
|
||||
|
||||
async def submit_order(self, symbol, price, amount, market_type=Order.Type.LIMIT,
|
||||
hidden=False, price_trailing=None, price_aux_limit=None,
|
||||
oco_stop_price=None, close=False, reduce_only=False,
|
||||
|
||||
Reference in New Issue
Block a user