Have /monthly return proper dates, move formatting to telegram

This commit is contained in:
Matthias
2023-09-02 20:11:19 +02:00
parent f838bc760f
commit 3c20ab683a
3 changed files with 8 additions and 7 deletions

View File

@@ -109,13 +109,13 @@ def daily(timescale: int = 7, rpc: RPC = Depends(get_rpc), config=Depends(get_co
@router.get('/weekly', response_model=DailyWeeklyMonthly, tags=['info'])
def weekly(timescale: int = 4, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
return rpc._rpc_timeunit_profit(timescale, config['stake_currency'],
config.get('fiat_display_currency', 'weeks'))
config.get('fiat_display_currency', ''), 'weeks')
@router.get('/monthly', response_model=DailyWeeklyMonthly, tags=['info'])
def monthly(timescale: int = 3, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
return rpc._rpc_timeunit_profit(timescale, config['stake_currency'],
config.get('fiat_display_currency', 'months'))
config.get('fiat_display_currency', ''), 'months')
@router.get('/status', response_model=List[OpenTradeSchema], tags=['info'])

View File

@@ -364,7 +364,7 @@ class RPC:
data = [
{
'date': f"{key.year}-{key.month:02d}" if timeunit == 'months' else key,
'date': key,
'abs_profit': value["amount"],
'starting_balance': value["daily_stake"],
'rel_profit': value["rel_profit"],

View File

@@ -51,6 +51,7 @@ class TimeunitMappings:
message2: str
callback: str
default: int
dateformat: str
def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]):
@@ -736,10 +737,10 @@ class Telegram(RPCHandler):
"""
vals = {
'days': TimeunitMappings('Day', 'Daily', 'days', 'update_daily', 7),
'days': TimeunitMappings('Day', 'Daily', 'days', 'update_daily', 7, '%Y-%m-%d'),
'weeks': TimeunitMappings('Monday', 'Weekly', 'weeks (starting from Monday)',
'update_weekly', 8),
'months': TimeunitMappings('Month', 'Monthly', 'months', 'update_monthly', 6),
'update_weekly', 8, '%Y-%m-%d'),
'months': TimeunitMappings('Month', 'Monthly', 'months', 'update_monthly', 6, '%Y-%m'),
}
val = vals[unit]
@@ -756,7 +757,7 @@ class Telegram(RPCHandler):
unit
)
stats_tab = tabulate(
[[f"{period['date']} ({period['trade_count']})",
[[f"{period['date']:{val.dateformat}} ({period['trade_count']})",
f"{round_coin_value(period['abs_profit'], stats['stake_currency'])}",
f"{period['fiat_value']:.2f} {stats['fiat_display_currency']}",
f"{period['rel_profit']:.2%}",