eaglelandsonce commited on
Commit
f727e0f
1 Parent(s): de00c34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py CHANGED
@@ -320,7 +320,51 @@ bot_inputs = [
320
  ]
321
 
322
 
 
 
323
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  with gr.Tab("Company Analysis"):
325
  gr.HTML(TITLE1)
326
 
 
320
  ]
321
 
322
 
323
+ # Interface =============================================
324
+
325
  with gr.Blocks() as demo:
326
+ with gr.Tab("Portfolio Analysis"):
327
+ with gr.Blocks() as app:
328
+ with gr.Row():
329
+ gr.HTML("<h1>Bohmian's Stock Portfolio Optimizer</h1>")
330
+
331
+ with gr.Row():
332
+ start_date = gr.Textbox("2013-01-01", label="Start Date")
333
+ end_date = gr.Textbox(datetime.datetime.now().date(), label="End Date")
334
+
335
+ with gr.Row():
336
+ tickers_string = gr.Textbox("MA,META,V,AMZN,JPM,BA",
337
+ label='Enter all stock tickers to be included in portfolio separated \
338
+ by commas WITHOUT spaces, e.g. "MA,META,V,AMZN,JPM,BA"')
339
+ btn = gr.Button("Get Optimized Portfolio")
340
+
341
+ with gr.Row():
342
+ gr.HTML("<h3>Optimizied Portfolio Metrics</h3>")
343
+
344
+ with gr.Row():
345
+ expected_annual_return = gr.Text(label="Expected Annual Return")
346
+ annual_volatility = gr.Text(label="Annual Volatility")
347
+ sharpe_ratio = gr.Text(label="Sharpe Ratio")
348
+
349
+ with gr.Row():
350
+ fig_cum_returns_optimized = gr.Plot(label="Cumulative Returns of Optimized Portfolio (Starting Price of $100)")
351
+ weights_df = gr.DataFrame(label="Optimized Weights of Each Ticker")
352
+
353
+ with gr.Row():
354
+ fig_efficient_frontier = gr.Plot(label="Efficient Frontier")
355
+ fig_corr = gr.Plot(label="Correlation between Stocks")
356
+
357
+ with gr.Row():
358
+ fig_indiv_prices = gr.Plot(label="Price of Individual Stocks")
359
+ fig_cum_returns = gr.Plot(label="Cumulative Returns of Individual Stocks Starting with $100")
360
+
361
+ btn.click(fn=output_results, inputs=[start_date, end_date, tickers_string],
362
+ outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
363
+ expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
364
+
365
+
366
+
367
+
368
  with gr.Tab("Company Analysis"):
369
  gr.HTML(TITLE1)
370