| 654 | return daily_stats |
| 655 | |
| 656 | def _create_daily_stats(self, perfs): |
| 657 | # create daily and cumulative stats dataframe |
| 658 | daily_perfs = [] |
| 659 | # TODO: the loop here could overwrite expected properties |
| 660 | # of daily_perf. Could potentially raise or log a |
| 661 | # warning. |
| 662 | for perf in perfs: |
| 663 | if 'daily_perf' in perf: |
| 664 | |
| 665 | perf['daily_perf'].update( |
| 666 | perf['daily_perf'].pop('recorded_vars') |
| 667 | ) |
| 668 | perf['daily_perf'].update(perf['cumulative_risk_metrics']) |
| 669 | daily_perfs.append(perf['daily_perf']) |
| 670 | else: |
| 671 | self.risk_report = perf |
| 672 | |
| 673 | daily_dts = pd.DatetimeIndex( |
| 674 | [p['period_close'] for p in daily_perfs], tz='UTC' |
| 675 | ) |
| 676 | daily_stats = pd.DataFrame(daily_perfs, index=daily_dts) |
| 677 | return daily_stats |
| 678 | |
| 679 | def calculate_capital_changes(self, dt, emission_rate, is_interday, |
| 680 | portfolio_value_adjustment=0.0): |