Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,6 @@ from scipy.stats import norm
|
|
| 12 |
FMP_API_KEY = os.getenv("FMP_API_KEY")
|
| 13 |
|
| 14 |
# Define functions
|
| 15 |
-
|
| 16 |
def fetch_earnings_data(ticker, limit=99):
|
| 17 |
"""
|
| 18 |
Fetch earnings data from the Financial Modeling Prep API.
|
|
@@ -84,8 +83,8 @@ def plot_stock_price_with_earnings(stock_data, earnings_dates, ticker):
|
|
| 84 |
"""
|
| 85 |
fig = go.Figure()
|
| 86 |
fig.add_trace(go.Scatter(x=stock_data.index, y=stock_data['Close'], mode='lines', name='Stock Price', line=dict(color='blue')))
|
| 87 |
-
scaling_factor = 2
|
| 88 |
-
max_marker_size =
|
| 89 |
added_positive_legend = False
|
| 90 |
added_negative_legend = False
|
| 91 |
|
|
@@ -365,13 +364,13 @@ with st.sidebar.expander("Ticker and Date Selection", expanded=True):
|
|
| 365 |
with st.sidebar.expander("Analysis Parameters", expanded=True):
|
| 366 |
threshold_percentage = st.number_input("Threshold Percentage", value=0.10, min_value=0.01, max_value=1.0, step=0.01, help="Set the threshold for percentage changes in price analysis.")
|
| 367 |
buffer_days = st.number_input("Buffer Days", value=10, min_value=1, help="Set the number of buffer days around the earnings dates when fetching stock data.")
|
| 368 |
-
implied_volatility = st.number_input("Implied Volatility", value=0.30, min_value=0.01, max_value=1.0, step=0.01, help="Enter the implied volatility for the Monte Carlo simulation.")
|
| 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 (
|
|
|
|
|
|
|
| 375 |
|
| 376 |
if st.sidebar.button("Run Analysis"):
|
| 377 |
try:
|
|
|
|
| 12 |
FMP_API_KEY = os.getenv("FMP_API_KEY")
|
| 13 |
|
| 14 |
# Define functions
|
|
|
|
| 15 |
def fetch_earnings_data(ticker, limit=99):
|
| 16 |
"""
|
| 17 |
Fetch earnings data from the Financial Modeling Prep API.
|
|
|
|
| 83 |
"""
|
| 84 |
fig = go.Figure()
|
| 85 |
fig.add_trace(go.Scatter(x=stock_data.index, y=stock_data['Close'], mode='lines', name='Stock Price', line=dict(color='blue')))
|
| 86 |
+
scaling_factor = 1.2
|
| 87 |
+
max_marker_size = 30 # Limit the maximum marker size
|
| 88 |
added_positive_legend = False
|
| 89 |
added_negative_legend = False
|
| 90 |
|
|
|
|
| 364 |
with st.sidebar.expander("Analysis Parameters", expanded=True):
|
| 365 |
threshold_percentage = st.number_input("Threshold Percentage", value=0.10, min_value=0.01, max_value=1.0, step=0.01, help="Set the threshold for percentage changes in price analysis.")
|
| 366 |
buffer_days = st.number_input("Buffer Days", value=10, min_value=1, help="Set the number of buffer days around the earnings dates when fetching stock data.")
|
|
|
|
| 367 |
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.")
|
|
|
|
| 368 |
|
| 369 |
# Checkbox to run Monte Carlo simulations
|
| 370 |
with st.sidebar.expander("Monte Carlo Simulation", expanded=False):
|
| 371 |
+
run_simulation = st.checkbox("Run Monte Carlo Simulations (will take a few seconds)", value=False, help="Whether to run Monte Carlo Simulation Analysis. May slow down the app.")
|
| 372 |
+
implied_volatility = st.number_input("Implied Volatility", value=0.30, min_value=0.01, max_value=1.0, step=0.01, help="Enter the implied volatility for the Monte Carlo simulation.")
|
| 373 |
+
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.")
|
| 374 |
|
| 375 |
if st.sidebar.button("Run Analysis"):
|
| 376 |
try:
|