refactor: move exception handler into helper function
This commit is contained in:
@@ -2233,7 +2233,6 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
# Must also run for partial exits
|
# Must also run for partial exits
|
||||||
# TODO: Margin will need to use interest_rate as well.
|
# TODO: Margin will need to use interest_rate as well.
|
||||||
# interest_rate = self.exchange.get_interest_rate()
|
# interest_rate = self.exchange.get_interest_rate()
|
||||||
try:
|
|
||||||
update_liquidation_prices(
|
update_liquidation_prices(
|
||||||
trade,
|
trade,
|
||||||
exchange=self.exchange,
|
exchange=self.exchange,
|
||||||
@@ -2241,8 +2240,6 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
stake_currency=self.config["stake_currency"],
|
stake_currency=self.config["stake_currency"],
|
||||||
dry_run=self.config["dry_run"],
|
dry_run=self.config["dry_run"],
|
||||||
)
|
)
|
||||||
except DependencyException:
|
|
||||||
logger.warning("Unable to calculate liquidation price")
|
|
||||||
if self.strategy.use_custom_stoploss:
|
if self.strategy.use_custom_stoploss:
|
||||||
current_rate = self.exchange.get_rate(
|
current_rate = self.exchange.get_rate(
|
||||||
trade.pair, side="exit", is_short=trade.is_short, refresh=True
|
trade.pair, side="exit", is_short=trade.is_short, refresh=True
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from freqtrade.enums import MarginMode
|
from freqtrade.enums import MarginMode
|
||||||
|
from freqtrade.exceptions import DependencyException
|
||||||
from freqtrade.exchange import Exchange
|
from freqtrade.exchange import Exchange
|
||||||
from freqtrade.persistence import LocalTrade, Trade
|
from freqtrade.persistence import LocalTrade, Trade
|
||||||
from freqtrade.wallets import Wallets
|
from freqtrade.wallets import Wallets
|
||||||
@@ -21,6 +22,7 @@ def update_liquidation_prices(
|
|||||||
Update trade liquidation price in isolated margin mode.
|
Update trade liquidation price in isolated margin mode.
|
||||||
Updates liquidation price for all trades in cross margin mode.
|
Updates liquidation price for all trades in cross margin mode.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
if exchange.margin_mode == MarginMode.CROSS:
|
if exchange.margin_mode == MarginMode.CROSS:
|
||||||
total_wallet_stake = 0.0
|
total_wallet_stake = 0.0
|
||||||
if dry_run:
|
if dry_run:
|
||||||
@@ -55,3 +57,5 @@ def update_liquidation_prices(
|
|||||||
other_trades=[],
|
other_trades=[],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except DependencyException:
|
||||||
|
logger.warning("Unable to calculate liquidation price")
|
||||||
|
|||||||
Reference in New Issue
Block a user