Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Procfile +1 -0
- app.py +29 -0
- requirements.txt +3 -0
Procfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
python app.py
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
def fetch_unusual_options():
|
| 6 |
+
url = "https://api.optioncharts.io/option/contracts/trending"
|
| 7 |
+
response = requests.get(url)
|
| 8 |
+
data = response.json()
|
| 9 |
+
|
| 10 |
+
df = pd.DataFrame(data)
|
| 11 |
+
if not df.empty:
|
| 12 |
+
df = df[['ticker', 'optionType', 'strikePrice', 'expiryDate', 'premium']]
|
| 13 |
+
df.rename(columns={
|
| 14 |
+
'ticker': 'Symbol',
|
| 15 |
+
'optionType': 'Type',
|
| 16 |
+
'strikePrice': 'Strike',
|
| 17 |
+
'expiryDate': 'Expiry',
|
| 18 |
+
'premium': 'Premium ($)'
|
| 19 |
+
}, inplace=True)
|
| 20 |
+
df['Premium ($)'] = df['Premium ($)'].apply(lambda x: f"${x:,}")
|
| 21 |
+
return df.head(50)
|
| 22 |
+
else:
|
| 23 |
+
return pd.DataFrame(columns=["Symbol", "Type", "Strike", "Expiry", "Premium ($)"])
|
| 24 |
+
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("# OptionCharts Unusual Options Flow (Top 50 Realtime)")
|
| 27 |
+
table = gr.Dataframe(fetch_unusual_options, every=30, label="Latest Unusual Options")
|
| 28 |
+
|
| 29 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
pandas
|
| 3 |
+
requests
|