def emailer(alerts): c = Client(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) c.get_protected(endpoint='/user/detail/') watchlist = c.results['_results_']['watchlist'] funds = c.results['_results_']['funds'] watchlist_ciks = ','.join([str(x['cik']) for x in watchlist]) funds_ciks = ','.join([str(x['cik']) for x in funds]) alerts.watchlist_filter(watchlist=watchlist_ciks, funds=funds_ciks, subscribed_alerts=SUBSCRIBED_ALERTS) for alert in alerts.email_alerts: """Handle email alerts""" print alert
def make_api_request(endpoint, params={}, headers={}): """A handler to make api requests to api.jivedata.com. For test data, if the endpoint is a /list/ change it to /new/ and if the endpoint is /detail/ then set the 'test' parameter""" if app.config['test_data'] == True: if endpoint in ['/filings/list/', '/insiders/list/', '/13F/list/', '/econ/list/']: endpoint = endpoint.replace('/list/', '/new/') elif endpoint in ['/financials/detail/', '/econ/detail/', '/13F/detail/']: params['test'] = True client = Client(client_id=app.config['client_id'], client_secret=app.config['client_secret']) client.get_protected(endpoint=endpoint, params=params) return client.results