Spaces:
Runtime error
Runtime error
anaucoin commited on
Commit ·
28a8802
1
Parent(s): d562cbd
update to include PB
Browse files
app.py
CHANGED
|
@@ -167,6 +167,8 @@ def cc_coding(row):
|
|
| 167 |
return ['background-color: lightgrey'] * len(row) if row['Exit Date'] <= datetime.strptime('2022-12-16 00:00:00','%Y-%m-%d %H:%M:%S').date() else [''] * len(row)
|
| 168 |
def ctt_coding(row):
|
| 169 |
return ['background-color: lightgrey'] * len(row) if row['Exit Date'] <= datetime.strptime('2023-01-02 00:00:00','%Y-%m-%d %H:%M:%S').date() else [''] * len(row)
|
|
|
|
|
|
|
| 170 |
|
| 171 |
@st.experimental_memo
|
| 172 |
def my_style(v, props=''):
|
|
@@ -231,7 +233,7 @@ def load_data(filename, otimeheader, fmat):
|
|
| 231 |
if filename == "CT-Trade-Log.csv":
|
| 232 |
df.columns = ['Trade','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %', 'Drawdown %']
|
| 233 |
df.insert(1, 'Signal', ['Long']*len(df))
|
| 234 |
-
elif filename == "CC-Trade-Log.csv":
|
| 235 |
df.columns = ['Trade','Signal','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %', 'Drawdown %']
|
| 236 |
else:
|
| 237 |
df.columns = ['Trade','Signal','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %']
|
|
@@ -608,7 +610,7 @@ def runapp() -> None:
|
|
| 608 |
|
| 609 |
if logtype == "BreadBytes Historical Logs" and no_errors:
|
| 610 |
|
| 611 |
-
bots = ["Cinnamon Toast", "Short Bread", "Cosmic Cupcake"
|
| 612 |
bot_selections = st.selectbox("Select your Trading Bot", options=bots)
|
| 613 |
otimeheader = 'Exit Date'
|
| 614 |
fmat = '%Y-%m-%d %H:%M:%S'
|
|
@@ -630,10 +632,10 @@ def runapp() -> None:
|
|
| 630 |
lev_cap = 3
|
| 631 |
dollar_cap = 1000000000.00
|
| 632 |
data = load_data("CC-Trade-Log.csv",otimeheader, fmat)
|
| 633 |
-
if bot_selections == "
|
| 634 |
-
lev_cap =
|
| 635 |
dollar_cap = 1000000000.00
|
| 636 |
-
data = load_data("
|
| 637 |
|
| 638 |
df = data.copy(deep=True)
|
| 639 |
|
|
@@ -773,7 +775,7 @@ def runapp() -> None:
|
|
| 773 |
# f"" ,#${cum_sdm:.2f}"
|
| 774 |
# f"{100*(cum_sdm-principal_balance)/(principal_balance):.2f} %",
|
| 775 |
# )
|
| 776 |
-
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 777 |
#st.line_chart(data=df.drop('Drawdown %', axis=1).dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
| 778 |
dfdata = df.drop('Drawdown %', axis=1).dropna()
|
| 779 |
#sd_df = sd_df.drop('Drawdown %', axis=1).dropna()
|
|
@@ -838,7 +840,7 @@ def runapp() -> None:
|
|
| 838 |
df['Per Trade Return Rate'] = df['Return Per Trade']-1
|
| 839 |
|
| 840 |
totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
|
| 841 |
-
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
|
| 842 |
data = get_hist_info(df.drop('Drawdown %', axis=1).dropna(), principal_balance,'Per Trade Return Rate')
|
| 843 |
else:
|
| 844 |
data = get_hist_info(df.dropna(), principal_balance,'Per Trade Return Rate')
|
|
@@ -964,6 +966,10 @@ def runapp() -> None:
|
|
| 964 |
.applymap(my_style,subset=['P/L %']), use_container_width=True)
|
| 965 |
new_title = '<div style="text-align: right;"><span style="background-color:lightgrey;"> </span> Not Live Traded</div>'
|
| 966 |
st.markdown(new_title, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
else:
|
| 968 |
st.dataframe(grouped_df.style.format({'Entry Date':'{:%m-%d-%Y %H:%M:%S}','Exit Date':'{:%m-%d-%Y %H:%M:%S}','Avg. Buy Price': '${:.2f}', 'Sell Price': '${:.2f}', 'Net P/L':'${:.2f}', 'P/L %':'{:.2f}%'})\
|
| 969 |
.applymap(my_style,subset=['Net P/L'])\
|
|
|
|
| 167 |
return ['background-color: lightgrey'] * len(row) if row['Exit Date'] <= datetime.strptime('2022-12-16 00:00:00','%Y-%m-%d %H:%M:%S').date() else [''] * len(row)
|
| 168 |
def ctt_coding(row):
|
| 169 |
return ['background-color: lightgrey'] * len(row) if row['Exit Date'] <= datetime.strptime('2023-01-02 00:00:00','%Y-%m-%d %H:%M:%S').date() else [''] * len(row)
|
| 170 |
+
def conditional_formatter(value):
|
| 171 |
+
return "${:.2f}".format(value) if not (abs(value) < 1.00) else "${:.4f}".format(value)
|
| 172 |
|
| 173 |
@st.experimental_memo
|
| 174 |
def my_style(v, props=''):
|
|
|
|
| 233 |
if filename == "CT-Trade-Log.csv":
|
| 234 |
df.columns = ['Trade','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %', 'Drawdown %']
|
| 235 |
df.insert(1, 'Signal', ['Long']*len(df))
|
| 236 |
+
elif filename == "CC-Trade-Log.csv" or filename == "PB-Trade-Log.csv":
|
| 237 |
df.columns = ['Trade','Signal','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %', 'Drawdown %']
|
| 238 |
else:
|
| 239 |
df.columns = ['Trade','Signal','Entry Date','Buy Price', 'Sell Price','Exit Date', 'P/L per token', 'P/L %']
|
|
|
|
| 610 |
|
| 611 |
if logtype == "BreadBytes Historical Logs" and no_errors:
|
| 612 |
|
| 613 |
+
bots = ["Cinnamon Toast", "Short Bread", "Cosmic Cupcake", "Pure Bread"]
|
| 614 |
bot_selections = st.selectbox("Select your Trading Bot", options=bots)
|
| 615 |
otimeheader = 'Exit Date'
|
| 616 |
fmat = '%Y-%m-%d %H:%M:%S'
|
|
|
|
| 632 |
lev_cap = 3
|
| 633 |
dollar_cap = 1000000000.00
|
| 634 |
data = load_data("CC-Trade-Log.csv",otimeheader, fmat)
|
| 635 |
+
if bot_selections == "Pure Bread":
|
| 636 |
+
lev_cap = 3
|
| 637 |
dollar_cap = 1000000000.00
|
| 638 |
+
data = load_data("PB-Trade-Log.csv",otimeheader, fmat)
|
| 639 |
|
| 640 |
df = data.copy(deep=True)
|
| 641 |
|
|
|
|
| 775 |
# f"" ,#${cum_sdm:.2f}"
|
| 776 |
# f"{100*(cum_sdm-principal_balance)/(principal_balance):.2f} %",
|
| 777 |
# )
|
| 778 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake" or bot_selections == "Pure Bread":
|
| 779 |
#st.line_chart(data=df.drop('Drawdown %', axis=1).dropna(), x='Exit Date', y='Cumulative P/L', use_container_width=True)
|
| 780 |
dfdata = df.drop('Drawdown %', axis=1).dropna()
|
| 781 |
#sd_df = sd_df.drop('Drawdown %', axis=1).dropna()
|
|
|
|
| 840 |
df['Per Trade Return Rate'] = df['Return Per Trade']-1
|
| 841 |
|
| 842 |
totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
|
| 843 |
+
if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake" or bot_selections == "Pure Bread":
|
| 844 |
data = get_hist_info(df.drop('Drawdown %', axis=1).dropna(), principal_balance,'Per Trade Return Rate')
|
| 845 |
else:
|
| 846 |
data = get_hist_info(df.dropna(), principal_balance,'Per Trade Return Rate')
|
|
|
|
| 966 |
.applymap(my_style,subset=['P/L %']), use_container_width=True)
|
| 967 |
new_title = '<div style="text-align: right;"><span style="background-color:lightgrey;"> </span> Not Live Traded</div>'
|
| 968 |
st.markdown(new_title, unsafe_allow_html=True)
|
| 969 |
+
elif bot_selections == "Pure Bread":
|
| 970 |
+
st.dataframe(grouped_df.style.format({'Entry Date':'{:%m-%d-%Y %H:%M:%S}','Exit Date':'{:%m-%d-%Y %H:%M:%S}','Avg. Buy Price': '${:.4f}', 'Sell Price': '${:.4f}', 'Net P/L': conditional_formatter, 'P/L %':'{:.2f}%'})\
|
| 971 |
+
.applymap(my_style,subset=['Net P/L'])\
|
| 972 |
+
.applymap(my_style,subset=['P/L %']), use_container_width=True)
|
| 973 |
else:
|
| 974 |
st.dataframe(grouped_df.style.format({'Entry Date':'{:%m-%d-%Y %H:%M:%S}','Exit Date':'{:%m-%d-%Y %H:%M:%S}','Avg. Buy Price': '${:.2f}', 'Sell Price': '${:.2f}', 'Net P/L':'${:.2f}', 'P/L %':'{:.2f}%'})\
|
| 975 |
.applymap(my_style,subset=['Net P/L'])\
|