def setUp(self):
        self.account1 = ClientAccountFactory.create()
        self.broker_acc1 = IBAccountFactory.create(bs_account=self.account1, ib_account=IB_ACC_1)
        self.goal1 = GoalFactory.create(account=self.account1)

        self.account2 = ClientAccountFactory.create()
        self.goal2 = GoalFactory.create(account=self.account2)
        self.broker_acc2 = IBAccountFactory.create(bs_account=self.account2, ib_account=IB_ACC_2)

        self.ticker1 = TickerFactory.create(symbol='GOOG')
        self.ticker2 = TickerFactory.create(symbol='AAPL')
示例#2
0
    def setUp(self):
        super(FirmAnalyticsMixinTests, self).setUp()
        self.support_group = GroupFactory(name=GROUP_SUPPORT_STAFF)
        self.bonds_type = InvestmentType.Standard.BONDS.get()
        self.stocks_type = InvestmentType.Standard.STOCKS.get()

        self.view = self.DummyView()
        self.today = today = timezone.now().date()
        # Populate the AccountType -> RiskProfileGroup mapping
        for atid, _ in constants.ACCOUNT_TYPES:
            AccountTypeRiskProfileGroupFactory.create(account_type=atid)
        # first client
        self.betasmartz_client = ClientFactory.create()
        self.client_account = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client,
            account_type=constants.ACCOUNT_TYPE_PERSONAL)
        self.firm = self.betasmartz_client.advisor.firm

        self.external_asset1 = ExternalAssetFactory.create(
            owner=self.betasmartz_client)
        self.external_asset2 = ExternalAssetFactory.create(
            owner=self.betasmartz_client)
        self.goal = GoalFactory.create(account=self.client_account)
        self.goal2 = GoalFactory.create(account=self.client_account)
        self.transaction = TransactionFactory.create(
            to_goal=self.goal,
            from_goal=self.goal2,
            amount=self.goal.cash_balance,
            status=Transaction.STATUS_EXECUTED,
            reason=Transaction.REASON_TRANSFER,
            executed=self.today)

        # second client
        self.betasmartz_client2 = ClientFactory.create(
            advisor=self.betasmartz_client.advisor)
        self.client_account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2,
            account_type=constants.ACCOUNT_TYPE_PERSONAL)
        self.external_asset1 = ExternalAssetFactory.create(
            owner=self.betasmartz_client2)
        self.external_asset2 = ExternalAssetFactory.create(
            owner=self.betasmartz_client2)

        self.goal3 = GoalFactory.create(account=self.client_account2)
        self.goal4 = GoalFactory.create(account=self.client_account2)
        self.transaction2 = TransactionFactory.create(
            to_goal=self.goal3,
            from_goal=self.goal4,
            amount=self.goal3.cash_balance,
            status=Transaction.STATUS_EXECUTED,
            reason=Transaction.REASON_TRANSFER,
            executed=self.today)
示例#3
0
    def setUp(self):
        self.account1 = ClientAccountFactory.create()
        self.goal1 = GoalFactory.create(account=self.account1)

        self.account2 = ClientAccountFactory.create()
        self.goal2 = GoalFactory.create(account=self.account2)

        self.account3 = ClientAccountFactory.create()
        self.goal3 = GoalFactory.create(account=self.account3)

        self.ticker1 = TickerFactory.create(symbol='GOOG')
        self.ticker2 = TickerFactory.create(symbol='AAPL')
        self.ticker3 = TickerFactory.create(symbol='MSFT')
示例#4
0
    def setUp(self):
        for atid, _ in constants.ACCOUNT_TYPES:
            AccountTypeRiskProfileGroupFactory.create(account_type=atid)
        self.today = today = date(2016, 5, 1)
        self.older_fiscal_year = FiscalYearFactory.create()
        self.older_fiscal_year2 = FiscalYearFactory.create()
        self.current_fiscal_year = FiscalYearFactory.create(
            year=today.year,
            begin_date=datetime(year=today.year, month=1, day=1),
            end_date=datetime(year=today.year, month=12, day=31))
        self.firm = FirmFactory.create()
        self.firm.fiscal_years.add(self.older_fiscal_year)
        self.firm.fiscal_years.add(self.older_fiscal_year2)
        self.firm.fiscal_years.add(self.current_fiscal_year)
        # add an advisor for the firm
        self.advisor = AdvisorFactory.create(firm=self.firm)
        # add a client account for the firm
        self.betasmartz_client = ClientFactory.create(advisor=self.advisor)
        self.client_account = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client)
        # add some goals
        self.goal1 = GoalFactory.create(account=self.client_account)
        self.goal2 = GoalFactory.create(account=self.client_account)
        # add some transaction fees associated with the goals
        # there are two fees here, one for the from_goal1, and one for the to_goal2
        self.fee1 = TransactionFactory.create(
            reason=Transaction.REASON_FEE,
            status=Transaction.STATUS_EXECUTED,
            from_goal=self.goal1,
            to_goal=self.goal2,
            amount=500,
            executed=today - relativedelta(months=1))

        # add new advisor to firm
        # add new clientacounts for advisor and fees
        self.advisor2 = AdvisorFactory.create(firm=self.firm)
        self.betasmartz_client2 = ClientFactory.create(advisor=self.advisor2)
        self.client_account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2)
        self.goal3 = GoalFactory.create(account=self.client_account2)
        # add some more fees
        self.fee2 = TransactionFactory.create(
            reason=Transaction.REASON_FEE,
            status=Transaction.STATUS_EXECUTED,
            to_goal=self.goal3,
            amount=800,
            executed=self.older_fiscal_year.begin_date +
            relativedelta(months=1))
    def setUp(self):
        self.broker = ETNABroker()
        self.account1 = ClientAccountFactory.create()
        self.broker_acc1 = APEXAccountFactory.create(bs_account=self.account1)
        self.goal1 = GoalFactory.create(account=self.account1)

        self.account2 = ClientAccountFactory.create()
        self.goal2 = GoalFactory.create(account=self.account2)
        self.broker_acc2 = IBAccountFactory.create(bs_account=self.account2)

        self.account3 = ClientAccountFactory.create()
        self.goal3 = GoalFactory.create(account=self.account3)
        self.broker_acc3 = IBAccountFactory.create(bs_account=self.account3)

        self.ticker1 = TickerFactory.create(symbol='GOOG')
        self.ticker2 = TickerFactory.create(symbol='AAPL')
        self.ticker3 = TickerFactory.create(symbol='MSFT')
    def setUp(self):
        self.support_group = GroupFactory(name=GROUP_SUPPORT_STAFF)
        self.account = ClientAccountFactory.create()

        self.advisor = self.account.primary_owner.advisor
        self.firm = self.advisor.firm
        self.advisor2 = AdvisorFactory.create(firm=self.firm)
        self.betasmartz_client2 = ClientFactory.create(advisor=self.advisor2)
        self.account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2)
        self.account_group = AccountGroupFactory.create(advisor=self.advisor)
        self.account_group2 = AccountGroupFactory.create(advisor=self.advisor2)
        self.account.account_group = self.account_group
        self.account.save()
        self.account2.account_group = self.account_group2
        self.account2.save()
        self.rep = AuthorisedRepresentativeFactory.create(firm=self.firm)
示例#7
0
 def test_apex_order3(self):
     self.account3 = ClientAccountFactory.create()
     self.goal3 = GoalFactory.create(account=self.account3)
     self.mor3 = MarketOrderRequestFactory.create(account=self.account3)
     er5 = ExecutionRequestFactory.create(goal=self.goal3,
                                          asset=self.asset,
                                          volume=20,
                                          order=self.mor3)
     create_apex_orders()
     etna_orders = OrderETNA.objects.all()
     self.assertTrue(len(etna_orders) == 2)
     self.assertTrue(etna_orders[0].Quantity == 35)
示例#8
0
    def test_get_firm_analytics_worth_and_risk_filter(self):
        # /firm/analytics?worth=affluent&risk=0&risk=20&advisor=&client=
        url = reverse('firm:analytics') + '?worth=affluent&risk=0&risk=20&advisor=&client='
        rep = AuthorisedRepresentativeFactory.create(firm=self.firm)
        advisor = AdvisorFactory.create(firm=self.firm)
        aclient = ClientFactory.create(advisor=advisor)
        aaccount = ClientAccountFactory.create(primary_owner=aclient)
        goal = GoalFactory.create(account=aaccount)

        self.client.login(username=rep.user.email, password='******')
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
示例#9
0
 def test_apex_order2(self):
     self.account2 = ClientAccountFactory.create()
     self.goal2 = GoalFactory.create(account=self.account2)
     self.mor2 = MarketOrderRequestFactory.create(account=self.account2)
     self.asset3 = TickerFactory.create(symbol='MSFT')
     er4 = ExecutionRequestFactory.create(goal=self.goal2,
                                          asset=self.asset3,
                                          volume=20,
                                          order=self.mor2)
     create_apex_orders()
     etna_order = OrderETNA.objects.all()
     self.assertTrue(len(etna_order) == 3)
     self.assertTrue(etna_order[2].Quantity == 20)
示例#10
0
    def setUp(self):
        self.account = ClientAccountFactory.create()
        self.goal = GoalFactory.create(account=self.account)
        self.mor = MarketOrderRequestFactory.create(account=self.account)

        self.asset = TickerFactory.create(symbol='GOOG')
        self.asset2 = TickerFactory.create(symbol='AAPL')
        er1 = ExecutionRequestFactory.create(goal=self.goal,
                                             asset=self.asset,
                                             volume=5,
                                             order=self.mor)
        er2 = ExecutionRequestFactory.create(goal=self.goal,
                                             asset=self.asset,
                                             volume=10,
                                             order=self.mor)
        er3 = ExecutionRequestFactory.create(goal=self.goal,
                                             asset=self.asset2,
                                             volume=10,
                                             order=self.mor)
    def setUp(self):

        # employed, client over 50 years old
        self.betasmartz_client = ClientFactory.create(
            employment_status=constants.EMPLOYMENT_STATUS_EMMPLOYED,
            date_of_birth=datetime.now().date() - relativedelta(years=60))
        self.betasmartz_client.regional_data['tax_transcript_data'] = {
            'sections': [{
                'name': 'Introduction',
                'fields': {
                    'SPOUSE NAME': 'SPOUSE M LAST',
                    'SPOUSE SSN': '222-22-2222',
                    'ADDRESS': '999 AVENUE RD  CITY, ST 10.000-90.00-800',
                    'NAME': 'FIRST M',
                    'SSN': '111-11-1111',
                    'FILING STATUS': 'Single'
                }
            }, {
                'name': 'Income',
                'fields': {
                    'TOTAL INCOME': '$0.00'
                }
            }]
        }
        self.betasmartz_client.save()
        # personal account
        self.account = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client)
        self.plan = RetirementPlanFactory.create(client=self.betasmartz_client)
        self.plan_account = RetirementPlanAccountFactory.create(
            plan=self.plan, account=self.account)

        # 401k
        self.account2 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client,
            account_type=constants.ACCOUNT_TYPE_401K)
        self.plan2 = RetirementPlanFactory.create(
            client=self.betasmartz_client,
            income=100000,
            max_employer_match_percent=.05)
        self.plan_account2 = RetirementPlanAccountFactory.create(
            plan=self.plan2, account=self.account2)

        # roth IRA
        self.account5 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client,
            account_type=constants.ACCOUNT_TYPE_ROTHIRA)
        self.plan5 = RetirementPlanFactory.create(
            client=self.betasmartz_client,
            income=100000,
            max_employer_match_percent=.05)
        self.plan_account5 = RetirementPlanAccountFactory.create(
            plan=self.plan5, account=self.account5)

        # unemployed, client 40 years old
        self.unemployed_client = ClientFactory.create(
            employment_status=constants.EMPLOYMENT_STATUS_UNEMPLOYED,
            date_of_birth=datetime.now().date() - relativedelta(years=40))
        self.unemployed_client.regional_data['tax_transcript_data'] = {
            'sections': [{
                'name': 'Introduction',
                'fields': {
                    'SPOUSE NAME': 'SPOUSE M LAST',
                    'SPOUSE SSN': '222-22-2222',
                    'ADDRESS': '999 AVENUE RD  CITY, ST 10.000-90.00-800',
                    'NAME': 'FIRST M',
                    'SSN': '111-11-1111',
                    'FILING STATUS': 'Single'
                }
            }, {
                'name': 'Income',
                'fields': {
                    'TOTAL INCOME': '$0.00'
                }
            }]
        }
        self.unemployed_client.save()
        # personal account
        self.account3 = ClientAccountFactory.create(
            primary_owner=self.unemployed_client)
        self.plan3 = RetirementPlanFactory.create(
            client=self.unemployed_client)
        self.plan_account3 = RetirementPlanAccountFactory.create(
            plan=self.plan3, account=self.account3)

        # employed, client over 50 years old, 150k+ income
        self.betasmartz_client2 = ClientFactory.create(
            employment_status=constants.EMPLOYMENT_STATUS_EMMPLOYED,
            date_of_birth=datetime.now().date() - relativedelta(years=60))
        self.betasmartz_client2.regional_data['tax_transcript_data'] = {
            'sections': [{
                'name': 'Introduction',
                'fields': {
                    'SPOUSE NAME': 'SPOUSE M LAST',
                    'SPOUSE SSN': '222-22-2222',
                    'ADDRESS': '999 AVENUE RD  CITY, ST 10.000-90.00-800',
                    'NAME': 'FIRST M',
                    'SSN': '111-11-1111',
                    'FILING STATUS': 'Single'
                }
            }, {
                'name': 'Income',
                'fields': {
                    'TOTAL INCOME': '$0.00'
                }
            }]
        }
        self.betasmartz_client2.save()

        # personal account
        self.account6 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2)
        self.plan6 = RetirementPlanFactory.create(
            client=self.betasmartz_client2, income=150000)
        self.plan_account6 = RetirementPlanAccountFactory.create(
            plan=self.plan6, account=self.account6)

        # 401k
        self.account7 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2,
            account_type=constants.ACCOUNT_TYPE_401K)
        self.plan7 = RetirementPlanFactory.create(
            client=self.betasmartz_client2,
            income=150000,
            max_employer_match_percent=.05)
        self.plan_account7 = RetirementPlanAccountFactory.create(
            plan=self.plan7, account=self.account7)

        # roth IRA
        self.account8 = ClientAccountFactory.create(
            primary_owner=self.betasmartz_client2,
            account_type=constants.ACCOUNT_TYPE_ROTHIRA)
        self.plan8 = RetirementPlanFactory.create(
            client=self.betasmartz_client2,
            income=150000,
            max_employer_match_percent=.05)
        self.plan_account8 = RetirementPlanAccountFactory.create(
            plan=self.plan8, account=self.account8)

        # unemployed, client 40 years old 150k+ income
        self.unemployed_client2 = ClientFactory.create(
            employment_status=constants.EMPLOYMENT_STATUS_UNEMPLOYED,
            date_of_birth=datetime.now().date() - relativedelta(years=40))
        self.unemployed_client2.regional_data['tax_transcript_data'] = {
            'sections': [{
                'name': 'Introduction',
                'fields': {
                    'SPOUSE NAME': 'SPOUSE M LAST',
                    'SPOUSE SSN': '222-22-2222',
                    'ADDRESS': '999 AVENUE RD  CITY, ST 10.000-90.00-800',
                    'NAME': 'FIRST M',
                    'SSN': '111-11-1111',
                    'FILING STATUS': 'Single'
                }
            }, {
                'name': 'Income',
                'fields': {
                    'TOTAL INCOME': '$0.00'
                }
            }]
        }
        self.unemployed_client2.save()
        # personal account
        self.account9 = ClientAccountFactory.create(
            primary_owner=self.unemployed_client2)
        self.plan9 = RetirementPlanFactory.create(
            client=self.unemployed_client2, income=150000)
        self.plan_account9 = RetirementPlanAccountFactory.create(
            plan=self.plan9, account=self.account9)