예제 #1
0
def get_popularity_by_ids(inputIds, info=None, errors=True):
    """Returns the number of open positions.

    :param inputSymbols: The stock ids.
    :type symbol: str, list
    :param info: Will filter the results to be a string value.
    :type info: Optional[str]
    :returns: If the info parameter is provided, then the function will extract the value of the key \
    that matches the info parameter. Otherwise, the whole dictionary is returned.

    """
    ids = helper.inputs_to_set(inputIds)
    url = urls.popularity()
    payload = {'ids': ','.join(ids)}
    data = helper.request_get(url, payload=payload, errors=errors)

    if (data == None or data == [None]):
        return data

    for count, item in enumerate(data):
        if item is None:
            print(helper.error_ticker_does_not_exist(ids[count]))

    # data = [item for item in data if item is not None]

    return (helper.filter(data, info))
예제 #2
0
def get_popularity(symbol, info=None):
    """Returns the number of open positions.
    :param symbol: The stock ticker.
    :type symbol: str
    :param info: Will filter the results to be a string value.
    :type info: Optional[str]
    :returns: If the info parameter is provided, then the function will extract the value of the key \
    that matches the info parameter. Otherwise, the whole dictionary is returned.
    """
    try:
        symbol = symbol.upper().strip()
    except AttributeError as message:
        print(message)
        return None
    url = urls.popularity()
    payload = {'ids': helper.id_for_stock(symbol)}
    data = helper.request_get(url, payload)
    res = helper.filter(data, info)
    return res[0]
예제 #3
0
def get_popularity(symbol, info=None):
    """Returns the number of open positions.

    :param symbol: The stock ticker.
    :type symbol: str
    :param info: Will filter the results to be a string value.
    :type info: Optional[str]
    :returns: [dict] If the info parameter is provided, then the function will extract the value of the key \
    that matches the info parameter. Otherwise, the whole dictionary is returned.
    :Dictionary Keys: * instrument
                      * num_open_positions

    """
    try:
        symbol = symbol.upper().strip()
    except AttributeError as message:
        print(message)
        return None

    url = urls.popularity(symbol)
    data = helper.request_get(url)

    return(helper.filter(data, info))