Esempio n. 1
0
def get_currency_value(date, name=None):
    '''
    Obtiene los valores de los currency para dos fechas. Cada vez que hay una nueva moneda hay que agregarlo a mano acá.
    '''
    days_dif = 0

    if name.strip() == 'US$':
        date_inc = fs.convert_date_to_string(date)
        date = fs.convert_date_to_string(get_next_weekdays(date))
    else:
        prev_day = get_previous_weekdays(date)
        date_inc = fs.convert_date_to_string(prev_day)
        #solo para calcular bien el devengo diario de la uf, los dias lunes
        days_dif = (date - prev_day).days

    dic_id = {'UF': 23, 'US$': 66, 'MX': 85}
    currency_id = dic_id[name]
    query = "Select Valor from Indices_Dinamica where Index_ID={} and  fecha in ('{}', '{}')".format(
        currency_id, date_inc, date)
    df = fs.get_frame_sql_user(server="puyehue",
                               database="MesaInversiones",
                               username="******",
                               password="******",
                               query=query)
    return df.loc[1]['Valor'], df.loc[0]['Valor'], days_dif
Esempio n. 2
0
def get_next_weekday(adate):
    '''
	Retorna la fecha en string del proximo weekday dado una fecha en string.
	'''
    adate = convert_string_to_date(date_string=adate)
    adate += dt.timedelta(days=1)
    while adate.weekday() > 4:  # Mon-Fri are 0-4
        adate += dt.timedelta(days=1)
    adate = convert_date_to_string(adate)
    return adate
Esempio n. 3
0
def get_currency_types(date):
    '''
    Obtenemos los tipos de moneds de los instrumentos para una fecha
    '''
    date = fs.convert_date_to_string(get_previous_weekdays(date))
    query = open('./querys/currency.txt', 'r').read()
    query = query.replace('[DATE]', "'"+date+"'")
    df = fs.get_frame_sql_user(server="puyehue",
                               database="MesaInversiones",
                               username="******",
                               password="******",
                               query=query)
    return df['moneda'].tolist()
Esempio n. 4
0
def get_data(name, date, new_index=False):
    '''
    Obtiene los leverage de los fondos
    '''
    date = fs.convert_date_to_string(get_previous_weekdays(date))
    query = open('./querys/{}'.format(name), 'r').read()
    query = query.replace('[DATE]', "'"+date+"'")
    df = fs.get_frame_sql_user(server="puyehue",
                               database="MesaInversiones",
                               username="******",
                               password="******",
                               query=query)
    if new_index is not False:
        df.set_index([new_index], inplace=True)
    return df