Skip to content

Commit 9d55aa1

Browse files
committed
Fixed bug in YoY plot
1 parent 59e340e commit 9d55aa1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Calculate event study around events for asset (see examples/events_examples.py)
6060
# Requirements
6161

6262
Major requirements
63-
* Required: Python 3.7
64-
* Required: pandas 1.0.5, numpy etc.
63+
* Required: Python 3.8
64+
* Required: pandas 1.2.3, numpy etc.
6565
* Required: findatapy for downloading market data (https://github.com/cuemacro/findatapy)
6666
* Required: chartpy for funky interactive plots (https://github.com/cuemacro/chartpy)
6767

@@ -171,6 +171,8 @@ In finmarketpy/examples you will find several examples, including some simple tr
171171

172172
# finmarketpy log
173173

174+
* 23 Sep 2021
175+
* Fixed bug in YoY plot
174176
* 23 Jul 2021
175177
* Added roll costs in backtest
176178
* 30 May 2021

finmarketpy/backtest/backtestengine.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,12 @@ def construct_strategy(self, br=None, run_in_parallel=False):
10771077

10781078
self._strategy_group_benchmark_pnl_ret_stats = ret_stats_results
10791079

1080-
if hasattr(self, '_benchmark_ret_stats'):
1080+
try:
10811081
ret_stats_list = ret_stats_results
10821082
ret_stats_list['Benchmark'] = (self._strategy_benchmark_pnl_ret_stats)
10831083
self._strategy_group_benchmark_pnl_ret_stats = ret_stats_list
1084+
except:
1085+
pass
10841086

10851087
# Individual parts (all after individually applying portfolio level vol adjustment)
10861088
self._strategy_group_pnl = cum_results
@@ -1687,10 +1689,12 @@ def _plot_ret_stats_helper(self, ret_stats, metric, title, file_tag, strip=None,
16871689
return self._chart_return_with_df(ret_stats, style, silent_plot, chart_type='bar', ret_with_df=ret_with_df,
16881690
split_on_char=split_on_char)
16891691

1690-
def plot_strategy_group_benchmark_pnl_yoy(self, strip=None, silent_plot=False, split_on_char=None):
1692+
def plot_strategy_group_benchmark_pnl_yoy(self, strip=None, silent_plot=False, ret_with_df=False, split_on_char=None):
16911693

16921694
return self.plot_yoy_helper(self._strategy_group_benchmark_pnl_ret_stats, "", "Group Benchmark PnL YoY",
1693-
strip=strip, silent_plot=silent_plot)
1695+
strip=strip,
1696+
silent_plot=silent_plot, ret_with_df=ret_with_df,
1697+
split_on_char=split_on_char)
16941698

16951699
def plot_yoy_helper(self, ret_stats, title, file_tag, strip=None, silent_plot=False, ret_with_df=False,
16961700
split_on_char=None):

0 commit comments

Comments
 (0)