def _get_fx_prices_with_ib_config(
            self, currency_code: str,
            ib_config_for_code: ibFXConfig) -> fxPrices:
        raw_fx_prices_as_series = self._get_raw_fx_prices(ib_config_for_code)

        if len(raw_fx_prices_as_series) == 0:
            self.log.warn(
                "No available IB prices for %s %s" %
                (currency_code, str(ib_config_for_code)),
                fx_code=currency_code,
            )
            return fxPrices.create_empty()

        if ib_config_for_code.invert:
            raw_fx_prices = 1.0 / raw_fx_prices_as_series
        else:
            raw_fx_prices = raw_fx_prices_as_series

        # turn into a fxPrices
        fx_prices = fxPrices(raw_fx_prices)

        self.log.msg("Downloaded %d prices" % len(fx_prices),
                     fx_code=currency_code)

        return fx_prices
    def _get_fx_prices_without_checking(self, currency_code: str) -> fxPrices:

        fx_data = self.arctic.read(currency_code)

        fx_prices = fxPrices(fx_data[fx_data.columns[0]])

        return fx_prices
Пример #3
0
    def _get_fx_prices_without_checking(self, currency_code: str) -> fxPrices:

        fx_data = self.arctic.read(currency_code)

        # Returns a pd.Series which should have the right format
        fx_prices = fxPrices(fx_data['values'])

        return fx_prices
    def _get_fx_prices_without_checking(self, currency_code):
        qcode = self._get_qcode(currency_code)
        try:
            fx_prices = quandl.get(qcode)
        except Exception as exception:
            self.log.warn("Can't get QUANDL data for %s error %s" %
                          (qcode, exception))
            return fxPrices.create_empty()

        fx_prices = fx_prices.Rate

        return fxPrices(fx_prices)
Пример #5
0
    def _get_fx_prices_without_checking(self, code: str) -> fxPrices:
        filename = self._filename_given_fx_code(code)
        config = self.config
        price_column = config.price_column
        date_column = config.date_column
        date_format = config.date_format

        try:
            fx_data = pd_readcsv(
                filename, date_format=date_format, date_index_name=date_column
            )
        except OSError:
            self.log.warn("Can't find currency price file %s" % filename, fx_code=code)
            return fxPrices.create_empty()

        fx_data = pd.Series(fx_data[price_column])

        fx_data = fxPrices(fx_data.sort_index())

        return fx_data