Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.Portfolio


        Security security = new Security();
        security.addPrice(new SecurityPrice(Dates.date(2010, Calendar.JANUARY, 1), 10000));
        security.addPrice(new SecurityPrice(Dates.date(2011, Calendar.JUNE, 1), 11000));
        client.addSecurity(security);

        Portfolio portfolio = new Portfolio();
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), security,
                        PortfolioTransaction.Type.BUY, 1000000, 100, 0, 0));
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011, Calendar.JANUARY, 15), security,
                        PortfolioTransaction.Type.SELL, 100000, 9900, 0, 0));
        client.addPortfolio(portfolio);

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


        Security security = new Security();
        security.addPrice(new SecurityPrice(Dates.date(2010, Calendar.JANUARY, 1), 10000));
        security.addPrice(new SecurityPrice(Dates.date(2011, Calendar.JUNE, 1), 11000));
        client.addSecurity(security);

        Portfolio portfolio = new Portfolio();
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), security,
                        PortfolioTransaction.Type.BUY, 1000000, 100, 0, 0));
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011, Calendar.JANUARY, 15), security,
                        PortfolioTransaction.Type.SELL, 100000, 9900, 1, 0));
        client.addPortfolio(portfolio);

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

        Client client = new Client();

        Security security = new SecurityBuilder() //
                        .addTo(client);

        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(security, "2010-01-01", 109 * Values.Share.factor(), 314920) //
                        .sell(security, "2010-02-01", 15 * Values.Share.factor(), 53150) //
                        .buy(security, "2010-03-01", 52 * Values.Share.factor(), 168492) //
                        .buy(security, "2010-03-01", 32 * Values.Share.factor(), 95930) //
                        .addTo(client);

        CostCalculation cost = new CostCalculation();
        cost.visitAll(portfolio.getTransactions());

        // expected:
        // 3149,20 - round(3149,20 * 15/109) + 1684,92 + 959,30 = 5360,04385

        assertThat(cost.getFifoCost(), is(536005L));
View Full Code Here

        Client client = new Client();

        Security security = new SecurityBuilder() //
                        .addTo(client);

        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(security, "2010-01-01", 10 * Values.Share.factor(), 1) //
                        .sell(security, "2010-02-01", 3 * Values.Share.factor(), 1) //
                        .sell(security, "2010-03-01", 3 * Values.Share.factor(), 1) //
                        .sell(security, "2010-03-01", 4 * Values.Share.factor(), 1) //
                        .addTo(client);

        CostCalculation cost = new CostCalculation();
        cost.visitAll(portfolio.getTransactions());

        assertThat(cost.getFifoCost(), is(0L));
    }
View Full Code Here

        Client client = new Client();

        Security security = new SecurityBuilder() //
                        .addTo(client);

        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(security, "2010-01-01", 100 * Values.Share.factor(), 314920) //
                        .sell(security, "2010-02-01", 100 * Values.Share.factor(), 53150) //
                        .buy(security, "2010-03-01", 50 * Values.Share.factor(), 168492) //
                        .sell(security, "2010-04-01", 50 * Values.Share.factor(), 53150) //
                        .addTo(client);

        CostCalculation cost = new CostCalculation();
        cost.visitAll(portfolio.getTransactions());

        assertThat(cost.getFifoCost(), is(0L));
    }
View Full Code Here

                    .addTo(client);

    @Test
    public void testBuyIsPreferredOverSell()
    {
        Portfolio portfolio = new PortfolioBuilder() //
                        .sell(security, "2010-01-01", 100, 100) //
                        .buy(security, "2010-01-01", 100, 100) //
                        .addTo(client);

        List<PortfolioTransaction> list = portfolio.getTransactions();

        Collections.sort(list, new TransactionComparator());

        assertThat(list.get(0).getType(), is(Type.BUY));
        assertThat(list.get(1).getType(), is(Type.SELL));
View Full Code Here

    }

    @Test
    public void testBuyIsPreferredOverSell2()
    {
        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(security, "2010-01-01", 100, 100) //
                        .sell(security, "2010-01-01", 100, 100) //
                        .addTo(client);

        List<PortfolioTransaction> list = portfolio.getTransactions();

        Collections.sort(list, new TransactionComparator());

        assertThat(list.get(0).getType(), is(Type.BUY));
        assertThat(list.get(1).getType(), is(Type.SELL));
View Full Code Here

    }

    @Test
    public void testTwoInboundTransactionsStay()
    {
        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(security, "2010-01-01", 1, 100) //
                        .buy(security, "2010-01-01", 2, 100) //
                        .addTo(client);

        List<PortfolioTransaction> list = portfolio.getTransactions();

        Collections.sort(list, new TransactionComparator());

        assertThat(list.get(0).getShares(), is(1L));
        assertThat(list.get(1).getShares(), is(2L));
View Full Code Here

    }

    @Test
    public void testThatDatePreceedsType()
    {
        Portfolio portfolio = new PortfolioBuilder() //
                        .sell(security, "2010-01-01", 100, 100) //
                        .buy(security, "2010-01-02", 100, 100) //
                        .addTo(client);

        List<PortfolioTransaction> list = portfolio.getTransactions();

        Collections.sort(list, new TransactionComparator());

        assertThat(list.get(0).getType(), is(Type.SELL));
        assertThat(list.get(1).getType(), is(Type.BUY));
View Full Code Here

        for (Portfolio portfolio : client.getPortfolios())
            snapshot.portfolios.add(PortfolioSnapshot.create(portfolio, time));

        if (snapshot.portfolios.isEmpty())
            snapshot.jointPortfolio = PortfolioSnapshot.create(new Portfolio(), time);
        else if (snapshot.portfolios.size() == 1)
            snapshot.jointPortfolio = snapshot.portfolios.get(0);
        else
            snapshot.jointPortfolio = PortfolioSnapshot.merge(snapshot.portfolios);
View Full Code Here

TOP

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

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.