def currencies_filter(query, code, currency_name, favorites=None):
    """Determine whether query matched with the code or currency name

    For query to match, it must not be a item in favorites
    (if favorites is provided), and be one of the following:
    * Empty query
    * Matching code from start (case insensitive)
    * Matching one of the word in currency_name from start (case insensitive)

    Arguments:
        query {str} -- Input query string
        code {str} -- Currency code
        currency_name {str} -- Full name of currency

    Keyword Arguments:
        favorites {list} -- list of favorites currency code (default: {None})

    Returns:
        bool -- True if matched else False
    """
    favorites = favorites or []
    if code in favorites:
        return False
    if not query:
        return True
    if code.startswith(query.upper()):
        return True
    for key_word in currency_name.split():
        if key_word.lower().startswith(query.lower()):
            return True
    return False