Update app.py
Browse files
app.py
CHANGED
|
@@ -139,14 +139,17 @@ def plot_opciones(df_put, df_call, ticker_input, expiration_date):
|
|
| 139 |
return fig1, fig2
|
| 140 |
|
| 141 |
|
| 142 |
-
|
| 143 |
-
def generar_todo(ticker_input, expiration_date, size_of_the_window):
|
| 144 |
ticker_input = ticker_input
|
| 145 |
puts = generar_tabla("put", ticker_input, expiration_date, size_of_the_window)
|
| 146 |
-
calls = generar_tabla("call", ticker_input, expiration_date, size_of_the_window)
|
| 147 |
clean_puts = parse_opciones_table(puts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
clean_calls = parse_opciones_table(calls)
|
| 149 |
-
return
|
| 150 |
|
| 151 |
# Funci贸n para generar y devolver el archivo Excel
|
| 152 |
def exportar_a_excel(option_type, ticker_input, expiration_date, size_of_the_window):
|
|
@@ -169,7 +172,8 @@ def exportar_a_excel(option_type, ticker_input, expiration_date, size_of_the_win
|
|
| 169 |
|
| 170 |
def exportar_a_excel_con_hojas(ticker_input, expiration_date, size_of_the_window):
|
| 171 |
|
| 172 |
-
df_puts
|
|
|
|
| 173 |
ticker = ticker_input.upper()
|
| 174 |
nombre_archivo = f"{ticker}_opciones.xlsx"
|
| 175 |
try:
|
|
@@ -224,6 +228,12 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 224 |
|
| 225 |
output_df_put = gr.DataFrame(label="Datos de Opciones put", value=initial_df_put)
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
|
| 229 |
with gr.Tab("Calls"):
|
|
@@ -233,6 +243,12 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 233 |
|
| 234 |
output_df_call = gr.DataFrame(label="Datos de Opciones call", value=initial_df_call)
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
with gr.Tab("Plots"):
|
| 238 |
|
|
@@ -264,12 +280,6 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 264 |
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 265 |
outputs=[output_file, output_msg]
|
| 266 |
)
|
| 267 |
-
gr.on(
|
| 268 |
-
triggers=None, # Esto hace que se ejecute al cargar
|
| 269 |
-
fn=generar_todo,
|
| 270 |
-
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 271 |
-
outputs=[output_df_put, output_df_call, df_put_state, df_call_state]
|
| 272 |
-
)
|
| 273 |
|
| 274 |
'''
|
| 275 |
btn_mostrar.click(
|
|
|
|
| 139 |
return fig1, fig2
|
| 140 |
|
| 141 |
|
| 142 |
+
def generar_puts(ticker_input, expiration_date, size_of_the_window):
|
|
|
|
| 143 |
ticker_input = ticker_input
|
| 144 |
puts = generar_tabla("put", ticker_input, expiration_date, size_of_the_window)
|
|
|
|
| 145 |
clean_puts = parse_opciones_table(puts)
|
| 146 |
+
return puts, clean_puts
|
| 147 |
+
|
| 148 |
+
def generar_calls(ticker_input, expiration_date, size_of_the_window):
|
| 149 |
+
ticker_input = ticker_input
|
| 150 |
+
calls = generar_tabla("call", ticker_input, expiration_date, size_of_the_window)
|
| 151 |
clean_calls = parse_opciones_table(calls)
|
| 152 |
+
return calls, clean_calls
|
| 153 |
|
| 154 |
# Funci贸n para generar y devolver el archivo Excel
|
| 155 |
def exportar_a_excel(option_type, ticker_input, expiration_date, size_of_the_window):
|
|
|
|
| 172 |
|
| 173 |
def exportar_a_excel_con_hojas(ticker_input, expiration_date, size_of_the_window):
|
| 174 |
|
| 175 |
+
df_puts = generar_puts(ticker_input, expiration_date, size_of_the_window)[0]
|
| 176 |
+
df_calls = generar_calls(ticker_input, expiration_date, size_of_the_window)[0]
|
| 177 |
ticker = ticker_input.upper()
|
| 178 |
nombre_archivo = f"{ticker}_opciones.xlsx"
|
| 179 |
try:
|
|
|
|
| 228 |
|
| 229 |
output_df_put = gr.DataFrame(label="Datos de Opciones put", value=initial_df_put)
|
| 230 |
|
| 231 |
+
gr.on(
|
| 232 |
+
triggers=None, # Esto hace que se ejecute al cargar
|
| 233 |
+
fn=generar_puts,
|
| 234 |
+
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 235 |
+
outputs= [ output_df_put, df_put_state]
|
| 236 |
+
)
|
| 237 |
|
| 238 |
|
| 239 |
with gr.Tab("Calls"):
|
|
|
|
| 243 |
|
| 244 |
output_df_call = gr.DataFrame(label="Datos de Opciones call", value=initial_df_call)
|
| 245 |
|
| 246 |
+
gr.on(
|
| 247 |
+
triggers=None, # Esto hace que se ejecute al cargar
|
| 248 |
+
fn=generar_calls,
|
| 249 |
+
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 250 |
+
outputs= [ output_df_call, df_call_state]
|
| 251 |
+
)
|
| 252 |
|
| 253 |
with gr.Tab("Plots"):
|
| 254 |
|
|
|
|
| 280 |
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 281 |
outputs=[output_file, output_msg]
|
| 282 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
'''
|
| 285 |
btn_mostrar.click(
|