Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,12 +13,10 @@ st.set_page_config(layout="wide")
|
|
| 13 |
st.sidebar.title("Input Parameters")
|
| 14 |
|
| 15 |
with st.sidebar.expander("How to Use", expanded=False):
|
| 16 |
-
st.markdown("""
|
| 17 |
-
1. **Input Ticker Symbol**: Enter the stock ticker symbol in the sidebar (e.g., `AAPL` for Apple Inc.).
|
| 18 |
-
2. **Analyze**: Click the "Analyze" button to fetch and process the options data.
|
| 19 |
-
3. **Visualize**: View the visualizations and interpretations of the options data to understand market sentiment.
|
| 20 |
-
### Understanding Implied Volatility:
|
| 21 |
-
Implied volatility is derived from the market price of an option. It reflects the market's view of the likelihood of changes in a given security's price. Higher implied volatility means the market expects the stock to have large price swings (either up or down). Here’s a simplified representation of how implied volatility is calculated.
|
| 22 |
""")
|
| 23 |
|
| 24 |
st.title("Options Sentiment Analysis Tool")
|
|
@@ -694,25 +692,25 @@ with st.sidebar.expander("Input Parameters", expanded=True):
|
|
| 694 |
if st.sidebar.button("Run Analysis"):
|
| 695 |
options_data, recent_price = get_options_data(ticker)
|
| 696 |
if options_data is not None:
|
| 697 |
-
st.subheader("
|
| 698 |
overall_avg_iv_calls, overall_avg_iv_puts, avg_iv_by_strike_calls, avg_iv_by_strike_puts, expirations = plot_volatility_smile(options_data, recent_price, ticker)
|
| 699 |
|
| 700 |
with st.expander("Volatility Smile Interpretation", expanded=False):
|
| 701 |
interpret_volatility_smile(ticker, overall_avg_iv_calls, overall_avg_iv_puts, avg_iv_by_strike_calls, avg_iv_by_strike_puts)
|
| 702 |
|
| 703 |
-
st.subheader("
|
| 704 |
overall_avg_oi_calls, overall_avg_oi_puts, calls_data, puts_data = plot_open_interest(options_data, recent_price, ticker)
|
| 705 |
|
| 706 |
with st.expander("Open Interest Interpretation", expanded=False):
|
| 707 |
interpret_open_interest(ticker, overall_avg_oi_calls, overall_avg_oi_puts, calls_data, puts_data)
|
| 708 |
|
| 709 |
-
st.subheader("
|
| 710 |
overall_avg_vol_calls, overall_avg_vol_puts, calls_data, puts_data = plot_volume(options_data, recent_price, ticker)
|
| 711 |
|
| 712 |
with st.expander("Volume Analysis Interpretation", expanded=False):
|
| 713 |
interpret_volume(ticker, overall_avg_vol_calls, overall_avg_vol_puts, calls_data, puts_data)
|
| 714 |
|
| 715 |
-
st.subheader("
|
| 716 |
col1, col2 = st.columns(2)
|
| 717 |
with col1:
|
| 718 |
st.markdown("### Puts")
|
|
@@ -734,19 +732,19 @@ if st.sidebar.button("Run Analysis"):
|
|
| 734 |
with st.expander("Historical IV Interpretation", expanded=False):
|
| 735 |
interpret_historical_iv(ticker, historical_iv, current_iv)
|
| 736 |
|
| 737 |
-
st.subheader("
|
| 738 |
total_puts, total_calls, put_call_ratio = calculate_put_call_ratio(options_data)
|
| 739 |
|
| 740 |
with st.expander("Put to Call Ratio Interpretation", expanded=False):
|
| 741 |
interpret_put_call_ratio(ticker, total_puts, total_calls, put_call_ratio)
|
| 742 |
|
| 743 |
-
st.subheader("
|
| 744 |
calls_data, puts_data = plot_greeks(options_data, recent_price, ticker)
|
| 745 |
|
| 746 |
with st.expander("Greeks Analysis Interpretation", expanded=False):
|
| 747 |
interpret_greeks(ticker, calls_data, puts_data)
|
| 748 |
|
| 749 |
-
st.subheader("
|
| 750 |
high_iv_calls = overall_avg_iv_calls
|
| 751 |
low_iv_puts = overall_avg_iv_puts
|
| 752 |
sentiment_score, sentiment_description = calculate_sentiment_score(options_data, high_iv_calls, low_iv_puts, total_calls, total_puts)
|
|
|
|
| 13 |
st.sidebar.title("Input Parameters")
|
| 14 |
|
| 15 |
with st.sidebar.expander("How to Use", expanded=False):
|
| 16 |
+
st.markdown("""
|
| 17 |
+
- 1. **Input Ticker Symbol**: Enter the stock ticker symbol in the sidebar (e.g., `AAPL` for Apple Inc.).
|
| 18 |
+
- 2. **Analyze**: Click the "Analyze" button to fetch and process the options data.
|
| 19 |
+
- 3. **Visualize**: View the visualizations and interpretations of the options data to understand market sentiment.
|
|
|
|
|
|
|
| 20 |
""")
|
| 21 |
|
| 22 |
st.title("Options Sentiment Analysis Tool")
|
|
|
|
| 692 |
if st.sidebar.button("Run Analysis"):
|
| 693 |
options_data, recent_price = get_options_data(ticker)
|
| 694 |
if options_data is not None:
|
| 695 |
+
st.subheader("Volatility Smile Plot")
|
| 696 |
overall_avg_iv_calls, overall_avg_iv_puts, avg_iv_by_strike_calls, avg_iv_by_strike_puts, expirations = plot_volatility_smile(options_data, recent_price, ticker)
|
| 697 |
|
| 698 |
with st.expander("Volatility Smile Interpretation", expanded=False):
|
| 699 |
interpret_volatility_smile(ticker, overall_avg_iv_calls, overall_avg_iv_puts, avg_iv_by_strike_calls, avg_iv_by_strike_puts)
|
| 700 |
|
| 701 |
+
st.subheader("Open Interest")
|
| 702 |
overall_avg_oi_calls, overall_avg_oi_puts, calls_data, puts_data = plot_open_interest(options_data, recent_price, ticker)
|
| 703 |
|
| 704 |
with st.expander("Open Interest Interpretation", expanded=False):
|
| 705 |
interpret_open_interest(ticker, overall_avg_oi_calls, overall_avg_oi_puts, calls_data, puts_data)
|
| 706 |
|
| 707 |
+
st.subheader("Volume Analysis")
|
| 708 |
overall_avg_vol_calls, overall_avg_vol_puts, calls_data, puts_data = plot_volume(options_data, recent_price, ticker)
|
| 709 |
|
| 710 |
with st.expander("Volume Analysis Interpretation", expanded=False):
|
| 711 |
interpret_volume(ticker, overall_avg_vol_calls, overall_avg_vol_puts, calls_data, puts_data)
|
| 712 |
|
| 713 |
+
st.subheader("Volatility Surface Plot")
|
| 714 |
col1, col2 = st.columns(2)
|
| 715 |
with col1:
|
| 716 |
st.markdown("### Puts")
|
|
|
|
| 732 |
with st.expander("Historical IV Interpretation", expanded=False):
|
| 733 |
interpret_historical_iv(ticker, historical_iv, current_iv)
|
| 734 |
|
| 735 |
+
st.subheader("Put to Call Ratio")
|
| 736 |
total_puts, total_calls, put_call_ratio = calculate_put_call_ratio(options_data)
|
| 737 |
|
| 738 |
with st.expander("Put to Call Ratio Interpretation", expanded=False):
|
| 739 |
interpret_put_call_ratio(ticker, total_puts, total_calls, put_call_ratio)
|
| 740 |
|
| 741 |
+
st.subheader("Greeks Analysis")
|
| 742 |
calls_data, puts_data = plot_greeks(options_data, recent_price, ticker)
|
| 743 |
|
| 744 |
with st.expander("Greeks Analysis Interpretation", expanded=False):
|
| 745 |
interpret_greeks(ticker, calls_data, puts_data)
|
| 746 |
|
| 747 |
+
st.subheader("Sentiment Score")
|
| 748 |
high_iv_calls = overall_avg_iv_calls
|
| 749 |
low_iv_puts = overall_avg_iv_puts
|
| 750 |
sentiment_score, sentiment_description = calculate_sentiment_score(options_data, high_iv_calls, low_iv_puts, total_calls, total_puts)
|