def get_fx_rates(currency):

    fx_rates_info = FxRatesInfo[currency].value

    if fx_rates_info.data_source == 'quandl':
        fx_rates = quandl.get(fx_rates_info.data_name, api_key=quandl_token)
        fx_rates = fx_rates['Rate']
    else:
        fx_rates = DataReader(fx_rates_info.data_name,
                              fx_rates_info.data_source, START_DATE)
        fx_rates = fx_rates.squeeze()

    fx_rates = (fx_rates.fillna(method='pad').rename(
        fx_rates_info.fx_rates_name))
    return fx_rates
Beispiel #2
0
def get_fx_rates(currency):
    """ Return historical fx rates for a given currency name """
    fx_rates_info = FxRatesInfo[currency].value

    if fx_rates_info.data_source == 'quandl':
        fx_rates = quandl.get(fx_rates_info.data_name,
                              api_key=AdagioConfig.quandl_token)
        fx_rates = fx_rates['Rate']
    else:
        fx_rates = DataReader(fx_rates_info.data_name,
                              fx_rates_info.data_source, START_DATE)
        fx_rates = fx_rates.squeeze()

    fx_rates = (fx_rates
                .fillna(method='pad')
                .rename(fx_rates_info.fx_rates_name))
    return fx_rates