eaglelandsonce
commited on
Commit
•
eb13913
1
Parent(s):
fd33898
Update app.py
Browse files
app.py
CHANGED
@@ -608,6 +608,11 @@ def output_results(start_date, end_date, tickers_string):
|
|
608 |
return fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
609 |
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns
|
610 |
|
|
|
|
|
|
|
|
|
|
|
611 |
|
612 |
# Interface =============================================
|
613 |
|
@@ -626,22 +631,27 @@ with gr.Blocks() as demo:
|
|
626 |
with gr.Tab("Step 2: Optimize Portfolio"):
|
627 |
gr.HTML(STEP3_TITLE)
|
628 |
with gr.Blocks() as app:
|
629 |
-
|
630 |
-
btn1 = gr.Button("Button 1")
|
631 |
-
btn2 = gr.Button("Button 2")
|
632 |
-
btn3 = gr.Button("Button 3")
|
633 |
-
btn4 = gr.Button("Button 4")
|
634 |
with gr.Row():
|
635 |
gr.HTML("<h1>Stock Portfolio Optimizer</h1>")
|
636 |
|
637 |
with gr.Row():
|
638 |
start_date = gr.Textbox("2013-01-01", label="Start Date")
|
639 |
end_date = gr.Textbox(datetime.datetime.now().date(), label="End Date")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
|
641 |
with gr.Row():
|
642 |
tickers_string = gr.Textbox("AAPL,AMZN,TSLA,NVDA,GOOGL,MSFT,NFLX,V,MA,CRM",
|
643 |
label='Enter all stock tickers to be included in portfolio separated \
|
644 |
by commas WITHOUT spaces, e.g. "AAPL,AMZN,TSLA,NVDA,GOOGL,MSFT,NFLX,V,MA,CRM"')
|
|
|
645 |
btn = gr.Button("Get Optimized Portfolio")
|
646 |
|
647 |
with gr.Row():
|
@@ -664,10 +674,28 @@ with gr.Blocks() as demo:
|
|
664 |
fig_indiv_prices = gr.Plot(label="Price of Individual Stocks")
|
665 |
fig_cum_returns = gr.Plot(label="Cumulative Returns of Individual Stocks Starting with $100")
|
666 |
|
667 |
-
btn.click(fn=output_results, inputs=[start_date, end_date,
|
668 |
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
669 |
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
670 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
with gr.Tab("Step 3: Financial Outlook"):
|
672 |
gr.HTML(STEP2_TITLE)
|
673 |
run_button_crewai = gr.Button(value="Run", variant="primary", scale=1)
|
|
|
608 |
return fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
609 |
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns
|
610 |
|
611 |
+
ticker_string_concervative = "KO,PG,JNJ,VZ,PFE,MCD,WMT,MMM,SO,DUK"
|
612 |
+
ticker_string_growth = "AAPL,AMZN,TSLA,NVDA,GOOGL,MSFT,NFLX,V,MA,CRM"
|
613 |
+
ticker_string_balanced = "AAPL,JPM,JNJ,PG,KO,MSFT,PFE,VZ,MMM,WMT"
|
614 |
+
ticker_string_agressive = "TSLA,AMZN,NVDA,GOOGL,SHOP,SQ,MRNA,ZM,SNOW,PTON"
|
615 |
+
|
616 |
|
617 |
# Interface =============================================
|
618 |
|
|
|
631 |
with gr.Tab("Step 2: Optimize Portfolio"):
|
632 |
gr.HTML(STEP3_TITLE)
|
633 |
with gr.Blocks() as app:
|
634 |
+
|
|
|
|
|
|
|
|
|
635 |
with gr.Row():
|
636 |
gr.HTML("<h1>Stock Portfolio Optimizer</h1>")
|
637 |
|
638 |
with gr.Row():
|
639 |
start_date = gr.Textbox("2013-01-01", label="Start Date")
|
640 |
end_date = gr.Textbox(datetime.datetime.now().date(), label="End Date")
|
641 |
+
with gr.Row():
|
642 |
+
gr.HTML("<h1>Example Portfolios</h1>")
|
643 |
+
btn1 = gr.Button("Concervative")
|
644 |
+
btn2 = gr.Button("Growth")
|
645 |
+
btn3 = gr.Button("Balanced")
|
646 |
+
btn4 = gr.Button("Agressive")
|
647 |
+
|
648 |
+
|
649 |
|
650 |
with gr.Row():
|
651 |
tickers_string = gr.Textbox("AAPL,AMZN,TSLA,NVDA,GOOGL,MSFT,NFLX,V,MA,CRM",
|
652 |
label='Enter all stock tickers to be included in portfolio separated \
|
653 |
by commas WITHOUT spaces, e.g. "AAPL,AMZN,TSLA,NVDA,GOOGL,MSFT,NFLX,V,MA,CRM"')
|
654 |
+
with gr.Row():
|
655 |
btn = gr.Button("Get Optimized Portfolio")
|
656 |
|
657 |
with gr.Row():
|
|
|
674 |
fig_indiv_prices = gr.Plot(label="Price of Individual Stocks")
|
675 |
fig_cum_returns = gr.Plot(label="Cumulative Returns of Individual Stocks Starting with $100")
|
676 |
|
677 |
+
btn.click(fn=output_results, inputs=[start_date, end_date, ticker_string],
|
678 |
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
679 |
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
680 |
|
681 |
+
btn1.click(fn=output_results, inputs=[start_date, end_date, ticker_string_concervative],
|
682 |
+
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
683 |
+
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
684 |
+
|
685 |
+
btn2.click(fn=output_results, inputs=[start_date, end_date, ticker_string_growth],
|
686 |
+
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
687 |
+
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
688 |
+
|
689 |
+
btn3.click(fn=output_results, inputs=[start_date, end_date, ticker_string_balanced],
|
690 |
+
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
691 |
+
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
692 |
+
|
693 |
+
btn4.click(fn=output_results, inputs=[start_date, end_date, ticker_string_agressive],
|
694 |
+
outputs=[fig_cum_returns_optimized, weights_df, fig_efficient_frontier, fig_corr, \
|
695 |
+
expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns])
|
696 |
+
|
697 |
+
|
698 |
+
|
699 |
with gr.Tab("Step 3: Financial Outlook"):
|
700 |
gr.HTML(STEP2_TITLE)
|
701 |
run_button_crewai = gr.Button(value="Run", variant="primary", scale=1)
|