Exemple #1
0
def delete_symbols_from_watchlist(inputSymbols, name="My First List"):
    """Deletes multiple stock tickers from a watchlist.

    :param inputSymbols: May be a single stock ticker or a list of stock tickers.
    :type inputSymbols: str or list
    :param name: The name of the watchlist to delete data from.
    :type name: Optional[str]
    :returns: Returns result of the delete request.

    """
    symbols = helper.inputs_to_set(inputSymbols)
    ids = stocks.get_instruments_by_symbols(symbols, info='id')
    data = []

    #Get id of requested watchlist
    all_watchlists = get_all_watchlists()
    watchlist_id = ''
    for wl in all_watchlists['results']:
        if wl['display_name'] == name:
            watchlist_id = wl['id']

    for id in ids:
        payload = {
            watchlist_id: [{
                "object_type": "instrument",
                "object_id": id,
                "operation": "delete"
            }]
        }
        url = urls.watchlists(name, True)
        data.append(helper.request_post(url, payload, json=True))

    return (data)
Exemple #2
0
def delete_symbols_from_watchlist(inputSymbols, name='Default'):
    """Deletes multiple stock tickers from a watchlist.

    :param inputSymbols: May be a single stock ticker or a list of stock tickers.
    :type inputSymbols: str or list
    :param name: The name of the watchlist to delete data from.
    :type name: Optional[str]
    :returns: Returns result of the delete request.

    """
    symbols = helper.inputs_to_set(inputSymbols)
    symbols = stocks.get_fundamentals(symbols, info='instrument')

    watchlist = get_watchlist_by_name(name=name)

    items = []
    data = None

    for symbol in symbols:
        for list_ in watchlist:
            if symbol == list_['instrument']:
                items.append(symbol[37:])

    for item in items:
        url = urls.watchlists() + name + item
        data = helper.request_delete(url)

    return(data)
Exemple #3
0
def get_all_watchlists(info=None):
    """Returns a list of all watchlists that have been created. Everone has a 'default' watchlist.

    :param info: Will filter the results to get a specific value.
    :type info: Optional[str]
    :returns: Returns a list of the watchlists. Keywords are 'url', 'user', and 'name'.

    """
    url = urls.watchlists()
    data = helper.request_get(url, 'pagination')
    return(helper.filter(data, info))
Exemple #4
0
def get_watchlist_by_name(name='Default', info=None):
    """Returns a list of information related to the stocks in a single watchlist.

    :param name: The name of the watchlist to get data from.
    :type name: Optional[str]
    :param info: Will filter the results to get a specific value.
    :type info: Optional[str]
    :returns: Returns a list of dictionaries that contain the instrument urls and a url that references itself.

    """
    url = urls.watchlists(name)
    data = helper.request_get(url, 'pagination')
    return(helper.filter(data, info))
Exemple #5
0
def post_symbols_to_watchlist(inputSymbols, name='Default'):
    """Posts multiple stock tickers to a watchlist.

    :param inputSymbols: May be a single stock ticker or a list of stock tickers.
    :type inputSymbols: str or list
    :param name: The name of the watchlist to post data to.
    :type name: Optional[str]
    :returns: Returns result of the post request.

    """
    symbols = helper.inputs_to_set(inputSymbols)
    payload = {'symbols': ','.join(symbols)}
    url = urls.watchlists(name, True)
    data = helper.request_post(url, payload)

    return (data)
Exemple #6
0
def post_symbols_to_watchlist(*inputSymbols, name='Default'):
    """Posts multiple stock tickers to a watchlist.

    :param inputSymbols: This is a variable length parameter that represents a stock ticker. \
    May be several tickers seperated by commas or a list of tickers.
    :type inputSymbols: str or list
    :param name: The name of the watchlist to post data to.
    :type name: Optional[str]
    :returns: Returns result of the post request.

    """
    symbols = helper.inputs_to_set(inputSymbols)
    payload = {'symbols': ','.join(symbols)}
    url = urls.watchlists(name, True)
    data = helper.request_post(url, payload)

    return (data)
Exemple #7
0
def get_watchlist_by_name(name='Default', info=None):
    """Returns a list of information related to the stocks in a single watchlist.

    :param name: The name of the watchlist to get data from.
    :type name: Optional[str]
    :param info: Will filter the results to get a specific value.
    :type info: Optional[str]
    :returns: Returns a list of dictionaries that contain the instrument urls and a url that references itself.

    """

    #Get id of requested watchlist
    all_watchlists = get_all_watchlists()
    watchlist_id = ''
    for wl in all_watchlists['results']:
        if wl['display_name'] == name:
            watchlist_id = wl['id']

    url = urls.watchlists(name)
    data = helper.request_get(url, 'list_id', {'list_id': watchlist_id})
    return (helper.filter(data, info))