Spaces:
Runtime error
Runtime error
Commit ·
9df5fa8
1
Parent(s): 00b4056
update sb and ft for drawdown %
Browse files
app.py
CHANGED
|
@@ -583,8 +583,12 @@ def runapp() -> None:
|
|
| 583 |
df['Balance used in Trade'] = np.concatenate([[principal_balance], df['New Balance'].values[:-1]])
|
| 584 |
df['Net P/L Per Trade'] = (df['Return Per Trade']-1)*df['Balance used in Trade']
|
| 585 |
df['Cumulative P/L'] = df['Net P/L Per Trade'].cumsum()
|
| 586 |
-
cum_pl = df.loc[df.drop('Drawdown %', axis=1).dropna().index[-1],'Cumulative P/L'] + principal_balance
|
| 587 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 588 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
| 589 |
|
| 590 |
st.header(f"{bot_selections} Results")
|
|
@@ -594,17 +598,23 @@ def runapp() -> None:
|
|
| 594 |
f"${cum_pl:.2f}",
|
| 595 |
f"{100*(cum_pl-principal_balance)/(principal_balance):.2f} %",
|
| 596 |
)
|
| 597 |
-
|
| 598 |
-
|
|
|
|
|
|
|
| 599 |
|
| 600 |
df['Per Trade Return Rate'] = df['Return Per Trade']-1
|
| 601 |
|
| 602 |
totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
|
| 603 |
-
|
|
|
|
|
|
|
|
|
|
| 604 |
totals.loc[len(totals)] = list(i for i in data)
|
| 605 |
|
| 606 |
totals['Cum. P/L'] = cum_pl-principal_balance
|
| 607 |
totals['Cum. P/L (%)'] = 100*(cum_pl-principal_balance)/principal_balance
|
|
|
|
| 608 |
if df.empty:
|
| 609 |
st.error("Oops! None of the data provided matches your selection(s). Please try again.")
|
| 610 |
else:
|
|
|
|
| 583 |
df['Balance used in Trade'] = np.concatenate([[principal_balance], df['New Balance'].values[:-1]])
|
| 584 |
df['Net P/L Per Trade'] = (df['Return Per Trade']-1)*df['Balance used in Trade']
|
| 585 |
df['Cumulative P/L'] = df['Net P/L Per Trade'].cumsum()
|
|
|
|
| 586 |
|
| 587 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 588 |
+
cum_pl = df.loc[df.drop('Drawdown %', axis=1).dropna().index[-1],'Cumulative P/L'] + principal_balance
|
| 589 |
+
else:
|
| 590 |
+
cum_pl = df.loc[df.dropna().index[-1],'Cumulative P/L'] + principal_balance
|
| 591 |
+
|
| 592 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
| 593 |
|
| 594 |
st.header(f"{bot_selections} Results")
|
|
|
|
| 598 |
f"${cum_pl:.2f}",
|
| 599 |
f"{100*(cum_pl-principal_balance)/(principal_balance):.2f} %",
|
| 600 |
)
|
| 601 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 602 |
+
st.line_chart(data=df.drop('Drawdown %', axis=1).dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
| 603 |
+
else:
|
| 604 |
+
st.line_chart(data=df.dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
| 605 |
|
| 606 |
df['Per Trade Return Rate'] = df['Return Per Trade']-1
|
| 607 |
|
| 608 |
totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
|
| 609 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 610 |
+
data = get_hist_info(df.drop('Drawdown %', axis=1).dropna(), principal_balance,'Per Trade Return Rate')
|
| 611 |
+
else:
|
| 612 |
+
data = get_hist_info(df.dropna(), principal_balance,'Per Trade Return Rate')
|
| 613 |
totals.loc[len(totals)] = list(i for i in data)
|
| 614 |
|
| 615 |
totals['Cum. P/L'] = cum_pl-principal_balance
|
| 616 |
totals['Cum. P/L (%)'] = 100*(cum_pl-principal_balance)/principal_balance
|
| 617 |
+
|
| 618 |
if df.empty:
|
| 619 |
st.error("Oops! None of the data provided matches your selection(s). Please try again.")
|
| 620 |
else:
|