updated unit test

This commit is contained in:
Kavinkumar 2022-02-18 16:06:50 +05:30
parent 8bc94ab378
commit 6021dffb4a
3 changed files with 23 additions and 12 deletions

View File

@ -452,7 +452,7 @@ class LocalTrade():
f"Trailing stoploss saved us: " f"Trailing stoploss saved us: "
f"{float(self.stop_loss) - float(self.initial_stop_loss):.8f}.") f"{float(self.stop_loss) - float(self.initial_stop_loss):.8f}.")
def update(self, order: Dict, partial:bool=False) -> None: def update(self, order: Dict, sub_trade:bool=False) -> None:
""" """
Updates this entity with amount and actual open/close rates. Updates this entity with amount and actual open/close rates.
:param order: order retrieved by exchange.fetch_order() :param order: order retrieved by exchange.fetch_order()
@ -477,7 +477,7 @@ class LocalTrade():
if self.is_open: if self.is_open:
logger.info(f'{order_type.upper()}_SELL has been fulfilled for {self}.') logger.info(f'{order_type.upper()}_SELL has been fulfilled for {self}.')
self.open_order_id = None self.open_order_id = None
if partial: if sub_trade:
orders=(self.select_filled_orders('buy')) orders=(self.select_filled_orders('buy'))
lbuy=orders[-2] lbuy=orders[-2]
lamount = (lbuy.filled or lbuy.amount) lamount = (lbuy.filled or lbuy.amount)

View File

@ -251,9 +251,9 @@ class Telegram(RPCHandler):
if msg.get('fiat_currency', None): if msg.get('fiat_currency', None):
message += f", {round_coin_value(total, msg['fiat_currency'])}" message += f", {round_coin_value(total, msg['fiat_currency'])}"
message += ")`\n" message += ")`"
if msg['partial']: if msg.get('sub_trade'):
message += f"*Balance:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}" message += f"\n*Balance:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}"
if msg.get('fiat_currency', None): if msg.get('fiat_currency', None):
message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}" message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}"
@ -300,13 +300,13 @@ class Telegram(RPCHandler):
elif msg['type'] == RPCMessageType.SELL_FILL: elif msg['type'] == RPCMessageType.SELL_FILL:
message += f"*Close Rate:* `{msg['close_rate']:.8f}`" message += f"*Close Rate:* `{msg['close_rate']:.8f}`"
if self._rpc._fiat_converter: if msg.get('sub_trade'):
msg['stake_amount_fiat'] = self._rpc._fiat_converter.convert_amount( if self._rpc._fiat_converter:
msg['stake_amount'], msg['stake_currency'], msg['fiat_currency']) msg['stake_amount_fiat'] = self._rpc._fiat_converter.convert_amount(
else: msg['stake_amount'], msg['stake_currency'], msg['fiat_currency'])
msg['stake_amount_fiat'] = 0 else:
if msg['partial']: msg['stake_amount_fiat'] = 0
message += f"*Balance:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}" message += f"\n*Balance:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}"
if msg.get('fiat_currency', None): if msg.get('fiat_currency', None):
message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}" message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}"

View File

@ -2619,6 +2619,9 @@ def test_execute_trade_exit_up(default_conf_usdt, ticker_usdt, fee, ticker_usdt_
'open_date': ANY, 'open_date': ANY,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'partial': False,
'stake_amount': 60.0,
} == last_msg } == last_msg
@ -2673,6 +2676,8 @@ def test_execute_trade_exit_down(default_conf_usdt, ticker_usdt, fee, ticker_usd
'open_date': ANY, 'open_date': ANY,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'partial': False,
'stake_amount': 60.0,
} == last_msg } == last_msg
@ -2741,6 +2746,8 @@ def test_execute_trade_exit_custom_exit_price(default_conf_usdt, ticker_usdt, fe
'open_date': ANY, 'open_date': ANY,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'partial': False,
'stake_amount': 60.0,
} == last_msg } == last_msg
@ -2801,6 +2808,8 @@ def test_execute_trade_exit_down_stoploss_on_exchange_dry_run(
'open_date': ANY, 'open_date': ANY,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'partial': False,
'stake_amount': 60.0,
} == last_msg } == last_msg
@ -3019,6 +3028,8 @@ def test_execute_trade_exit_market_order(default_conf_usdt, ticker_usdt, fee,
'open_date': ANY, 'open_date': ANY,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'partial': False,
'stake_amount': 60.0,
} == last_msg } == last_msg