mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
fix test_rpc_trade_status
This commit is contained in:
@@ -26,7 +26,7 @@ from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs
|
|||||||
from freqtrade.exchange.types import Tickers
|
from freqtrade.exchange.types import Tickers
|
||||||
from freqtrade.loggers import bufferHandler
|
from freqtrade.loggers import bufferHandler
|
||||||
from freqtrade.misc import decimals_per_coin
|
from freqtrade.misc import decimals_per_coin
|
||||||
from freqtrade.persistence import KeyStoreKeys, KeyValueStore, Order, PairLocks, Trade
|
from freqtrade.persistence import KeyStoreKeys, KeyValueStore, PairLocks, Trade
|
||||||
from freqtrade.persistence.models import PairLock
|
from freqtrade.persistence.models import PairLock
|
||||||
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
||||||
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
|
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
|
||||||
@@ -171,11 +171,18 @@ class RPC:
|
|||||||
else:
|
else:
|
||||||
results = []
|
results = []
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
order: Optional[Order] = None
|
|
||||||
current_profit_fiat: Optional[float] = None
|
current_profit_fiat: Optional[float] = None
|
||||||
total_profit_fiat: Optional[float] = None
|
total_profit_fiat: Optional[float] = None
|
||||||
if trade.open_order_id:
|
|
||||||
order = trade.select_order_by_order_id(trade.open_order_id)
|
# prepare open orders details
|
||||||
|
oo_details: Optional[str] = ""
|
||||||
|
oo_details_lst = [
|
||||||
|
f'({oo.order_type} {oo.side} rem={oo.safe_remaining:.8f})'
|
||||||
|
for oo in trade.open_orders
|
||||||
|
if oo.ft_order_side not in ['stoploss']
|
||||||
|
]
|
||||||
|
oo_details = ''.join(map(str, oo_details_lst))
|
||||||
|
|
||||||
# calculate profit and send message to user
|
# calculate profit and send message to user
|
||||||
if trade.is_open:
|
if trade.is_open:
|
||||||
try:
|
try:
|
||||||
@@ -230,7 +237,6 @@ class RPC:
|
|||||||
profit_pct=round(current_profit * 100, 2),
|
profit_pct=round(current_profit * 100, 2),
|
||||||
profit_abs=current_profit_abs,
|
profit_abs=current_profit_abs,
|
||||||
profit_fiat=current_profit_fiat,
|
profit_fiat=current_profit_fiat,
|
||||||
|
|
||||||
total_profit_abs=total_profit_abs,
|
total_profit_abs=total_profit_abs,
|
||||||
total_profit_fiat=total_profit_fiat,
|
total_profit_fiat=total_profit_fiat,
|
||||||
total_profit_ratio=total_profit_ratio,
|
total_profit_ratio=total_profit_ratio,
|
||||||
@@ -239,10 +245,7 @@ class RPC:
|
|||||||
stoploss_current_dist_pct=round(stoploss_current_dist_ratio * 100, 2),
|
stoploss_current_dist_pct=round(stoploss_current_dist_ratio * 100, 2),
|
||||||
stoploss_entry_dist=stoploss_entry_dist,
|
stoploss_entry_dist=stoploss_entry_dist,
|
||||||
stoploss_entry_dist_ratio=round(stoploss_entry_dist_ratio, 8),
|
stoploss_entry_dist_ratio=round(stoploss_entry_dist_ratio, 8),
|
||||||
open_order=(
|
open_orders=oo_details
|
||||||
f'({order.order_type} {order.side} rem={order.safe_remaining:.8f})' if
|
|
||||||
order else None
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
results.append(trade_dict)
|
results.append(trade_dict)
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'stoploss_current_dist_pct': -10.01,
|
'stoploss_current_dist_pct': -10.01,
|
||||||
'stoploss_entry_dist': -0.00010402,
|
'stoploss_entry_dist': -0.00010402,
|
||||||
'stoploss_entry_dist_ratio': -0.10376381,
|
'stoploss_entry_dist_ratio': -0.10376381,
|
||||||
'open_order': None,
|
'open_orders': '',
|
||||||
'realized_profit': 0.0,
|
'realized_profit': 0.0,
|
||||||
'realized_profit_ratio': None,
|
'realized_profit_ratio': None,
|
||||||
'total_profit_abs': -4.09e-06,
|
'total_profit_abs': -4.09e-06,
|
||||||
@@ -127,7 +127,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'profit_pct': 0.0,
|
'profit_pct': 0.0,
|
||||||
'profit_abs': 0.0,
|
'profit_abs': 0.0,
|
||||||
'total_profit_abs': 0.0,
|
'total_profit_abs': 0.0,
|
||||||
'open_order': '(limit buy rem=91.07468123)',
|
'open_orders': '(limit buy rem=91.07468123)',
|
||||||
})
|
})
|
||||||
response_unfilled['orders'][0].update({
|
response_unfilled['orders'][0].update({
|
||||||
'is_open': True,
|
'is_open': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user