Add test for breakdown-stats

This commit is contained in:
Matthias
2021-10-21 07:09:17 +02:00
parent fa028c2134
commit 7b5346b984
3 changed files with 36 additions and 4 deletions

View File

@@ -219,12 +219,14 @@ def _get_resample_from_period(period: str) -> str:
if period == 'week':
return '1w'
if period == 'month':
return '1m'
return '1M'
raise ValueError(f"Period {period} is not supported.")
def generate_periodic_breakdown_stats(trade_list: List, period: str) -> List[Dict[str, Any]]:
results = DataFrame.from_records(trade_list)
if len(results) == 0:
return []
results['close_date'] = to_datetime(results['close_date'], utc=True)
resample = _get_resample_from_period(period)
period = results.resample(resample, on='close_date')