Have /monthly return proper dates, move formatting to telegram
This commit is contained in:
@@ -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'])
|
@router.get('/weekly', response_model=DailyWeeklyMonthly, tags=['info'])
|
||||||
def weekly(timescale: int = 4, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
def weekly(timescale: int = 4, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
||||||
return rpc._rpc_timeunit_profit(timescale, config['stake_currency'],
|
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'])
|
@router.get('/monthly', response_model=DailyWeeklyMonthly, tags=['info'])
|
||||||
def monthly(timescale: int = 3, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
def monthly(timescale: int = 3, rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
||||||
return rpc._rpc_timeunit_profit(timescale, config['stake_currency'],
|
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'])
|
@router.get('/status', response_model=List[OpenTradeSchema], tags=['info'])
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ class RPC:
|
|||||||
|
|
||||||
data = [
|
data = [
|
||||||
{
|
{
|
||||||
'date': f"{key.year}-{key.month:02d}" if timeunit == 'months' else key,
|
'date': key,
|
||||||
'abs_profit': value["amount"],
|
'abs_profit': value["amount"],
|
||||||
'starting_balance': value["daily_stake"],
|
'starting_balance': value["daily_stake"],
|
||||||
'rel_profit': value["rel_profit"],
|
'rel_profit': value["rel_profit"],
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class TimeunitMappings:
|
|||||||
message2: str
|
message2: str
|
||||||
callback: str
|
callback: str
|
||||||
default: int
|
default: int
|
||||||
|
dateformat: str
|
||||||
|
|
||||||
|
|
||||||
def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]):
|
def authorized_only(command_handler: Callable[..., Coroutine[Any, Any, None]]):
|
||||||
@@ -736,10 +737,10 @@ class Telegram(RPCHandler):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
vals = {
|
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)',
|
'weeks': TimeunitMappings('Monday', 'Weekly', 'weeks (starting from Monday)',
|
||||||
'update_weekly', 8),
|
'update_weekly', 8, '%Y-%m-%d'),
|
||||||
'months': TimeunitMappings('Month', 'Monthly', 'months', 'update_monthly', 6),
|
'months': TimeunitMappings('Month', 'Monthly', 'months', 'update_monthly', 6, '%Y-%m'),
|
||||||
}
|
}
|
||||||
val = vals[unit]
|
val = vals[unit]
|
||||||
|
|
||||||
@@ -756,7 +757,7 @@ class Telegram(RPCHandler):
|
|||||||
unit
|
unit
|
||||||
)
|
)
|
||||||
stats_tab = tabulate(
|
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"{round_coin_value(period['abs_profit'], stats['stake_currency'])}",
|
||||||
f"{period['fiat_value']:.2f} {stats['fiat_display_currency']}",
|
f"{period['fiat_value']:.2f} {stats['fiat_display_currency']}",
|
||||||
f"{period['rel_profit']:.2%}",
|
f"{period['rel_profit']:.2%}",
|
||||||
|
|||||||
Reference in New Issue
Block a user