Example #1
0
 def test_ticker_full(self):
     tickers.TickerFull.DelimiterSplit = '|'
     tickers.TickerFull('A|B')
     with self.assertRaises(tickers.InvalidTickerError):
         tickers.TickerFull('A@B')
     tickers.TickerFull.DelimiterSplit = '@'
     tickers.TickerFull('A@B')
Example #2
0
 def test_map_string(self):
     with self.assertRaises(tickers.InvalidTickerError):
         tickers.map_string_to_ticker('')
     self.is_equal(tickers.TickerFull('A@B'), tickers.map_string_to_ticker('A@B'))
     self.is_equal(tickers.TickerFull('A@B|C'), tickers.map_string_to_ticker('A@B|C'))
     self.is_equal(tickers.TickerDataType('A|B'), tickers.map_string_to_ticker('A|B'))
     self.is_equal(tickers.TickerLocal('AB'), tickers.map_string_to_ticker('AB'))
Example #3
0
 def test_create_ticker_full(self):
     targ = tickers.TickerFull('A@B')
     self.assertTrue(
         self.is_equal(targ, tickers.create_ticker_full('A', 'B')))
     provider = tickers.TickerProviderCode('A')
     query = tickers.TickerFetch('B')
     self.assertTrue(
         self.is_equal(targ, tickers.create_ticker_full(provider, query)))
Example #4
0
    def fetch(self, series_meta):
        """

        :param series_meta: myplattform.SeriesMetadata
        :return:
        """
        # This will not be needed once the platform code is switched over to using the tickers module.
        full_ticker = tickers.TickerFull(series_meta.ticker_full)
        #provider_code, series_code = full_ticker.SplitTicker()
        series_code = series_meta.ticker_query
        df = self.SearchForSeriesCode(str(series_code))
        # Need to eliminate the after "Series ID"
        l_index = list(df.index)
        pos = l_index.index('Series ID')
        pos += 1
        ser = pandas.Series(df.values[pos:])
        ser.index = l_index[pos:]
        ser.name = str(full_ticker)
        return ser
def greek_overnight(series_meta):
    """

    :param series_meta: econ_platform_core.SeriesMetadata
    :return:
    """
    if not str(series_meta.ticker_query) in ('GREEK_DRACHMA_OVERNIGHT_AVG',
            'GREEK_DRACHMA_OVERNIGHT_EOM'):
        raise ValueError('Wrong series!')
    full_ticker = tickers.TickerFull(series_meta.ticker_full)
    # I will assume that the file is downloaded to the current directory
    sheet = pandas.read_excel('drachma_overnight_rate.xls',  header=2)
    if str(series_meta.ticker_query) == 'GREEK_DRACHMA_OVERNIGHT_AVG':
        ser = pandas.Series(sheet['monthly averages'])
        ser.index = sheet['Unnamed: 0']
        series_meta.series_name = 'Average pre-Euro Greek Drachma Bank Overnight Rate'
        series_meta.series_description = 'Monthly average bank overnight rate from Bank of Greece'
        # quick_plot(ser)
    else:
        print(sheet)
        raise NotImplementedError('Bam!')
    ser.name = str(full_ticker)
    return ser
Example #6
0
    def fetch(self, series_meta):
        """

        :param series_meta: myplattform.SeriesMetaData
        :return:
        """
        if self.Directory is None:
            self.Directory = econ_platform_core.utils.parse_config_path(
                econ_platform_core.PlatformConfiguration['P_RBAXLS']
                ['directory'])
        # This will not be needed once the platform code is switched over to using the tickers module.
        full_ticker = tickers.TickerFull(series_meta.ticker_full)
        series_code = series_meta.ticker_query
        df_list = self.SearchForSeriesCode(str(series_code))
        ser = None
        for df in df_list:
            partial_ser = self.ConvertDFtoSeries(df, full_ticker)
            if ser is None:
                ser = partial_ser
            else:
                ser = ser.update(partial_ser)
        return [
            ser,
        ]
Example #7
0
 def test_split(self):
     x = tickers.TickerFull('A@B')
     [a,b] = x.SplitTicker()
     self.is_equal(tickers.TickerProviderCode('A'), a)
     self.is_equal(tickers.TickerFetch('B'), b)
Example #8
0
 def test_len(self):
     x = tickers.TickerFull('A@B')
     self.assertEqual(3, len(x))
Example #9
0
 def test_str(self):
     x = tickers.TickerFull('A@B')
     self.assertEqual('A@B', str(x))