alexaxbreadbytes commited on
Commit
e638ad4
·
verified ·
1 Parent(s): cc57d1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -86
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
- if submitted:
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,81 +565,80 @@ def runapp() -> None:
565
  )
566
 
567
  st.plotly_chart(fig, theme=None, use_container_width=True,height=600)
568
- if submitted:
569
- st.write()
570
- df['Per Trade Return Rate'] = df['Return Per Trade']-1
571
-
572
- totals = pd.DataFrame([], columns = ['# of Trades', 'Wins', 'Losses', 'Win Rate', 'Profit Factor'])
573
- if bot_selections == "Cinnamon Toast" or bot_selections == "Cosmic Cupcake":
574
- data = get_hist_info(df.drop('Drawdown %', axis=1).dropna(), principal_balance,'Per Trade Return Rate')
575
- else:
576
- data = get_hist_info(df.dropna(), principal_balance,'Per Trade Return Rate')
577
- totals.loc[len(totals)] = list(i for i in data)
578
-
579
- totals['Cum. P/L'] = cum_pl-principal_balance
580
- totals['Cum. P/L (%)'] = 100*(cum_pl-principal_balance)/principal_balance
581
-
582
- if df.empty:
583
- st.error("Oops! None of the data provided matches your selection(s). Please try again.")
584
- else:
585
- with st.container():
586
- for row in totals.itertuples():
587
- col1, col2, col3, col4= st.columns(4)
588
- c1, c2, c3, c4 = st.columns(4)
589
- with col1:
590
- st.metric(
591
- "Total Trades",
592
- f"{row._1:.0f}",
593
- )
594
- with c1:
595
- st.metric(
596
- "Profit Factor",
597
- f"{row._5:.2f}",
598
- )
599
- with col2:
600
- st.metric(
601
- "Wins",
602
- f"{row.Wins:.0f}",
603
- )
604
- with c2:
605
- st.metric(
606
- "Cumulative P/L",
607
- f"${row._6:.2f}",
608
- f"{row._7:.2f} %",
609
- )
610
- with col3:
611
- st.metric(
612
- "Losses",
613
- f"{row.Losses:.0f}",
614
- )
615
- with c3:
616
- st.metric(
617
- "Rolling 7 Days",
618
- "",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
619
- f"{get_rolling_stats(df,lev, otimeheader, 7):.2f}%",
620
- )
621
- st.metric(
622
- "Rolling 30 Days",
623
- "",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
624
- f"{get_rolling_stats(df,lev, otimeheader, 30):.2f}%",
625
- )
626
-
627
- with col4:
628
- st.metric(
629
- "Win Rate",
630
- f"{row._4:.1f}%",
631
- )
632
- with c4:
633
- st.metric(
634
- "Rolling 90 Days",
635
- "",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
636
- f"{get_rolling_stats(df,lev, otimeheader, 90):.2f}%",
637
- )
638
- st.metric(
639
- "Rolling 180 Days",
640
- "",#f"{(1+get_rolling_stats(df,otimeheader, 30))*principal_balance:.2f}",
641
- f"{get_rolling_stats(df,lev, otimeheader, 180):.2f}%",
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: