anaucoin commited on
Commit
a4f78f7
·
1 Parent(s): 3487cf6

beta feedback changes pt 1

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -130,11 +130,17 @@ def get_hist_info(df_coin, principal_balance,plheader):
130
  numtrades = int(len(df_coin))
131
  numwin = int(sum(df_coin[plheader] > 0))
132
  numloss = int(sum(df_coin[plheader] < 0))
133
- winrate = int(np.round(100*numwin/numtrades,2))
 
 
 
134
 
135
  grosswin = sum(df_coin[df_coin[plheader] > 0][plheader])
136
  grossloss = sum(df_coin[df_coin[plheader] < 0][plheader])
137
- pfactor = -1*np.round(grosswin/grossloss,2)
 
 
 
138
  return numtrades, numwin, numloss, winrate, pfactor
139
 
140
  @st.experimental_memo
@@ -385,6 +391,8 @@ def runapp() -> None:
385
 
386
  start = df.iloc[0][dateheader] if (not startdate) else startdate
387
  stop = df.iloc[len(df)-1][dateheader] if (not enddate) else enddate
 
 
388
 
389
  results_df = pd.DataFrame([], columns = ['Coin', '# of Trades', 'Wins', 'Losses', 'Win Rate',
390
  'Profit Factor', 'Cum. P/L', 'Cum. P/L (%)', 'Avg. P/L', 'Avg. P/L (%)'])
 
130
  numtrades = int(len(df_coin))
131
  numwin = int(sum(df_coin[plheader] > 0))
132
  numloss = int(sum(df_coin[plheader] < 0))
133
+ if numtrades != 0:
134
+ winrate = int(np.round(100*numwin/numtrades,2))
135
+ else:
136
+ winrate = np.nan
137
 
138
  grosswin = sum(df_coin[df_coin[plheader] > 0][plheader])
139
  grossloss = sum(df_coin[df_coin[plheader] < 0][plheader])
140
+ if grossloss != 0:
141
+ pfactor = -1*np.round(grosswin/grossloss,2)
142
+ else:
143
+ pfactor = np.nan
144
  return numtrades, numwin, numloss, winrate, pfactor
145
 
146
  @st.experimental_memo
 
391
 
392
  start = df.iloc[0][dateheader] if (not startdate) else startdate
393
  stop = df.iloc[len(df)-1][dateheader] if (not enddate) else enddate
394
+
395
+ df = df[(df[dateheader] >= start) & (df[dateheader] <= stop)]
396
 
397
  results_df = pd.DataFrame([], columns = ['Coin', '# of Trades', 'Wins', 'Losses', 'Win Rate',
398
  'Profit Factor', 'Cum. P/L', 'Cum. P/L (%)', 'Avg. P/L', 'Avg. P/L (%)'])