Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.Account


                        .addPrice("2012-01-03", 106 * Values.Quote.factor()) //
                        .addPrice("2012-01-08", 112 * Values.Quote.factor()) //
                        .assign(taxonomy, "one", weight) //
                        .addTo(client);

        Account account = new AccountBuilder() //
                        .deposit_("2011-12-31", 10000 * Values.Amount.factor()) //
                        .interest("2012-01-01", 230 * Values.Amount.factor()) //
                        .deposit_("2012-01-02", 200 * Values.Amount.factor()) //
                        .interest("2012-01-02", 200 * Values.Amount.factor()) //
                        .withdraw("2012-01-03", 400 * Values.Amount.factor()) //
View Full Code Here


    @Test
    public void testDepositPlusInterest()
    {
        Client client = new Client();

        Account account = new Account();
        account.addTransaction(new AccountTransaction(Dates.date(2010, Calendar.JANUARY, 1), null,
                        AccountTransaction.Type.DEPOSIT, 100000));
        account.addTransaction(new AccountTransaction(Dates.date(2011, Calendar.JUNE, 1), null,
                        AccountTransaction.Type.INTEREST, 5000));
        client.addAccount(account);

        ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, startDate, endDate);
        assertNotNull(snapshot);
View Full Code Here

    @Test
    public void testDepositPlusInterestFirstDay()
    {
        Client client = new Client();

        Account account = new Account();
        account.addTransaction(new AccountTransaction(Dates.date(2010, Calendar.JANUARY, 1), null,
                        AccountTransaction.Type.DEPOSIT, 100000));
        account.addTransaction(new AccountTransaction(Dates.date(2010, Calendar.DECEMBER, 31), null,
                        AccountTransaction.Type.INTEREST, 5000));
        client.addAccount(account);

        ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, startDate, endDate);
View Full Code Here

    @Test
    public void testDepositPlusInterestLastDay()
    {
        Client client = new Client();

        Account account = new Account();
        account.addTransaction(new AccountTransaction(Dates.date(2010, Calendar.JANUARY, 1), null,
                        AccountTransaction.Type.DEPOSIT, 100000));
        account.addTransaction(new AccountTransaction(Dates.date(2011, Calendar.DECEMBER, 31), null,
                        AccountTransaction.Type.INTEREST, 5000));
        client.addAccount(account);

        ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, startDate, endDate);
View Full Code Here

        Portfolio portfolio = new Portfolio();
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), security,
                        PortfolioTransaction.Type.BUY, 10, 100, 0, 0));
        client.addPortfolio(portfolio);

        Account account = new Account();
        account.addTransaction(new AccountTransaction(Dates.date(2011, Calendar.JANUARY, 31), security,
                        AccountTransaction.Type.INTEREST, 5000));
        client.addAccount(account);

        ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, startDate, endDate);
View Full Code Here

        return PerformanceIndex.forClient(pseudoClient, reportInterval, warnings);
    }

    private static void addSecurity(Client pseudoClient, Client client, Security security, int weight)
    {
        Account pseudoAccount = new Account();
        pseudoAccount.setName(""); //$NON-NLS-1$
        pseudoClient.addAccount(pseudoAccount);

        Portfolio pseudoPortfolio = new Portfolio();
        pseudoPortfolio.setReferenceAccount(pseudoAccount);
        pseudoClient.addPortfolio(pseudoPortfolio);

        pseudoClient.addSecurity(security);

        for (Portfolio p : client.getPortfolios())
        {
            for (PortfolioTransaction t : p.getTransactions())
            {
                if (t.getSecurity().equals(security))
                {
                    long shares = value(t.getShares(), weight);
                    long amount = value(t.getAmount(), weight);
                    long fees = value(t.getFees(), weight);
                    long taxes = value(t.getTaxes(), weight);

                    switch (t.getType())
                    {
                        case BUY:
                        case TRANSFER_IN:
                        {
                            pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(),
                                            PortfolioTransaction.Type.DELIVERY_INBOUND, shares, amount, fees, taxes));
                            break;
                        }
                        case SELL:
                        case TRANSFER_OUT:
                            pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(),
                                            PortfolioTransaction.Type.DELIVERY_OUTBOUND, shares, amount, fees, taxes));
                            break;
                        case DELIVERY_INBOUND:
                        case DELIVERY_OUTBOUND:
                            pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(), t
                                            .getType(), shares, amount, fees, taxes));
                            break;
                        default:
                            throw new UnsupportedOperationException();
                    }
                }
            }
        }

        for (Account a : client.getAccounts())
        {
            for (AccountTransaction t : a.getTransactions())
            {
                if (security.equals(t.getSecurity()))
                {
                    switch (t.getType())
                    {
                        case DIVIDENDS:
                            long amount = value(t.getAmount(), weight);
                            pseudoAccount.addTransaction(new AccountTransaction(t.getDate(), t.getSecurity(),
                                            AccountTransaction.Type.DIVIDENDS, amount));
                            pseudoAccount.addTransaction(new AccountTransaction(t.getDate(), t.getSecurity(),
                                            AccountTransaction.Type.REMOVAL, amount));
                            break;
                        case BUY:
                        case TRANSFER_IN:
                        case SELL:
View Full Code Here

        }
    }

    private static void addAccount(Client pseudoClient, Account account, int weight)
    {
        Account pseudoAccount = new Account();
        pseudoAccount.setName(account.getName());
        pseudoClient.addAccount(pseudoAccount);

        for (AccountTransaction t : account.getTransactions())
        {
            long amount = value(t.getAmount(), weight);
            switch (t.getType())
            {
                case SELL:
                case TRANSFER_IN:
                case DIVIDENDS:
                    pseudoAccount.addTransaction(new AccountTransaction(t.getDate(), t.getSecurity(),
                                    AccountTransaction.Type.DEPOSIT, amount));
                    break;
                case BUY:
                case TRANSFER_OUT:
                    pseudoAccount.addTransaction(new AccountTransaction(t.getDate(), t.getSecurity(),
                                    AccountTransaction.Type.REMOVAL, amount));
                    break;
                case DEPOSIT:
                case REMOVAL:
                case INTEREST:
                case TAXES:
                case FEES:
                    if (weight != Classification.ONE_HUNDRED_PERCENT)
                        pseudoAccount.addTransaction(new AccountTransaction(t.getDate(), null, t.getType(), amount));
                    else
                        pseudoAccount.addTransaction(t);
                    break;
                default:
                    throw new UnsupportedOperationException();
            }
        }
View Full Code Here

{
    @Test
    public void testThatSecurityIsFoundByISIN_whenImportingAccountTransactions() throws ParseException
    {
        Client client = buildClient();
        Account account = client.getAccounts().get(0);

        AccountTransactionDef def = new AccountTransactionDef();

        def.build(client, account, //
                        new String[] { "2013-01-01", "DE0007164600", "", "", "100", "" }, //
                        buildField2Column(def));

        AccountTransaction t = account.getTransactions().get(account.getTransactions().size() - 1);
        assertThat(t.getAmount(), is(100L * Values.Amount.factor()));
        assertThat(t.getDate(), is(Dates.date(2013, Calendar.JANUARY, 1)));
        assertThat(t.getSecurity(), is(client.getSecurities().get(0)));
        assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    }
View Full Code Here

    @Test
    public void testThatSecurityIsFoundByTicker_whenImportingAccountTransactions() throws ParseException
    {
        Client client = buildClient();
        Account account = client.getAccounts().get(0);

        AccountTransactionDef def = new AccountTransactionDef();

        def.build(client, account, //
                        new String[] { "2013-01-01", "", "SAP.DE", "", "200", "DIVIDENDS" }, //
                        buildField2Column(def));

        AccountTransaction t = account.getTransactions().get(account.getTransactions().size() - 1);
        assertThat(t.getAmount(), is(200L * Values.Amount.factor()));
        assertThat(t.getDate(), is(Dates.date(2013, Calendar.JANUARY, 1)));
        assertThat(t.getSecurity(), is(client.getSecurities().get(0)));
        assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    }
View Full Code Here

    @Test
    public void testThatSecurityIsFoundByWKN_whenImportingAccountTransactions() throws ParseException
    {
        Client client = buildClient();
        Account account = client.getAccounts().get(0);

        AccountTransactionDef def = new AccountTransactionDef();

        def.build(client, account, //
                        new String[] { "2013-01-01", "", "", "716460", "300", "FEES" }, //
                        buildField2Column(def));

        AccountTransaction t = account.getTransactions().get(account.getTransactions().size() - 1);
        assertThat(t.getAmount(), is(300L * Values.Amount.factor()));
        assertThat(t.getDate(), is(Dates.date(2013, Calendar.JANUARY, 1)));
        assertThat(t.getSecurity(), is(client.getSecurities().get(0)));
        assertThat(t.getType(), is(AccountTransaction.Type.FEES));
    }
View Full Code Here

TOP

Related Classes of name.abuchen.portfolio.model.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.