Ejemplo n.º 1
0
    def get_ohlcv(self, symbol, params={}):
        custom_params = deep_extend(self.ohlcv_headers, params)

        headers = {
            'url': self.urls['chart'],
            'symbol': symbol,
            'data_fields': custom_params['data_fields'],
            'frequency': chart_time_interval_dct[custom_params['frequency']],
        }

        params = deep_extend(custom_params, headers)
        return self._get_ohlcv(params)
Ejemplo n.º 2
0
    def __init__(self, symbol, params={}):
        self.base = deep_extend(self.base, params)
        pure_symbol, suffix, asset_type = symbol.split(' ')[:]

        base = {
            'info': {
                'type': 'bloomberg',
                'symbol': symbol,
                'pure_symbol': pure_symbol,
                'suffix': suffix,
            },
            'symbol': pure_symbol,
            'asset_type': asset_type
        }

        self.base = deep_extend(self.base, base)
Ejemplo n.º 3
0
    def get_events(self, symbol, params={}):
        custom_params = deep_extend(self.events_headers, params)
        headers = {
            'symbol':
            symbol,
            'data_fields':
            custom_params['data_fields'],
            'req_data_fields': [
                hist_fields_dct[field]
                for field in self.events_headers['data_fields']
            ],
            'frequency':
            'daily'
        }

        params = deep_extend(custom_params, headers)
        return self._get_events(params)
Ejemplo n.º 4
0
    def get_ohlcv(self, symbol, params={}):
        custom_params = deep_extend(self.ohlcv_headers, params)
        custom_params['data_fields'].append('ADJ_CLOSE') if custom_params['adjusted'] == True and 'ADJ_CLOSE' not in \
        custom_params['data_fields'] else True

        headers = {
            'symbol':
            symbol,
            'data_fields':
            custom_params['data_fields'],
            'req_data_fields':
            [hist_fields_dct[field] for field in custom_params['data_fields']],
            'frequency':
            time_interval_dct[custom_params['frequency']],
        }

        params = deep_extend(custom_params, headers)
        return self._get_ohlcv(params)
Ejemplo n.º 5
0
    def get_ohlcv_curl(self, symbol, params={}):
        custom_params = deep_extend(self.ohlcv_headers, params)

        headers = {
            'url':
            self.urls['ohlcv'],
            'symbol':
            symbol,
            'data_fields':
            custom_params['data_fields'],
            'req_data_fields':
            [hist_fields_dct[field] for field in custom_params['data_fields']],
            'frequency':
            time_interval_dct[custom_params['frequency']],
        }

        params = deep_extend(custom_params, headers)
        return self._get_ohlcv(params)
Ejemplo n.º 6
0
 def yahoo(self, params={}):
     base = deep_extend(self.base, params)
     base_symbol = base['symbol']
     base_symbol = base_symbol.replace('/', '-')
     if base['info']['suffix'] == 'US':
         y_symbol = '{}'.format(base_symbol)
     elif suffix_yahoo_dic.get(base['info']['suffix'], None) is not None:
         y_symbol = '{}.{}'.format(base_symbol,
                                   suffix_yahoo_dic[base['info']['suffix']])
     else:
         y_symbol = '{}.{}'.format(base_symbol, base['info']['suffix'])
     return y_symbol
Ejemplo n.º 7
0
 def naver(self, params={}):
     base = deep_extend(self.base, params)
     return base['symbol']
Ejemplo n.º 8
0
 def _base(self, params={}):
     base = deep_extend(self.base, params)
     return base['info']['symbol']
Ejemplo n.º 9
0
 def yahoo(self, params={}):
     base = deep_extend(self.base, params)
     return base['symbol'] if base['info']['suffix'] == 'US' \
         else '{}.{}'.format(base['symbol'], base['info']['suffix'])