Spaces:
Build error
Build error
drawdown calc update
Browse files
app.py
CHANGED
|
@@ -295,7 +295,7 @@ def get_sd_df(sd_df, sd, bot_selections, dca1, dca2, dca3, dca4, dca5, dca6, fee
|
|
| 295 |
sd_df['Cumulative P/L (-)'] = sd_df['Net P/L Per Trade (-)'].cumsum()
|
| 296 |
return sd_df
|
| 297 |
|
| 298 |
-
def get_account_drawdown(trades):
|
| 299 |
max_draw = 0.0
|
| 300 |
beg = 0
|
| 301 |
fin = 0
|
|
@@ -308,9 +308,11 @@ def get_account_drawdown(trades):
|
|
| 308 |
max_draw = min(max_draw, delta.min())
|
| 309 |
beg = candidate
|
| 310 |
fin = delta.argmin()
|
|
|
|
| 311 |
except:
|
| 312 |
max_draw = min(max_draw, trades)
|
| 313 |
-
|
|
|
|
| 314 |
|
| 315 |
def runapp() -> None:
|
| 316 |
bot_selections = "Pure Bread"
|
|
@@ -409,7 +411,7 @@ def runapp() -> None:
|
|
| 409 |
df['Net P/L Per Trade'] = (df['Return Per Trade']-1)*df['Balance used in Trade']
|
| 410 |
df['Cumulative P/L'] = df['Net P/L Per Trade'].cumsum()
|
| 411 |
|
| 412 |
-
max_draw, (beg, fin) = get_account_drawdown(df['Cumulative P/L'])
|
| 413 |
cum_pl = df.loc[df.dropna().index[-1],'Cumulative P/L'] + principal_balance
|
| 414 |
|
| 415 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
|
@@ -559,7 +561,7 @@ def runapp() -> None:
|
|
| 559 |
st.metric(
|
| 560 |
"Max Account Drawdown",
|
| 561 |
"",#f"{np.round(100*max_draw/principal_balance,2)/100*principal_balance:.2f}",
|
| 562 |
-
f"{np.round(
|
| 563 |
)
|
| 564 |
|
| 565 |
if bot_selections == "Pumpernickel":
|
|
|
|
| 295 |
sd_df['Cumulative P/L (-)'] = sd_df['Net P/L Per Trade (-)'].cumsum()
|
| 296 |
return sd_df
|
| 297 |
|
| 298 |
+
def get_account_drawdown(trades, principal):
|
| 299 |
max_draw = 0.0
|
| 300 |
beg = 0
|
| 301 |
fin = 0
|
|
|
|
| 308 |
max_draw = min(max_draw, delta.min())
|
| 309 |
beg = candidate
|
| 310 |
fin = delta.argmin()
|
| 311 |
+
max_draw_perc = max_draw/(principal+trades[beg])
|
| 312 |
except:
|
| 313 |
max_draw = min(max_draw, trades)
|
| 314 |
+
max_draw_perc = max_draw/(principal_balance)
|
| 315 |
+
return 100*max_draw_perc, (beg, fin)
|
| 316 |
|
| 317 |
def runapp() -> None:
|
| 318 |
bot_selections = "Pure Bread"
|
|
|
|
| 411 |
df['Net P/L Per Trade'] = (df['Return Per Trade']-1)*df['Balance used in Trade']
|
| 412 |
df['Cumulative P/L'] = df['Net P/L Per Trade'].cumsum()
|
| 413 |
|
| 414 |
+
max_draw, (beg, fin) = get_account_drawdown(df['Cumulative P/L'], principal_balance)
|
| 415 |
cum_pl = df.loc[df.dropna().index[-1],'Cumulative P/L'] + principal_balance
|
| 416 |
|
| 417 |
effective_return = 100*((cum_pl - principal_balance)/principal_balance)
|
|
|
|
| 561 |
st.metric(
|
| 562 |
"Max Account Drawdown",
|
| 563 |
"",#f"{np.round(100*max_draw/principal_balance,2)/100*principal_balance:.2f}",
|
| 564 |
+
f"{np.round(max_draw)}%",
|
| 565 |
)
|
| 566 |
|
| 567 |
if bot_selections == "Pumpernickel":
|