pm6six commited on
Commit
5552733
·
verified ·
1 Parent(s): 73058b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -5,20 +5,14 @@ import matplotlib.pyplot as plt
5
  import io
6
  import gradio as gr
7
 
8
- def greet(name):
9
- return f"Hello, {name}!"
10
-
11
- app = gr.Interface(fn=greet, inputs="text", outputs="text")
12
- app.launch()
13
-
14
 
15
  def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
16
  try:
17
  df = yf.download(ticker, start=start_date, end=end_date, progress=False)
18
  if df.empty:
19
- return None, "No data available for the specified ticker and date range.", None
20
  except Exception as e:
21
- return None, f"Error fetching data: {str(e)}", None
22
 
23
  df = df[['Close']]
24
  df['SMA_50'] = df['Close'].rolling(window=50).mean()
@@ -75,7 +69,8 @@ def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
75
  Percentage Return: {percentage_return:.2f}%
76
  """
77
 
78
- return plot_file, results, None
 
79
 
80
  with gr.Blocks() as app:
81
  gr.Markdown("# SMA Crossover Trading Strategy Simulator")
@@ -101,4 +96,3 @@ with gr.Blocks() as app:
101
 
102
  app.launch()
103
 
104
-
 
5
  import io
6
  import gradio as gr
7
 
 
 
 
 
 
 
8
 
9
  def sma_crossover_strategy(initial_budget, start_date, end_date, ticker):
10
  try:
11
  df = yf.download(ticker, start=start_date, end=end_date, progress=False)
12
  if df.empty:
13
+ return None, "No data available for the specified ticker and date range."
14
  except Exception as e:
15
+ return None, f"Error fetching data: {str(e)}"
16
 
17
  df = df[['Close']]
18
  df['SMA_50'] = df['Close'].rolling(window=50).mean()
 
69
  Percentage Return: {percentage_return:.2f}%
70
  """
71
 
72
+ return plot_file, results
73
+
74
 
75
  with gr.Blocks() as app:
76
  gr.Markdown("# SMA Crossover Trading Strategy Simulator")
 
96
 
97
  app.launch()
98