1
File size: 1,429 Bytes
6277d8f
e635c27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit 
from datetime import datetime, timedelta
st.set_page_config(page_title="Options Scanner", layout="wide")
st.title("Naked Options Play Finder")
ticker = st.text_input("Enter Ticker Symbol (e.g. GME, SPY, TSLA)", "GME")
max_price = st.slider("Max Option Price ($)", 5, 200, 50)
days_out = st.slider("Days Until Expiration", 1, 14, 7)
if st.button("Find Options"):
    stock = yf.Ticker(ticker)
    today = datetime.today().date()

    try:
        expirations = stock.options
        st.success(f"Found {len(expirations)} expirations")

        for exp in expirations:
            exp_date = datetime.strptime(exp, "%Y-%m-%d").date()
            if (exp_date - today).days > days_out:
                continue

            calls = stock.option_chain(exp).calls
            puts = stock.option_chain(exp).puts

            cheap_calls = calls[calls['lastPrice'] <= max_price]
            cheap_puts = puts[puts['lastPrice'] <= max_price]

            if not cheap_calls.empty:
                st.subheader(f"Calls under ${max_price} expiring {exp}")
                st.dataframe(cheap_calls[['strike', 'lastPrice', 'volume', 'impliedVolatility']])

            if not cheap_puts.empty:
                st.subheader(f"Puts under ${max_price} expiring {exp}")
                st.dataframe(cheap_puts[['strike', 'lastPrice', 'volume', 'impliedVolatility']])

    except Exception as e:
        st.error(f"Error: {e}")