Spaces:
Runtime error
Runtime error
File size: 1,204 Bytes
e57c1e2 c5213f7 4570ada e57c1e2 c5213f7 e57c1e2 c5213f7 e57c1e2 c5213f7 e57c1e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import gradio as gr
import pandas as pd
import numpy as np
import math
import os
os.system('pip install openpyxl')
def vix_calculator(vix, spy, days=365):
score = ( (vix / math.sqrt(days)) / 100 )
return spy*(1-score), spy*(1+score)
# val1, val2 = (vix_spy_csv('VIX.csv'))
# print ('Volatility Range: ' + str(val1) + ' - ' + str(val2))
#multiple inputs are passed as arguments for the same function greet
def greet(file1):
# df = pd.read_csv(file1.name)
if 'csv' in file1.name:
df = pd.read_csv(file1.name, header=None)
df[0] = df[0].apply(lambda x : x.replace(',', ''))
if 'xlsx' in file1.name:
df = pd.read_excel(file1.name, header=None)
df[0] = df[0].apply(lambda x : x.replace(',', ''))
df.index = df.pop(0)
vix_spy_dict = df.to_dict()[1]
print(vix_spy_dict)
output = vix_calculator(vix_spy_dict['VIX'], vix_spy_dict['SPY'], days=365)
print(output)
return str(output)
# iface = gr.Interface(fn=greet, inputs=["file", "file", gr.inputs.Textbox(placeholder="Enter Question here...")], outputs="text")
iface = gr.Interface(fn=greet, inputs=['file'], outputs="text")
# iface.launch(share=True)
iface.launch(share=False) |