Update app.py
Browse files
app.py
CHANGED
|
@@ -151,6 +151,13 @@ def generar_calls(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):
|
| 156 |
|
|
@@ -215,7 +222,8 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 215 |
ticker_input = gr.Textbox(label="Ticker (ej. GOOGL)", value="MSTR")
|
| 216 |
expiration_date = gr.Textbox(label="Fecha de vencimiento (formato: aaaa-mm-dd)", value = "" )
|
| 217 |
size_of_the_window = gr.Slider(minimum=1, maximum=30, value=16, step=1, label="Tama帽o de la ventana")
|
| 218 |
-
|
|
|
|
| 219 |
df_put_state = gr.State(value=initial_df_put)
|
| 220 |
df_call_state = gr.State(value=initial_df_call)
|
| 221 |
|
|
@@ -225,17 +233,10 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 225 |
|
| 226 |
with gr.Row():
|
| 227 |
gr.Markdown("# Opciones Put")
|
| 228 |
-
btn_mostrar1 = gr.Button("Mostrar datos")
|
| 229 |
|
| 230 |
with gr.Row():
|
| 231 |
|
| 232 |
-
output_df_put = gr.DataFrame(label="Datos de Opciones put", value=initial_df_put)
|
| 233 |
-
|
| 234 |
-
btn_mostrar1.click(
|
| 235 |
-
fn=generar_puts,
|
| 236 |
-
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 237 |
-
outputs= [ output_df_put, df_put_state]
|
| 238 |
-
)
|
| 239 |
|
| 240 |
|
| 241 |
with gr.Tab("Calls"):
|
|
@@ -247,12 +248,7 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 247 |
with gr.Row():
|
| 248 |
|
| 249 |
output_df_call = gr.DataFrame(label="Datos de Opciones call", value=initial_df_call)
|
| 250 |
-
|
| 251 |
-
btn_mostrar2.click(
|
| 252 |
-
fn=generar_calls,
|
| 253 |
-
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 254 |
-
outputs= [ output_df_call, df_call_state]
|
| 255 |
-
)
|
| 256 |
|
| 257 |
with gr.Tab("Plots"):
|
| 258 |
|
|
@@ -278,6 +274,12 @@ with gr.Blocks(title="An谩lisis de Opciones") as demo:
|
|
| 278 |
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 279 |
outputs=[output_file, output_msg]
|
| 280 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
btn_plot.click(
|
| 283 |
fn=plot_opciones,
|
|
|
|
| 151 |
clean_calls = parse_opciones_table(calls)
|
| 152 |
return calls, clean_calls
|
| 153 |
|
| 154 |
+
def generar_todo(ticker_input, expiration_date, size_of_the_window):
|
| 155 |
+
puts = generar_puts(ticker_input, expiration_date, size_of_the_window)[0]
|
| 156 |
+
puts_clean = generar_puts(ticker_input, expiration_date, size_of_the_window)[1]
|
| 157 |
+
calls = generar_calls(ticker_input, expiration_date, size_of_the_window)[0]
|
| 158 |
+
calls_clean = generar_calls(ticker_input, expiration_date, size_of_the_window)[1]
|
| 159 |
+
return puts, puts_clean,calls,calls_clean
|
| 160 |
+
|
| 161 |
# Funci贸n para generar y devolver el archivo Excel
|
| 162 |
def exportar_a_excel(option_type, ticker_input, expiration_date, size_of_the_window):
|
| 163 |
|
|
|
|
| 222 |
ticker_input = gr.Textbox(label="Ticker (ej. GOOGL)", value="MSTR")
|
| 223 |
expiration_date = gr.Textbox(label="Fecha de vencimiento (formato: aaaa-mm-dd)", value = "" )
|
| 224 |
size_of_the_window = gr.Slider(minimum=1, maximum=30, value=16, step=1, label="Tama帽o de la ventana")
|
| 225 |
+
btn_mostrar = gr.Button('Cargar Datos')
|
| 226 |
+
|
| 227 |
df_put_state = gr.State(value=initial_df_put)
|
| 228 |
df_call_state = gr.State(value=initial_df_call)
|
| 229 |
|
|
|
|
| 233 |
|
| 234 |
with gr.Row():
|
| 235 |
gr.Markdown("# Opciones Put")
|
|
|
|
| 236 |
|
| 237 |
with gr.Row():
|
| 238 |
|
| 239 |
+
output_df_put = gr.DataFrame(label="Datos de Opciones put", value=initial_df_put)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
|
| 242 |
with gr.Tab("Calls"):
|
|
|
|
| 248 |
with gr.Row():
|
| 249 |
|
| 250 |
output_df_call = gr.DataFrame(label="Datos de Opciones call", value=initial_df_call)
|
| 251 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
with gr.Tab("Plots"):
|
| 254 |
|
|
|
|
| 274 |
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 275 |
outputs=[output_file, output_msg]
|
| 276 |
)
|
| 277 |
+
|
| 278 |
+
btn_mostrar.click(
|
| 279 |
+
fn=generar_todo,
|
| 280 |
+
inputs=[ticker_input, expiration_date, size_of_the_window],
|
| 281 |
+
outputs= [ output_df_put, output_df_call, df_call_state, df_put_state]
|
| 282 |
+
)
|
| 283 |
|
| 284 |
btn_plot.click(
|
| 285 |
fn=plot_opciones,
|