def vanguard_current_holdings(): try: user = auth() except AuthenticationFailed: return rAuthError try: vanguard_user = VanguardUser(user) except KeyError: return rNotEnrolled res = None try: v = Vanguard() v.login(vanguard_user.username, vanguard_user.password) question = v.get_security_question() answer = vanguard_user.security_questions.get(question) v.answer_security_question(answer) current_holdings = v.get_current_holdings() finally: v.close_browser() if len(current_holdings) == 0: return rInternalServerError return jsonify(current_holdings)
def vanguard_total_assets(): try: user = auth() except AuthenticationFailed: return rAuthError try: vanguard_user = VanguardUser(user) except KeyError: return rNotEnrolled res = None try: v = Vanguard() v.login(vanguard_user.username, vanguard_user.password) question = v.get_security_question() answer = vanguard_user.security_questions.get(question) v.answer_security_question(answer) total_assets = v.get_total_assets() res = dict(total=total_assets) finally: v.close_browser() if res is None: return rInternalServerError return jsonify(res)
def post_message(): weekday = datetime.now().isoweekday() if 0 < weekday < 6: team_a_vanguard = Vanguard('team_a.json') team_b_vanguard = Vanguard('team_b.json') greeting = Greetings().get_greeting() client = WebClient(token=bot_token) client.chat_postMessage( channel=channel_id, link_names='true', text= f"<!here|here> {greeting} Today's vanguard for team a is: {team_a_vanguard.name}. And the vanguard for team b is: {team_b_vanguard.name}. Please direct all team related questions to <@{team_a_vanguard.slack_id}> and <@{team_b_vanguard.slack_id}>" ) team_a_vanguard.update_member() team_b_vanguard.update_member() else: print("not a week day")
def setUp(self): self.v = Vanguard()
port=DB_PORT, user=DB_USERNAME, passwd=DB_PASSWORD, db=DB_DATABASE) cur = conn.cursor() cur.execute(query) cur.close() conn.commit() conn.close() execute_query(db_create_query) print("Created database") vanguard = Vanguard(EMAIL, PASSWORD) vanguard.login() values = vanguard.get_data() for value in values: print("Found value of %s for %s" % (value['value'], value['name'])) insert_query = "INSERT INTO vanguard_investments (Name, Value, RecordDateTime) values ('%s', %s, '%s')" % ( value['name'], value['value'], strftime("%Y-%m-%d %H:%M:%S")) execute_query(insert_query) print("Inserted data points.")