Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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()
        res = dict(current_holdings=current_holdings)
    finally:
        v.close_browser()
        if res is None:
            return rInternalServerError

    return jsonify(res)
Exemplo n.º 4
0
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")
Exemplo n.º 5
0
 def setUp(self):
     self.v = Vanguard()
Exemplo n.º 6
0
class TestBrowser(TestCase):
    def setUp(self):
        self.v = Vanguard()

    def tearDown(self):
        self.v.close_browser()

    def test_can_login(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

    def test_can_get_security_question(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)
        question = self.v.get_security_question()

    def test_can_answer_security_question(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)
        question = self.v.get_security_question()

        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.assertIsNotNone(answer)

        self.v.answer_security_question(answer)

    def test_can_go_to_balances_and_holdings(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.go_to_balances_and_holdings()
        self.assertEqual(self.v.browser.title, "Balances and holdings")

    def test_can_get_total_assets(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.get_total_assets()

    def test_can_get_current_holdings(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.get_current_holdings()
Exemplo n.º 7
0
 def setUp(self):
     self.v = Vanguard()
Exemplo n.º 8
0
class TestBrowser(TestCase):
    def setUp(self):
        self.v = Vanguard()

    def tearDown(self):
        self.v.close_browser()

    def test_can_login(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

    def test_can_get_security_question(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)
        question = self.v.get_security_question()

    def test_can_answer_security_question(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)
        question = self.v.get_security_question()

        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.assertIsNotNone(answer)

        self.v.answer_security_question(answer)

    def test_can_go_to_balances_and_holdings(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.go_to_balances_and_holdings()
        self.assertEqual(self.v.browser.title, "Balances and holdings")

    def test_can_get_total_assets(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.get_total_assets()

    def test_can_get_current_holdings(self):
        self.v.login(tests_config.TEST_USER, tests_config.TEST_PASSWORD)

        question = self.v.get_security_question()
        answer = tests_config.TEST_SECURITY_QUESTIONS.get(question)
        self.v.answer_security_question(answer)

        self.v.get_current_holdings()
Exemplo n.º 9
0
                           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.")