Merge pull request #3695 from freqtrade/fix_daily_rpc
Fix daily rpc for webservice
This commit is contained in:
commit
42273ae042
@ -224,22 +224,20 @@ class RPC:
|
|||||||
]).order_by(Trade.close_date).all()
|
]).order_by(Trade.close_date).all()
|
||||||
curdayprofit = sum(trade.close_profit_abs for trade in trades)
|
curdayprofit = sum(trade.close_profit_abs for trade in trades)
|
||||||
profit_days[profitday] = {
|
profit_days[profitday] = {
|
||||||
'amount': f'{curdayprofit:.8f}',
|
'amount': curdayprofit,
|
||||||
'trades': len(trades)
|
'trades': len(trades)
|
||||||
}
|
}
|
||||||
|
|
||||||
data = [
|
data = [
|
||||||
{
|
{
|
||||||
'date': key,
|
'date': key,
|
||||||
'abs_profit': f'{float(value["amount"]):.8f}',
|
'abs_profit': value["amount"],
|
||||||
'fiat_value': '{value:.3f}'.format(
|
'fiat_value': self._fiat_converter.convert_amount(
|
||||||
value=self._fiat_converter.convert_amount(
|
|
||||||
value['amount'],
|
value['amount'],
|
||||||
stake_currency,
|
stake_currency,
|
||||||
fiat_display_currency
|
fiat_display_currency
|
||||||
) if self._fiat_converter else 0,
|
) if self._fiat_converter else 0,
|
||||||
),
|
'trade_count': value["trades"],
|
||||||
'trade_count': f'{value["trades"]}',
|
|
||||||
}
|
}
|
||||||
for key, value in profit_days.items()
|
for key, value in profit_days.items()
|
||||||
]
|
]
|
||||||
|
@ -305,8 +305,8 @@ class Telegram(RPC):
|
|||||||
)
|
)
|
||||||
stats_tab = tabulate(
|
stats_tab = tabulate(
|
||||||
[[day['date'],
|
[[day['date'],
|
||||||
f"{day['abs_profit']} {stats['stake_currency']}",
|
f"{day['abs_profit']:.8f} {stats['stake_currency']}",
|
||||||
f"{day['fiat_value']} {stats['fiat_display_currency']}",
|
f"{day['fiat_value']:.3f} {stats['fiat_display_currency']}",
|
||||||
f"{day['trade_count']} trades"] for day in stats['data']],
|
f"{day['trade_count']} trades"] for day in stats['data']],
|
||||||
headers=[
|
headers=[
|
||||||
'Day',
|
'Day',
|
||||||
|
@ -255,11 +255,11 @@ def test_rpc_daily_profit(default_conf, update, ticker, fee,
|
|||||||
assert days['fiat_display_currency'] == default_conf['fiat_display_currency']
|
assert days['fiat_display_currency'] == default_conf['fiat_display_currency']
|
||||||
for day in days['data']:
|
for day in days['data']:
|
||||||
# [datetime.date(2018, 1, 11), '0.00000000 BTC', '0.000 USD']
|
# [datetime.date(2018, 1, 11), '0.00000000 BTC', '0.000 USD']
|
||||||
assert (day['abs_profit'] == '0.00000000' or
|
assert (day['abs_profit'] == 0.0 or
|
||||||
day['abs_profit'] == '0.00006217')
|
day['abs_profit'] == 0.00006217)
|
||||||
|
|
||||||
assert (day['fiat_value'] == '0.000' or
|
assert (day['fiat_value'] == 0.0 or
|
||||||
day['fiat_value'] == '0.767')
|
day['fiat_value'] == 0.76748865)
|
||||||
# ensure first day is current date
|
# ensure first day is current date
|
||||||
assert str(days['data'][0]['date']) == str(datetime.utcnow().date())
|
assert str(days['data'][0]['date']) == str(datetime.utcnow().date())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user