pm6six commited on
Commit
3098af2
·
verified ·
1 Parent(s): da6bd62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -4,7 +4,6 @@ import matplotlib.pyplot as plt
4
  import io
5
  import gradio as gr
6
 
7
-
8
  def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
9
  try:
10
  df = yf.download(ticker, start=start_date, end=end_date, progress=False)
@@ -45,7 +44,7 @@ def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
45
  plt.plot(df['Portfolio Value'], label='Portfolio Value', color='purple')
46
  plt.xlabel('Date')
47
  plt.ylabel('Portfolio Value ($)')
48
- plt.title(f'Portfolio Value Over Time ({ticker})')
49
  plt.legend()
50
  plt.grid()
51
  plt.tight_layout()
@@ -70,10 +69,8 @@ def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
70
 
71
  return plot_file, results
72
 
73
-
74
  with gr.Blocks() as app:
75
- gr.Markdown("## SMA Crossover Trading Strategy Simulator")
76
-
77
  with gr.Row():
78
  initial_budget = gr.Number(label="Initial Investment ($)", value=100)
79
  start_date = gr.Text(label="Start Date (YYYY-MM-DD)", value="1993-01-01")
@@ -93,5 +90,6 @@ with gr.Blocks() as app:
93
  outputs=[portfolio_graph, summary_text],
94
  )
95
 
96
- app.launch()
 
97
 
 
4
  import io
5
  import gradio as gr
6
 
 
7
  def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
8
  try:
9
  df = yf.download(ticker, start=start_date, end=end_date, progress=False)
 
44
  plt.plot(df['Portfolio Value'], label='Portfolio Value', color='purple')
45
  plt.xlabel('Date')
46
  plt.ylabel('Portfolio Value ($)')
47
+ plt.title(f'Portfolio Value Over Time with SMA Strategy ({ticker})')
48
  plt.legend()
49
  plt.grid()
50
  plt.tight_layout()
 
69
 
70
  return plot_file, results
71
 
 
72
  with gr.Blocks() as app:
73
+ gr.Markdown("# SMA Crossover Strategy Simulator")
 
74
  with gr.Row():
75
  initial_budget = gr.Number(label="Initial Investment ($)", value=100)
76
  start_date = gr.Text(label="Start Date (YYYY-MM-DD)", value="1993-01-01")
 
90
  outputs=[portfolio_graph, summary_text],
91
  )
92
 
93
+ if __name__ == "__main__":
94
+ app.launch()
95