Spaces:
Sleeping
Sleeping
Create Options trader
Browse files- Options trader +44 -0
Options trader
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
requirements.txt
|
2 |
+
yfinance
|
3 |
+
streamlit
|
4 |
+
import streamlit as st
|
5 |
+
import yfinance as yf
|
6 |
+
from datetime import datetime, timedelta
|
7 |
+
|
8 |
+
st.set_page_config(page_title="Options Scanner", layout="wide")
|
9 |
+
|
10 |
+
st.title("Naked Options Play Finder")
|
11 |
+
|
12 |
+
ticker = st.text_input("Enter Ticker Symbol (e.g. GME, SPY, TSLA)", "GME")
|
13 |
+
max_price = st.slider("Max Option Price ($)", 5, 200, 50)
|
14 |
+
days_out = st.slider("Days Until Expiration", 1, 14, 7)
|
15 |
+
|
16 |
+
if st.button("Find Options"):
|
17 |
+
stock = yf.Ticker(ticker)
|
18 |
+
today = datetime.today().date()
|
19 |
+
|
20 |
+
try:
|
21 |
+
expirations = stock.options
|
22 |
+
st.success(f"Found {len(expirations)} expirations")
|
23 |
+
|
24 |
+
for exp in expirations:
|
25 |
+
exp_date = datetime.strptime(exp, "%Y-%m-%d").date()
|
26 |
+
if (exp_date - today).days > days_out:
|
27 |
+
continue
|
28 |
+
|
29 |
+
calls = stock.option_chain(exp).calls
|
30 |
+
puts = stock.option_chain(exp).puts
|
31 |
+
|
32 |
+
cheap_calls = calls[calls['lastPrice'] <= max_price]
|
33 |
+
cheap_puts = puts[puts['lastPrice'] <= max_price]
|
34 |
+
|
35 |
+
if not cheap_calls.empty:
|
36 |
+
st.subheader(f"Calls under ${max_price} expiring {exp}")
|
37 |
+
st.dataframe(cheap_calls[['strike', 'lastPrice', 'volume', 'impliedVolatility']])
|
38 |
+
|
39 |
+
if not cheap_puts.empty:
|
40 |
+
st.subheader(f"Puts under ${max_price} expiring {exp}")
|
41 |
+
st.dataframe(cheap_puts[['strike', 'lastPrice', 'volume', 'impliedVolatility']])
|
42 |
+
|
43 |
+
except Exception as e:
|
44 |
+
st.error(f"Error: {e}")
|