Merge pull request #5890 from aezomz/todo-rpc

Todo-lev RPC tests and model
This commit is contained in:
Matthias
2021-11-17 06:58:07 +01:00
committed by GitHub
7 changed files with 119 additions and 63 deletions

View File

@@ -154,6 +154,7 @@ class TradeSchema(BaseModel):
trade_id: int
pair: str
is_open: bool
is_short: bool
exchange: str
amount: float
amount_requested: float

View File

@@ -156,8 +156,9 @@ class RPC:
# calculate profit and send message to user
if trade.is_open:
try:
closing_side = "buy" if trade.is_short else "sell"
current_rate = self._freqtrade.exchange.get_rate(
trade.pair, refresh=False, side="sell")
trade.pair, refresh=False, side=closing_side)
except (ExchangeError, PricingError):
current_rate = NAN
else:
@@ -216,8 +217,9 @@ class RPC:
for trade in trades:
# calculate profit and send message to user
try:
closing_side = "buy" if trade.is_short else "sell"
current_rate = self._freqtrade.exchange.get_rate(
trade.pair, refresh=False, side="sell")
trade.pair, refresh=False, side=closing_side)
except (PricingError, ExchangeError):
current_rate = NAN
trade_percent = (100 * trade.calc_profit_ratio(current_rate))
@@ -376,8 +378,9 @@ class RPC:
else:
# Get current rate
try:
closing_side = "buy" if trade.is_short else "sell"
current_rate = self._freqtrade.exchange.get_rate(
trade.pair, refresh=False, side="sell")
trade.pair, refresh=False, side=closing_side)
except (PricingError, ExchangeError):
current_rate = NAN
profit_ratio = trade.calc_profit_ratio(rate=current_rate)
@@ -572,8 +575,9 @@ class RPC:
if not fully_canceled:
# Get current rate and execute sell
closing_side = "buy" if trade.is_short else "sell"
current_rate = self._freqtrade.exchange.get_rate(
trade.pair, refresh=False, side="sell")
trade.pair, refresh=False, side=closing_side)
sell_reason = SellCheckTuple(sell_type=SellType.FORCE_SELL)
self._freqtrade.execute_trade_exit(trade, current_rate, sell_reason)
# ---- EOF def _exec_forcesell ----