Consider removing the commented out code block
960
961 metrics["Gain/Pain Ratio"] = _stats.gain_to_pain_ratio(df, rf)
962 metrics["Gain/Pain (1M)"] = _stats.gain_to_pain_ratio(df, rf, "M")
963 # if mode.lower() == 'full': 964 # metrics['GPR (3M)'] = _stats.gain_to_pain_ratio(df, rf, "Q")
965 # metrics['GPR (6M)'] = _stats.gain_to_pain_ratio(df, rf, "2Q")
966 # metrics['GPR (1Y)'] = _stats.gain_to_pain_ratio(df, rf, "A")
Consider removing the commented out code block
854 if mode.lower() == "full":
855 # metrics['Prob. Sortino Ratio %'] = _stats.probabilistic_sortino_ratio(df, rf, win_year, False) * pct
856 metrics["Smart Sortino"] = _stats.smart_sortino(df, rf, win_year, True)
857 # metrics['Prob. Smart Sortino Ratio %'] = _stats.probabilistic_sortino_ratio(df, rf, win_year, False, True) * pct 858
859 metrics["Sortino/√2"] = metrics["Sortino"] / _sqrt(2)
860 if mode.lower() == "full":
Consider removing the commented out code block
852
853 metrics["Sortino"] = _stats.sortino(df, rf, win_year, True)
854 if mode.lower() == "full":
855 # metrics['Prob. Sortino Ratio %'] = _stats.probabilistic_sortino_ratio(df, rf, win_year, False) * pct 856 metrics["Smart Sortino"] = _stats.smart_sortino(df, rf, win_year, True)
857 # metrics['Prob. Smart Sortino Ratio %'] = _stats.probabilistic_sortino_ratio(df, rf, win_year, False, True) * pct
858
Consider removing the commented out code block
848 )
849 if mode.lower() == "full":
850 metrics["Smart Sharpe"] = _stats.smart_sharpe(df, rf, win_year, True)
851 # metrics['Prob. Smart Sharpe Ratio %'] = _stats.probabilistic_sharpe_ratio(df, rf, win_year, False, True) * pct 852
853 metrics["Sortino"] = _stats.sortino(df, rf, win_year, True)
854 if mode.lower() == "full":
Consider removing the commented out code block
759 else:
760 blank = [""]
761
762 # if isinstance(returns, _pd.DataFrame): 763 # if len(returns.columns) > 1:
764 # raise ValueError("`returns` needs to be a Pandas Series or one column DataFrame. multi colums DataFrame was passed")
765 # returns = returns[returns.columns[0]]
Consider removing the commented out code block
1028 cmap=cmap,
1029 cbar_kws={"format": "%.0f%%"},
1030 )
1031 # _sns.set(font_scale=1)1032
1033 # align plot to match other
1034 if ylabel:
Consider removing the commented out code block
978 fig.set_facecolor("white")
979 ax.set_facecolor("white")
980
981 # _sns.set(font_scale=.9) 982 if active and benchmark is not None:
983 ax.set_title(
984 f"{returns_label} - Monthly Active Returns (%)\n",
Consider removing the commented out code block
953 show=True,
954 active=False,
955):
956 # colors, ls, alpha = _core._get_colors(grayscale) 957 cmap = "gray" if grayscale else "RdYlGn"
958
959 returns = _stats.monthly_returns(returns, eoy=eoy, compounded=compounded) * 100
Consider removing the commented out code block
226 axes[2].axhline(0, color=colors[-1], linestyle="--", lw=1, zorder=2)
227
228 axes[2].set_yscale("symlog" if log_scale else "linear")
229 # axes[2].legend(fontsize=12) 230
231 retmax = _utils._round_to_closest(returns.max() * 100, 5)
232 retmin = _utils._round_to_closest(returns.min() * 100, 5)
Consider removing the commented out code block
208 )
209
210 axes[1].set_yscale("symlog" if log_scale else "linear")
211 # axes[1].legend(fontsize=12) 212
213 axes[2].set_ylabel(
214 "Daily Return", fontname=fontname, fontweight="bold", fontsize=12
Consider removing the commented out code block
189 ddmin_ticks = ddmin / 3
190 ddmin_ticks = int(_utils._round_to_closest(ddmin_ticks, 5))
191
192 # ddmin_ticks = int(_utils._round_to_closest(ddmin, 5)) 193 axes[1].set_ylabel("Drawdown", fontname=fontname, fontweight="bold", fontsize=12)
194 axes[1].set_yticks(_np.arange(-ddmin, 0, step=ddmin_ticks))
195 if isinstance(dd, _pd.Series):
Consider removing the commented out code block
178 axes[0].axhline(0, color="silver", lw=1, zorder=0)
179
180 axes[0].set_yscale("symlog" if log_scale else "linear")
181 # axes[0].legend(fontsize=12) 182
183 dd = _stats.to_drawdown_series(returns) * 100
184 ddmin = _utils._round_to_closest(abs(dd.min()), 5)
Consider removing the commented out code block
1003 colors = _FLATUI_COLORS
1004 if grayscale:
1005 colors = ["#f9f9f9", "#dddddd", "#bbbbbb", "#999999", "#808080"]
1006 # colors, ls, alpha = _get_colors(grayscale)1007
1008 port = _pd.DataFrame(returns.fillna(0))
1009 port.columns = ["Daily"]
Consider removing the commented out code block
955 ax.yaxis.set_label_coords(-0.1, 0.5)
956
957 ax.yaxis.set_major_formatter(_FuncFormatter(format_pct_axis))
958 # ax.yaxis.set_major_formatter(_plt.FuncFormatter( 959 # lambda x, loc: "{:,}%".format(int(x*100))))
960
961 fig.autofmt_xdate()
Consider removing the commented out code block
567 )
568 ax.yaxis.set_label_coords(-0.1, 0.5)
569
570 # fig.autofmt_xdate() 571
572 try:
573 _plt.subplots_adjust(hspace=0, bottom=0, top=1)
Consider removing the commented out code block
552 color="red",
553 )
554
555 # _plt.setp(x.get_legend().get_texts(), fontsize=11) 556 ax.xaxis.set_major_formatter(
557 _plt.FuncFormatter(lambda x, loc: "{:,}%".format(int(x * 100)))
558 )
Consider removing the commented out code block
528 .reset_index()
529 .rename(columns={"level_1": "", 0: "Returns"})
530 )
531 # _sns.kdeplot(data=combined_returns, color='black', ax=ax) 532 x = _sns.histplot(
533 data=combined_returns,
534 x="Returns",
Consider removing the commented out code block
418 show=True,
419):
420
421 # colors = ['#348dc1', '#003366', 'red'] 422 # if grayscale:
423 # colors = ['silver', 'gray', 'black']
424
Consider removing the commented out code block
361
362 if percent:
363 ax.yaxis.set_major_formatter(_FuncFormatter(format_pct_axis))
364 # ax.yaxis.set_major_formatter(_plt.FuncFormatter( 365 # lambda x, loc: "{:,}%".format(int(x*100))))
366
367 ax.set_xlabel("")
Consider removing the commented out code block
354 ax.axhline(0, ls="-", lw=1, color="gray", zorder=1)
355 ax.axhline(0, ls="--", lw=1, color="white" if grayscale else "black", zorder=2)
356
357 # if isinstance(benchmark, _pd.Series) or hline is not None: 358 ax.legend(fontsize=11)
359
360 _plt.yscale("symlog" if log_scale else "linear")
Consider removing the commented out code block
326 if isinstance(returns, _pd.Series):
327 ax.plot(returns, lw=lw, label=returns.name, color=colors[1], alpha=alpha)
328 elif isinstance(returns, _pd.DataFrame):
329 # color_dict = {col: colors[i+1] for i, col in enumerate(returns.columns)} 330 for i, col in enumerate(returns.columns):
331 ax.plot(returns[col], lw=lw, label=col, alpha=alpha, color=colors[i + 1])
332
Consider removing the commented out code block
196
197 ax.axhline(0, ls="--", lw=1, color="#000000", zorder=2)
198
199 # if isinstance(benchmark, _pd.Series) or hline: 200 ax.legend(fontsize=11)
201
202 _plt.yscale("symlog" if log_scale else "linear")
Consider removing the commented out code block
176 ax.set_xticklabels(df.index)
177 years = sorted(list(set(df.index)))
178
179 # ax.fmt_xdata = _mdates.DateFormatter('%Y-%m-%d') 180 # years = sorted(list(set(df.index.year)))
181 if len(years) > 10:
182 mod = int(len(years) / 10)
Description
It is recommended to remove any commented code in your codebase.
Bad practice
for item in sequence:
# print(item)
do_something(item)
# def old_function():
# '''Older implementation that has been replaced'''
# data = get_data()
# api.post(data)
Recommended
for item in sequence:
do_something(item)