Skip to content

Commit

Permalink
add performance table
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekOzana committed Aug 18, 2024
1 parent 362e78c commit bac281e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pages/Micro_Finance_Analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ def main() -> None:
fig = create_cumul_per_chart(name)
st.altair_chart(fig, use_container_width=True)

# Create performance table
tbl = (
st.session_state["orig_rets"][[name]]
.assign(
year=lambda x: x.index.year,
quarter=lambda x: x.index.month.map({3: "Q1", 6: "Q2", 9: "Q3", 12: "Q4"}),
)
.pivot(index="year", columns="quarter", values=name)
.assign(YTD=lambda x: x.add(1).prod(axis=1).sub(1))
.sort_index(ascending=False)
)
tbl.index = tbl.index.astype(str)

st.dataframe(tbl.style.format("{:0.2%}", na_rep=""))

# add disclaimer
st.divider()
st.caption(Path("data/disclaimer.txt").read_text())

Expand Down

0 comments on commit bac281e

Please sign in to comment.