Package name.abuchen.portfolio.snapshot

Source Code of name.abuchen.portfolio.snapshot.PortfolioSnapshotTest

package name.abuchen.portfolio.snapshot;

import static org.junit.Assert.assertTrue;
import name.abuchen.portfolio.PortfolioBuilder;
import name.abuchen.portfolio.SecurityBuilder;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.model.Portfolio;
import name.abuchen.portfolio.model.Security;

import org.joda.time.DateTime;
import org.junit.Test;

@SuppressWarnings("nls")
public class PortfolioSnapshotTest
{

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

        Security a = new SecurityBuilder() //
                        .addPrice("2010-01-01", 1000) //
                        .addTo(client);

        Portfolio portfolio = new PortfolioBuilder() //
                        .buy(a, "2010-01-01", 1000000, 10000) //
                        .sell(a, "2010-01-02", 700000, 12000) //
                        .sell(a, "2010-01-03", 300000, 12000) //
                        .addTo(client);

        PortfolioSnapshot snapshot = PortfolioSnapshot.create(portfolio, new DateTime("2010-01-31").toDate());

        assertTrue(snapshot.getPositions().isEmpty());
    }
}
TOP

Related Classes of name.abuchen.portfolio.snapshot.PortfolioSnapshotTest

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.