def delete_from_watchlist(symbol, wl_id): """ removes a single "symbols" (str) from watchlist. Returns True on success, False on failure """ params = ST_BASE_PARAMS.copy() params['symbols'] = symbol resp = R.post_json(ST_BASE_URL + 'watchlists/{}/symbols/destroy.json'.format(wl_id), params=params) if resp['response']['status'] == 200: return True else: return False
def add_to_watchlist(symbols, wl_id): """ Adds list of symbols to our StockTwits watchlist. Returns list of new symbols added """ deadline = 30 * len(symbols) symbols = ','.join(symbols) # must be a csv list params = ST_BASE_PARAMS.copy() params['symbols'] = symbols resp = R.post_json(ST_BASE_URL + 'watchlists/{}/symbols/create.json'.format(wl_id), params=params, deadline=deadline) if resp['response']['status'] == 200: return [s['symbol'] for s in resp['symbols']] else: return []