Skip to content

Commit

Permalink
[RemoteTradingSignalsModeConsumer] improve min funds handling
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Oct 12, 2023
1 parent 5d7367d commit a9f19fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ async def internal_callback(self, trading_mode_name, cryptocurrency, symbol, tim
try:
await self._handle_signal_orders(symbol, data)
except errors.MissingMinimalExchangeTradeVolume:
self.logger.info(f"Not enough funds to create a new order: {self.exchange_manager.exchange_name} "
f"exchange minimal order volume has not been reached.")
self.logger.info(self.get_minimal_funds_error(symbol, final_note))
except Exception as e:
self.logger.exception(e, True, f"Error when handling remote signal orders: {e}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ async def test_internal_callback(local_trader, mocked_sell_limit_signal):
with mock.patch.object(consumer, "_handle_signal_orders",
new=mock.AsyncMock(side_effect=errors.MissingMinimalExchangeTradeVolume)) \
as _handle_signal_orders_mock:
await consumer.internal_callback("trading_mode_name", "cryptocurrency", "symbol", "time_frame", "final_note",
await consumer.internal_callback("trading_mode_name", "cryptocurrency", "symbol/x", "time_frame", "final_note",
"state", "data")
_handle_signal_orders_mock.assert_called_once_with("symbol", "data")
_handle_signal_orders_mock.assert_called_once_with("symbol/x", "data")
consumer.logger.info.assert_called_once()
consumer.logger.exception.assert_not_called()
consumer.logger.info.reset_mock()

with mock.patch.object(consumer, "_handle_signal_orders",
new=mock.AsyncMock(side_effect=RuntimeError)) \
as _handle_signal_orders_mock:
await consumer.internal_callback("trading_mode_name", "cryptocurrency", "symbol", "time_frame", "final_note",
await consumer.internal_callback("trading_mode_name", "cryptocurrency", "symbol/x", "time_frame", "final_note",
"state", "data")
_handle_signal_orders_mock.assert_called_once_with("symbol", "data")
_handle_signal_orders_mock.assert_called_once_with("symbol/x", "data")
consumer.logger.info.assert_not_called()
consumer.logger.exception.assert_called_once()

Expand Down

0 comments on commit a9f19fe

Please sign in to comment.