Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.PortfolioTransaction


    @Test
    public void testThatTransferInDoesNotCountIfMatchingTransferOutIsIncluded()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.JANUARY, 1), null, Type.BUY,
                        50 * Values.Share.factor(), 50000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_OUT, 50 * Values.Share.factor(), 55000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_IN, 50 * Values.Share.factor(), 55000, 0, 0));

        position.setPrice(new SecurityPrice(Dates.date(2012, Calendar.DECEMBER, 2), 2000));

        assertEquals(50 * Values.Share.factor(), position.getShares());
View Full Code Here


    @Test
    public void testThatOnlyMatchingTransfersAreRemoved_InRemains()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.JANUARY, 1), null, Type.BUY,
                        50 * Values.Share.factor(), 50000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_OUT, 50 * Values.Share.factor(), 55000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_IN, 50 * Values.Share.factor(), 55000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 2), null,
                        Type.TRANSFER_IN, 50 * Values.Share.factor(), 55000, 0, 0));

        position.setPrice(new SecurityPrice(Dates.date(2012, Calendar.DECEMBER, 2), 2000));

        assertEquals(100 * Values.Share.factor(), position.getShares());
View Full Code Here

    @Test
    public void testThatOnlyMatchingTransfersAreRemoved_OutRemains()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.JANUARY, 1), null, Type.BUY,
                        50 * Values.Share.factor(), 50000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_OUT, 50 * Values.Share.factor(), 55000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_IN, 50 * Values.Share.factor(), 55000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 2), null,
                        Type.TRANSFER_OUT, 25 * Values.Share.factor(), 55000, 0, 0));

        position.setPrice(new SecurityPrice(Dates.date(2012, Calendar.DECEMBER, 2), 2000));

        assertEquals(25 * Values.Share.factor(), position.getShares());
View Full Code Here

    @Test
    public void testPurchasePriceIfSharesArePartiallyTransferredOut()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.JANUARY, 1), null, Type.BUY,
                        50 * Values.Share.factor(), 50000, 0, 0));

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.FEBRUARY, 1), null,
                        Type.TRANSFER_OUT, 25 * Values.Share.factor(), 55000, 0, 0));

        position.setPrice(new SecurityPrice(Dates.date(2012, Calendar.DECEMBER, 2), 2000));

        assertEquals(25 * Values.Share.factor(), position.getShares());
View Full Code Here

        securityX = new Security();
        securityX.addPrice(new SecurityPrice(Dates.date(2010, Calendar.JANUARY, 1), 1200));
        client.addSecurity(securityX);

        Portfolio portfolioA = new Portfolio();
        portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), securityA,
                        PortfolioTransaction.Type.BUY, 1000000, 10000, 0, 0));
        portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), securityX,
                        PortfolioTransaction.Type.BUY, 1000000, 12100, 100, 0));
        client.addPortfolio(portfolioA);

        Portfolio portfolioB = new Portfolio();
        portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), securityB,
                        PortfolioTransaction.Type.BUY, 1000000, 11000, 0, 0));
        portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), securityX,
                        PortfolioTransaction.Type.BUY, 1000000, 10000, 0, 0));
        client.addPortfolio(portfolioB);
    }
View Full Code Here

    @Test
    public void testFIFOPurchasePrice()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.BUY, 100 * Values.Share.factor(),
                        100000, 0, 0));
        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.SELL, 50 * Values.Share.factor(),
                        50000, 0, 0));

        assertEquals(50 * Values.Share.factor(), position.getShares());
        assertEquals(1000L, position.getFIFOPurchasePrice());
    }
View Full Code Here

    @Test
    public void testPurchasePriceWithMultipleBuyTransactions()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.BUY, 25 * Values.Share.factor(),
                        25000, 0, 0));
        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.BUY, 75 * Values.Share.factor(),
                        150000, 0, 0));
        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.SELL, 50 * Values.Share.factor(),
                        100000, 0, 0));

        assertEquals(50 * Values.Share.factor(), position.getShares());
        assertEquals(2000L, position.getFIFOPurchasePrice());
    }
View Full Code Here

    @Test
    public void testPurchasePriceWithMultipleBuyTransactionsMiddlePrice()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.BUY, 75 * Values.Share.factor(),
                        75000, 0, 0));
        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.BUY, 25 * Values.Share.factor(),
                        50000, 0, 0));
        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.SELL, 50 * Values.Share.factor(),
                        100000, 0, 0));

        assertEquals(50 * Values.Share.factor(), position.getShares());
        assertEquals(1500L, position.getFIFOPurchasePrice());
    }
View Full Code Here

    @Test
    public void testPurchasePriceNaNIfOnlySellTransactions()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.today(), null, Type.SELL, 50 * Values.Share.factor(),
                        50000, 0, 0));

        assertEquals(-50 * Values.Share.factor(), position.getShares());
        assertEquals(0L, position.getFIFOPurchasePrice());
    }
View Full Code Here

    @Test
    public void testThatTransferInCountsIfTransferOutIsMissing()
    {
        SecurityPosition position = new SecurityPosition(new Security());

        position.addTransaction(new PortfolioTransaction(Dates.date(2012, Calendar.JANUARY, 1), null, Type.TRANSFER_IN,
                        50 * Values.Share.factor(), 50000, 0, 0));

        position.setPrice(new SecurityPrice(Dates.date(2012, Calendar.DECEMBER, 2), 2000));

        assertEquals(50 * Values.Share.factor(), position.getShares());
View Full Code Here

TOP

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

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.