Skip to content

Commit

Permalink
deployed + return from html()
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesir committed Jul 22, 2024
1 parent 71f9ab8 commit f2352f1
Show file tree
Hide file tree
Showing 4 changed files with 327 additions and 1,353 deletions.
5 changes: 4 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
18 changes: 16 additions & 2 deletions quantstats_lumi/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -733,7 +738,6 @@ def full(
active=active,
)


def basic(
returns,
benchmark=None,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion quantstats_lumi/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.3.1"
version = "0.3.2"
Loading

0 comments on commit f2352f1

Please sign in to comment.