Example #1
0
def get_exchange_symbols(exchange_name, environ=None):
    """
    The de-serialized content of the exchange's symbols.json.

    Parameters
    ----------
    exchange_name: str
    environ:

    Returns
    -------
    Object

    """
    filename = get_exchange_symbols_filename(exchange_name)

    if not os.path.isfile(filename) or \
                    pd.Timedelta(pd.Timestamp('now',
                                              tz='UTC') - last_modified_time(
                        filename)).days > 1:
        download_exchange_symbols(exchange_name, environ)

    if os.path.isfile(filename):
        with open(filename) as data_file:
            data = json.load(data_file)
            return data
    else:
        raise ExchangeSymbolsNotFound(
            exchange=exchange_name,
            filename=filename
        )
Example #2
0
def get_exchange_symbols(exchange_name, is_local=False, environ=None):
    """
    The de-serialized content of the exchange's symbols.json.

    Parameters
    ----------
    exchange_name: str
    is_local: bool
    environ:

    Returns
    -------
    Object

    """
    filename = get_exchange_symbols_filename(exchange_name, is_local)

    if not is_local and (not os.path.isfile(filename) or pd.Timedelta(
                pd.Timestamp('now', tz='UTC') - last_modified_time(
                filename)).days > 1):
        download_exchange_symbols(exchange_name, environ)

    if os.path.isfile(filename):
        with open(filename) as data_file:
            try:
                data = json.load(data_file, cls=ExchangeJSONDecoder)
                return data

            except ValueError:
                return dict()
    else:
        raise ExchangeSymbolsNotFound(
            exchange=exchange_name,
            filename=filename
        )
Example #3
0
def get_exchange_symbols(exchange_name, environ=None):
    filename = get_exchange_symbols_filename(exchange_name)

    if not os.path.isfile(filename) or \
            pd.Timedelta(pd.Timestamp('now', tz='UTC') - last_modified_time(filename)).days > 1:
        download_exchange_symbols(exchange_name, environ)

    if os.path.isfile(filename):
        with open(filename) as data_file:
            data = json.load(data_file)
            return data
    else:
        raise ExchangeSymbolsNotFound(exchange=exchange_name,
                                      filename=filename)
Example #4
0
def get_exchange_symbols(exchange_name, environ=None):
    exchange_folder = get_exchange_folder(exchange_name, environ)
    filename = os.path.join(exchange_folder, 'symbols.json')

    if not os.path.isfile(filename):
        download_exchange_symbols(exchange_name, environ)

    if os.path.isfile(filename):
        with open(filename) as data_file:
            data = json.load(data_file)
            return data
    else:
        raise ExchangeSymbolsNotFound(exchange=exchange_name,
                                      filename=filename)