Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,7 +81,8 @@ def calculate_profit_loss(stock_data,days_to_monitor):
|
|
81 |
dft = pd.DataFrame(buy_sell_actions)
|
82 |
|
83 |
dff = pd.DataFrame(columns = ['+ve trade probability','Median returns','Mean returns','Best return','Worst return'])
|
84 |
-
|
|
|
85 |
dff['Mean returns'] = dft['Profit/Loss (%)'].mean()
|
86 |
dff['Median returns'] = dft['Profit/Loss (%)'].median()
|
87 |
dff['Best return'] = dft['Profit/Loss (%)'].max()
|
@@ -166,7 +167,7 @@ def save_to_csv(stock_input,rsi_window,days_to_monitor,previous_n_days,rsi_thres
|
|
166 |
# fstock['Date'] = pd.to_datetime(fstock['Date']).dt.date
|
167 |
# profit_data['Date'] = pd.to_datetime(profit_data['Date']).dt.date
|
168 |
|
169 |
-
return
|
170 |
|
171 |
# Create the Gradio interface
|
172 |
with gr.Blocks() as demo:
|
@@ -194,13 +195,13 @@ with gr.Blocks() as demo:
|
|
194 |
|
195 |
with gr.Column():
|
196 |
gr.Markdown("<h3 style='text-align: center;'>Output</h3>")
|
197 |
-
output_stock_data = gr.DataFrame(label="Dates where Conditions met", interactive=False)
|
198 |
output_pl_data = gr.DataFrame(label="Profit and Loss Statement", interactive=False)
|
199 |
output_summary_data = gr.DataFrame(label="Returns Summary", interactive=False)
|
200 |
csv_download = gr.File(label="Download the full CSV")
|
201 |
|
202 |
# When the button is clicked, show the two dataframes and provide a downloadable CSV
|
203 |
-
submit_button.click(save_to_csv, inputs=[stock_input,rsi_window_slider,days_to_monitor,previous_n_days,rsi_threshold1,rsi_threshold2], outputs=[
|
204 |
|
205 |
# Launch the Gradio interface
|
206 |
demo.launch()
|
|
|
81 |
dft = pd.DataFrame(buy_sell_actions)
|
82 |
|
83 |
dff = pd.DataFrame(columns = ['+ve trade probability','Median returns','Mean returns','Best return','Worst return'])
|
84 |
+
|
85 |
+
dff['+ve trade probability'] = len(dft[dft['Profit/Loss (%)'] > 0]) / len(dft)
|
86 |
dff['Mean returns'] = dft['Profit/Loss (%)'].mean()
|
87 |
dff['Median returns'] = dft['Profit/Loss (%)'].median()
|
88 |
dff['Best return'] = dft['Profit/Loss (%)'].max()
|
|
|
167 |
# fstock['Date'] = pd.to_datetime(fstock['Date']).dt.date
|
168 |
# profit_data['Date'] = pd.to_datetime(profit_data['Date']).dt.date
|
169 |
|
170 |
+
return profit_data, summary_data, csv_file_path
|
171 |
|
172 |
# Create the Gradio interface
|
173 |
with gr.Blocks() as demo:
|
|
|
195 |
|
196 |
with gr.Column():
|
197 |
gr.Markdown("<h3 style='text-align: center;'>Output</h3>")
|
198 |
+
# output_stock_data = gr.DataFrame(label="Dates where Conditions met", interactive=False)
|
199 |
output_pl_data = gr.DataFrame(label="Profit and Loss Statement", interactive=False)
|
200 |
output_summary_data = gr.DataFrame(label="Returns Summary", interactive=False)
|
201 |
csv_download = gr.File(label="Download the full CSV")
|
202 |
|
203 |
# When the button is clicked, show the two dataframes and provide a downloadable CSV
|
204 |
+
submit_button.click(save_to_csv, inputs=[stock_input,rsi_window_slider,days_to_monitor,previous_n_days,rsi_threshold1,rsi_threshold2], outputs=[output_pl_data, output_summary_data,csv_download])
|
205 |
|
206 |
# Launch the Gradio interface
|
207 |
demo.launch()
|