QuantumLearner commited on
Commit
229a91e
·
verified ·
1 Parent(s): 6a980fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -351,7 +351,8 @@ with st.sidebar.expander("How to Use", expanded=False):
351
  4. Configure buffer days for fetching stock data.
352
  5. Enter the implied volatility and days until earnings for Monte Carlo simulation.
353
  6. Set the number of simulations for more precise results.
354
- 7. Click the "Run Analysis" button to start the analysis.
 
355
  """)
356
 
357
  # Ticker and date inputs inside an expander, open by default
@@ -368,6 +369,10 @@ with st.sidebar.expander("Analysis Parameters", expanded=True):
368
  days_until_earnings = st.number_input("Days Until Earnings", value=10, min_value=1, help="Enter the number of days until the earnings announcement for the Monte Carlo simulation.")
369
  num_simulations = st.number_input("Number of Simulations for Monte Carlo", value=10000, min_value=100, help="Set the number of simulations for the Monte Carlo analysis.")
370
 
 
 
 
 
371
  if st.sidebar.button("Run Analysis"):
372
  try:
373
  if not FMP_API_KEY:
@@ -440,12 +445,13 @@ if st.sidebar.button("Run Analysis"):
440
  st.markdown("This scatter plot shows the relationship between earnings surprise percentages and the resulting price effects.")
441
  st.plotly_chart(plot_surprise_vs_price_effect(earnings_dates), use_container_width=True)
442
 
443
- up_target = latest_close_price * upper_threshold
444
- down_target = latest_close_price * lower_threshold
 
445
 
446
- st.subheader("Monte Carlo Simulation for Price Movements")
447
- st.markdown("We simulate multiple price paths using the stock's implied volatility to estimate the probabilities of the stock price reaching given targets.")
448
- st.plotly_chart(monte_carlo_simulation(ticker, implied_volatility, days_until_earnings, up_target, down_target, stock_data, num_simulations), use_container_width=True)
449
 
450
  except Exception as e:
451
  st.error(f"An error occurred while running the analysis: {e}")
 
351
  4. Configure buffer days for fetching stock data.
352
  5. Enter the implied volatility and days until earnings for Monte Carlo simulation.
353
  6. Set the number of simulations for more precise results.
354
+ 7. Check the box if you wish to run the Monte Carlo simulations (may slow down the app).
355
+ 8. Click the "Run Analysis" button to start the analysis.
356
  """)
357
 
358
  # Ticker and date inputs inside an expander, open by default
 
369
  days_until_earnings = st.number_input("Days Until Earnings", value=10, min_value=1, help="Enter the number of days until the earnings announcement for the Monte Carlo simulation.")
370
  num_simulations = st.number_input("Number of Simulations for Monte Carlo", value=10000, min_value=100, help="Set the number of simulations for the Monte Carlo analysis.")
371
 
372
+ # Checkbox to run Monte Carlo simulations
373
+ with st.sidebar.expander("Monte Carlo Simulation", expanded=False):
374
+ run_simulation = st.checkbox("Run Monte Carlo Simulations (may slow down the app)", value=False)
375
+
376
  if st.sidebar.button("Run Analysis"):
377
  try:
378
  if not FMP_API_KEY:
 
445
  st.markdown("This scatter plot shows the relationship between earnings surprise percentages and the resulting price effects.")
446
  st.plotly_chart(plot_surprise_vs_price_effect(earnings_dates), use_container_width=True)
447
 
448
+ if run_simulation:
449
+ up_target = latest_close_price * upper_threshold
450
+ down_target = latest_close_price * lower_threshold
451
 
452
+ st.subheader("Monte Carlo Simulation for Price Movements")
453
+ st.markdown("We simulate multiple price paths using the stock's implied volatility to estimate the probabilities of the stock price reaching given targets.")
454
+ st.plotly_chart(monte_carlo_simulation(ticker, implied_volatility, days_until_earnings, up_target, down_target, stock_data, num_simulations), use_container_width=True)
455
 
456
  except Exception as e:
457
  st.error(f"An error occurred while running the analysis: {e}")