Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import matplotlib.pyplot as plt
|
|
| 6 |
import plotly.graph_objects as go
|
| 7 |
import numpy as np
|
| 8 |
import os
|
|
|
|
| 9 |
|
| 10 |
from processes import *
|
| 11 |
# Funci贸n para obtener los datos y mostrarlos en el DataFrame de la UI
|
|
@@ -16,6 +17,15 @@ def generar_tabla(option_type, ticker_input, expiration_date, size_of_the_window
|
|
| 16 |
|
| 17 |
if yf.Ticker(ticker_input).options:
|
| 18 |
if expiration_date is None or expiration_date == "":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
for date in yf.Ticker(ticker_input).options:
|
| 20 |
table = data_option(ticker_input, date, option_type, size_of_the_window)
|
| 21 |
if not table.empty:
|
|
@@ -181,8 +191,8 @@ def exportar_a_excel_con_hojas(ticker_input, expiration_date, size_of_the_window
|
|
| 181 |
|
| 182 |
|
| 183 |
# --- Valores por defecto para inicializar la tabla ---
|
| 184 |
-
initial_df_put = generar_tabla("put", "MSTR", '
|
| 185 |
-
initial_df_call = generar_tabla("call", "MSTR", '
|
| 186 |
|
| 187 |
|
| 188 |
with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
|
|
| 6 |
import plotly.graph_objects as go
|
| 7 |
import numpy as np
|
| 8 |
import os
|
| 9 |
+
from datetime import date
|
| 10 |
|
| 11 |
from processes import *
|
| 12 |
# Funci贸n para obtener los datos y mostrarlos en el DataFrame de la UI
|
|
|
|
| 17 |
|
| 18 |
if yf.Ticker(ticker_input).options:
|
| 19 |
if expiration_date is None or expiration_date == "":
|
| 20 |
+
|
| 21 |
+
expiration_date1 = date.today().strftime('%Y-%m-%d')
|
| 22 |
+
fechas = pd.Series(yf.Ticker(ticker_input).options)
|
| 23 |
+
timedeltas = fechas.apply(lambda x: pd.to_datetime(x) - pd.to_datetime(expiration_date))
|
| 24 |
+
expiration_date1 = fechas[timedeltas.abs().idxmin()]
|
| 25 |
+
df_final = data_option(ticker_input, expiration_date1, option_type, size_of_the_window)
|
| 26 |
+
|
| 27 |
+
return df_final
|
| 28 |
+
elif expiration_date == "All":
|
| 29 |
for date in yf.Ticker(ticker_input).options:
|
| 30 |
table = data_option(ticker_input, date, option_type, size_of_the_window)
|
| 31 |
if not table.empty:
|
|
|
|
| 191 |
|
| 192 |
|
| 193 |
# --- Valores por defecto para inicializar la tabla ---
|
| 194 |
+
initial_df_put = generar_tabla("put", "MSTR", '', 16)
|
| 195 |
+
initial_df_call = generar_tabla("call", "MSTR", '', 16)
|
| 196 |
|
| 197 |
|
| 198 |
with gr.Blocks(title="An谩lisis de Opciones") as demo:
|