Exemplo n.º 1
0
    def _get_fx_prices_without_checking(self, currency_code):
        new_log = self.log.setup(currency_code=currency_code)

        ibfxcode = self._get_ibfxcode(currency_code)
        if ibfxcode is missing_instrument:
            new_log.warn(
                "Can't get prices as missing IB config for %s" %
                currency_code)
            return fxPrices.create_empty()

        ccy1, ccy2, invert = ibfxcode
        raw_fx_prices = self.ibconnection.broker_get_daily_fx_data(
            ccy1, ccy2=ccy2, bar_freq="D"
        )
        raw_fx_prices_as_series = raw_fx_prices["FINAL"]

        if len(raw_fx_prices_as_series) == 0:
            new_log.warn("No available IB prices for %s" % currency_code)
            return fxPrices.create_empty()

        # turn into a fxPrices
        raw_fx_prices = fxPrices(raw_fx_prices_as_series)

        if invert:
            fx_prices = 1.0 / raw_fx_prices
        else:
            fx_prices = raw_fx_prices

        new_log.msg("Downloaded %d prices" % len(fx_prices))

        return fx_prices
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def _get_fx_prices_without_checking(self, code):
        filename = self._filename_given_fx_code(code)
        try:
            fx_data = pd_readcsv(filename)
        except OSError:
            self.log.warning("Can't find currency price file %s" % filename)
            return fxPrices.create_empty()

        fx_data = pd.Series(fx_data.iloc[:, 0])

        fx_data = fxPrices(fx_data)

        return fx_data
    def _get_fx_prices_without_checking(self, code):
        filename = self._filename_given_fx_code(code)
        try:
            fx_data = pd_readcsv(filename)
        except OSError:
            self.log.warning("Can't find currency price file %s" % filename)
            return fxPrices.create_empty()

        fx_data = pd.Series(fx_data.iloc[:, 0])

        fx_data = fxPrices(fx_data)

        return fx_data
Exemplo n.º 5
0
    def _get_fx_prices_without_checking(self, code):
        filename = self._filename_given_fx_code(code)
        price_column = self._price_column
        date_column = self._date_column
        date_format = self._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)
            return fxPrices.create_empty()

        fx_data = pd.Series(fx_data[price_column])

        fx_data = fxPrices(fx_data.sort_index())

        return fx_data