mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-03 18:43:04 +00:00
Fix wrong "first trade" date in UI, improve interface
closes https://github.com/freqtrade/freqtrade-strategies/issues/301
This commit is contained in:
@@ -100,8 +100,10 @@ class Profit(BaseModel):
|
||||
trade_count: int
|
||||
closed_trade_count: int
|
||||
first_trade_date: str
|
||||
first_trade_humanized: str
|
||||
first_trade_timestamp: int
|
||||
latest_trade_date: str
|
||||
latest_trade_humanized: str
|
||||
latest_trade_timestamp: int
|
||||
avg_duration: str
|
||||
best_pair: str
|
||||
|
||||
@@ -540,8 +540,8 @@ class RPC:
|
||||
fiat_display_currency
|
||||
) if self._fiat_converter else 0
|
||||
|
||||
first_date = trades[0].open_date if trades else None
|
||||
last_date = trades[-1].open_date if trades else None
|
||||
first_date = trades[0].open_date_utc if trades else None
|
||||
last_date = trades[-1].open_date_utc if trades else None
|
||||
num = float(len(durations) or 1)
|
||||
bot_start = KeyValueStore.get_datetime_value(KeyStoreKeys.BOT_START_TIME)
|
||||
return {
|
||||
@@ -563,9 +563,11 @@ class RPC:
|
||||
'profit_all_fiat': profit_all_fiat,
|
||||
'trade_count': len(trades),
|
||||
'closed_trade_count': len([t for t in trades if not t.is_open]),
|
||||
'first_trade_date': arrow.get(first_date).humanize() if first_date else '',
|
||||
'first_trade_date': first_date.strftime(DATETIME_PRINT_FORMAT) if first_date else '',
|
||||
'first_trade_humanized': arrow.get(first_date).humanize() if first_date else '',
|
||||
'first_trade_timestamp': int(first_date.timestamp() * 1000) if first_date else 0,
|
||||
'latest_trade_date': arrow.get(last_date).humanize() if last_date else '',
|
||||
'latest_trade_date': last_date.strftime(DATETIME_PRINT_FORMAT) if last_date else '',
|
||||
'latest_trade_humanized': arrow.get(last_date).humanize() if last_date else '',
|
||||
'latest_trade_timestamp': int(last_date.timestamp() * 1000) if last_date else 0,
|
||||
'avg_duration': str(timedelta(seconds=sum(durations) / num)).split('.')[0],
|
||||
'best_pair': best_pair[0] if best_pair else '',
|
||||
|
||||
@@ -853,8 +853,8 @@ class Telegram(RPCHandler):
|
||||
profit_all_percent = stats['profit_all_percent']
|
||||
profit_all_fiat = stats['profit_all_fiat']
|
||||
trade_count = stats['trade_count']
|
||||
first_trade_date = stats['first_trade_date']
|
||||
latest_trade_date = stats['latest_trade_date']
|
||||
first_trade_date = f"{stats['first_trade_humanized']} ({stats['first_trade_date']})"
|
||||
latest_trade_date = f"{stats['latest_trade_humanized']} ({stats['latest_trade_date']})"
|
||||
avg_duration = stats['avg_duration']
|
||||
best_pair = stats['best_pair']
|
||||
best_pair_profit_ratio = stats['best_pair_profit_ratio']
|
||||
|
||||
@@ -414,8 +414,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
|
||||
assert pytest.approx(stats['profit_all_percent_mean']) == -57.86
|
||||
assert pytest.approx(stats['profit_all_fiat']) == -85.205614098
|
||||
assert stats['trade_count'] == 7
|
||||
assert stats['first_trade_date'] == '2 days ago'
|
||||
assert stats['latest_trade_date'] == '17 minutes ago'
|
||||
assert stats['first_trade_humanized'] == '2 days ago'
|
||||
assert stats['latest_trade_humanized'] == '17 minutes ago'
|
||||
assert stats['avg_duration'] in ('0:17:40')
|
||||
assert stats['best_pair'] == 'XRP/USDT'
|
||||
assert stats['best_rate'] == 10.0
|
||||
@@ -425,8 +425,8 @@ def test_rpc_trade_statistics(default_conf_usdt, ticker, fee, mocker) -> None:
|
||||
MagicMock(side_effect=ExchangeError("Pair 'XRP/USDT' not available")))
|
||||
stats = rpc._rpc_trade_statistics(stake_currency, fiat_display_currency)
|
||||
assert stats['trade_count'] == 7
|
||||
assert stats['first_trade_date'] == '2 days ago'
|
||||
assert stats['latest_trade_date'] == '17 minutes ago'
|
||||
assert stats['first_trade_humanized'] == '2 days ago'
|
||||
assert stats['latest_trade_humanized'] == '17 minutes ago'
|
||||
assert stats['avg_duration'] in ('0:17:40')
|
||||
assert stats['best_pair'] == 'XRP/USDT'
|
||||
assert stats['best_rate'] == 10.0
|
||||
|
||||
@@ -888,8 +888,10 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, is_short, expected)
|
||||
'best_pair_profit_ratio': expected['best_pair_profit_ratio'],
|
||||
'best_rate': expected['best_rate'],
|
||||
'first_trade_date': ANY,
|
||||
'first_trade_humanized': ANY,
|
||||
'first_trade_timestamp': ANY,
|
||||
'latest_trade_date': '5 minutes ago',
|
||||
'latest_trade_date': ANY,
|
||||
'latest_trade_humanized': '5 minutes ago',
|
||||
'latest_trade_timestamp': ANY,
|
||||
'profit_all_coin': pytest.approx(expected['profit_all_coin']),
|
||||
'profit_all_fiat': pytest.approx(expected['profit_all_fiat']),
|
||||
|
||||
Reference in New Issue
Block a user