Examples of Portfolio


Examples of name.abuchen.portfolio.model.Portfolio

        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

Examples of name.abuchen.portfolio.model.Portfolio

                    .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

Examples of name.abuchen.portfolio.model.Portfolio

    }

    @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

Examples of name.abuchen.portfolio.model.Portfolio

    }

    @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

Examples of name.abuchen.portfolio.model.Portfolio

    }

    @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

Examples of name.abuchen.portfolio.model.Portfolio

        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

Examples of name.abuchen.portfolio.model.Portfolio

    {
        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();
                    }
View Full Code Here

Examples of name.abuchen.portfolio.model.Portfolio

        {
            new AccountContextMenu(view).menuAboutToShow(manager, element.getAccount());
        }
        else if (element.isSecurity())
        {
            Portfolio portfolio = portfolioSnapshot != null ? portfolioSnapshot.getSource() : null;
            new SecurityContextMenu(view).menuAboutToShow(manager, element.getSecurity(), portfolio);
        }
    }
View Full Code Here

Examples of name.abuchen.portfolio.model.Portfolio

    public static PortfolioSnapshot merge(List<PortfolioSnapshot> snapshots)
    {
        if (snapshots.isEmpty())
            throw new RuntimeException("Error: PortfolioSnapshots to be merged must not be empty"); //$NON-NLS-1$

        Portfolio portfolio = new Portfolio();
        portfolio.setName(Messages.LabelJointPortfolio);

        Map<Security, SecurityPosition> securities = new HashMap<Security, SecurityPosition>();
        for (PortfolioSnapshot s : snapshots)
        {
            portfolio.addAllTransaction(s.getSource().getTransactions());
            for (SecurityPosition p : s.getPositions())
            {
                SecurityPosition pos = securities.get(p.getSecurity());
                if (pos == null)
                    securities.put(p.getSecurity(), p);
View Full Code Here

Examples of name.abuchen.portfolio.model.Portfolio

    public void setupClient()
    {
        client = new Client();
        account = new Account();
        client.addAccount(account);
        portfolio = new Portfolio();
        client.addPortfolio(portfolio);
        security = new Security();
        client.addSecurity(security);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.