Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -487,18 +487,18 @@ def runapp() -> None:
|
|
| 487 |
#sd_df = get_sd_df(get_sd_df(df.copy(), sd, bot_selections, dca1, dca2, dca3, dca4, dca5, dca6, fees, lev, dollar_cap, principal_balance)
|
| 488 |
|
| 489 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
|
| 503 |
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 504 |
#st.line_chart(data=df.drop('Drawdown %', axis=1).dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
|
@@ -565,81 +565,80 @@ def runapp() -> None:
|
|
| 565 |
)
|
| 566 |
|
| 567 |
st.plotly_chart(fig, theme=None, use_container_width=True,height=600)
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
"
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
"
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
"
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
"
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
)
|
| 643 |
|
| 644 |
if bot_selections == "Cinnamon Toast":
|
| 645 |
if submitted:
|
|
|
|
| 487 |
#sd_df = get_sd_df(get_sd_df(df.copy(), sd, bot_selections, dca1, dca2, dca3, dca4, dca5, dca6, fees, lev, dollar_cap, principal_balance)
|
| 488 |
|
| 489 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
| 490 |
+
|
| 491 |
+
st.header(f"{bot_selections} Results")
|
| 492 |
+
with st.container():
|
| 493 |
|
| 494 |
+
if len(bot_selections) > 1:
|
| 495 |
+
col1, col2 = st.columns(2)
|
| 496 |
+
with col1:
|
| 497 |
+
st.metric(
|
| 498 |
+
"Total Account Balance",
|
| 499 |
+
f"${cum_pl:.2f}",
|
| 500 |
+
f"{100*(cum_pl-principal_balance)/(principal_balance):.2f} %",
|
| 501 |
+
)
|
| 502 |
|
| 503 |
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 504 |
#st.line_chart(data=df.drop('Drawdown %', axis=1).dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
|
|
|
| 565 |
)
|
| 566 |
|
| 567 |
st.plotly_chart(fig, theme=None, use_container_width=True,height=600)
|
| 568 |
+
st.write()
|
| 569 |
+
df['Per Trade Return Rate'] = df['Return Per Trade']-1
|
| 570 |
+
|
| 571 |
+
totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
|
| 572 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 573 |
+
data = get_hist_info(df.drop('Drawdown %', axis=1).dropna(), principal_balance,'Per Trade Return Rate')
|
| 574 |
+
else:
|
| 575 |
+
data = get_hist_info(df.dropna(), principal_balance,'Per Trade Return Rate')
|
| 576 |
+
totals.loc[len(totals)] = list(i for i in data)
|
| 577 |
+
|
| 578 |
+
totals['Cum. P/L'] = cum_pl-principal_balance
|
| 579 |
+
totals['Cum. P/L (%)'] = 100*(cum_pl-principal_balance)/principal_balance
|
| 580 |
+
|
| 581 |
+
if df.empty:
|
| 582 |
+
st.error("Oops! None of the data provided matches your selection(s). Please try again.")
|
| 583 |
+
else:
|
| 584 |
+
with st.container():
|
| 585 |
+
for row in totals.itertuples():
|
| 586 |
+
col1, col2, col3, col4= st.columns(4)
|
| 587 |
+
c1, c2, c3, c4 = st.columns(4)
|
| 588 |
+
with col1:
|
| 589 |
+
st.metric(
|
| 590 |
+
"Total Trades",
|
| 591 |
+
f"{row._1:.0f}",
|
| 592 |
+
)
|
| 593 |
+
with c1:
|
| 594 |
+
st.metric(
|
| 595 |
+
"Profit Factor",
|
| 596 |
+
f"{row._5:.2f}",
|
| 597 |
+
)
|
| 598 |
+
with col2:
|
| 599 |
+
st.metric(
|
| 600 |
+
"Wins",
|
| 601 |
+
f"{row.Wins:.0f}",
|
| 602 |
+
)
|
| 603 |
+
with c2:
|
| 604 |
+
st.metric(
|
| 605 |
+
"Cumulative P/L",
|
| 606 |
+
f"${row._6:.2f}",
|
| 607 |
+
f"{row._7:.2f} %",
|
| 608 |
+
)
|
| 609 |
+
with col3:
|
| 610 |
+
st.metric(
|
| 611 |
+
"Losses",
|
| 612 |
+
f"{row.Losses:.0f}",
|
| 613 |
+
)
|
| 614 |
+
with c3:
|
| 615 |
+
st.metric(
|
| 616 |
+
"Rolling 7 Days",
|
| 617 |
+
"",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
|
| 618 |
+
f"{get_rolling_stats(df,lev, otimeheader, 7):.2f}%",
|
| 619 |
+
)
|
| 620 |
+
st.metric(
|
| 621 |
+
"Rolling 30 Days",
|
| 622 |
+
"",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
|
| 623 |
+
f"{get_rolling_stats(df,lev, otimeheader, 30):.2f}%",
|
| 624 |
+
)
|
| 625 |
+
|
| 626 |
+
with col4:
|
| 627 |
+
st.metric(
|
| 628 |
+
"Win Rate",
|
| 629 |
+
f"{row._4:.1f}%",
|
| 630 |
+
)
|
| 631 |
+
with c4:
|
| 632 |
+
st.metric(
|
| 633 |
+
"Rolling 90 Days",
|
| 634 |
+
"",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
|
| 635 |
+
f"{get_rolling_stats(df,lev, otimeheader, 90):.2f}%",
|
| 636 |
+
)
|
| 637 |
+
st.metric(
|
| 638 |
+
"Rolling 180 Days",
|
| 639 |
+
"",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
|
| 640 |
+
f"{get_rolling_stats(df,lev, otimeheader, 180):.2f}%",
|
| 641 |
+
)
|
|
|
|
| 642 |
|
| 643 |
if bot_selections == "Cinnamon Toast":
|
| 644 |
if submitted:
|