diff --git a/example.py b/example.py index 16a80ce..54a1e48 100644 --- a/example.py +++ b/example.py @@ -33,7 +33,10 @@ } # Generate the HTML report -reports.html(returns, output=output_file_path, parameters=example_parameters) +html_result = reports.html(returns, output=output_file_path, parameters=example_parameters) + +# Print the HTML result +print(html_result) # Open the HTML file in a browser to visually inspect the output os.system(f"open {output_file_path}") diff --git a/quantstats_lumi/reports.py b/quantstats_lumi/reports.py index d8332f4..705bef0 100644 --- a/quantstats_lumi/reports.py +++ b/quantstats_lumi/reports.py @@ -579,6 +579,11 @@ def html( with open(output, "w", encoding="utf-8") as f: f.write(tpl) + print(f"HTML report saved to: {output}") + + # Return the metrics + return mtrx + def full( returns, @@ -733,7 +738,6 @@ def full( active=active, ) - def basic( returns, benchmark=None, @@ -1160,7 +1164,17 @@ def metrics( ) * pct ) - metrics["Win Days %%"] = _stats.win_rate(df, prepare_returns=False) * pct + + # Get the win rate + win_rate = _stats.win_rate(df, prepare_returns=False) + + # Number of win days in total + metrics["Win Days"] = win_rate * len(df) + + # Number of loss days in total + metrics["Loss Days"] = len(df) - metrics["Win Days"] + + metrics["Win Days %%"] = win_rate * pct metrics["Win Month %%"] = ( _stats.win_rate( df, compounded=compounded, aggregate="ME", prepare_returns=False diff --git a/quantstats_lumi/version.py b/quantstats_lumi/version.py index 63fe829..5189669 100644 --- a/quantstats_lumi/version.py +++ b/quantstats_lumi/version.py @@ -1 +1 @@ -version = "0.3.1" +version = "0.3.2" diff --git a/report.html b/report.html index ce20582..c18b5be 100644 --- a/report.html +++ b/report.html @@ -284,7 +284,7 @@