Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.Security


    @Test
    public void testWhenSharesHeldGoToZero()
    {
        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) //
View Full Code Here


    @Override
    public void onModified(Object element, Object newValue, Object oldValue)
    {
        // called from prices table
        Security security = (Security) prices.getData(Security.class.toString());

        // if the date changed, the prices must be reordered --> binary search
        if (newValue instanceof Date)
        {
            SecurityPrice price = (SecurityPrice) element;
            security.removePrice(price);
            security.addPrice(price);
        }

        securities.refresh(security);
        prices.refresh(element);
        latest.setInput(security);
        transactions.setInput(security.getTransactions(getClient()));
        events.setInput(security.getEvents());
        updateChart(security);

        markDirty();
    }
View Full Code Here

            public boolean select(Viewer viewer, Object parentElement, Object element)
            {
                if (filterPattern == null)
                    return true;

                Security security = (Security) element;

                String[] properties = new String[] { security.getName(), //
                                security.getIsin(), //
                                security.getTickerSymbol(), //
                                security.getWkn(), //
                                security.getNote() //
                };

                for (String property : properties)
                {
                    if (property != null && filterPattern.matcher(property).matches())
View Full Code Here

            @Override
            public void widgetSelected(SelectionEvent e)
            {
                chartPeriod = null;

                Security security = (Security) prices.getData(Security.class.toString());
                updateChart(security);
            }
        });

        // tab 2: historical quotes
View Full Code Here

            manager.add(new Action(Messages.SecurityMenuAddPrice)
            {
                @Override
                public void run()
                {
                    Security security = (Security) prices.getData(Security.class.toString());
                    if (security == null)
                        return;

                    SecurityPrice price = new SecurityPrice();
                    price.setTime(Dates.today());

                    security.addPrice(price);

                    markDirty();

                    prices.setInput(security.getPrices());
                    latest.setInput(security);
                    transactions.setInput(security.getTransactions(getClient()));
                    events.setInput(security.getEvents());
                    updateChart(security);

                    prices.setSelection(new StructuredSelection(price), true);
                    prices.editElement(price, 0);
                }
            });
            manager.add(new Separator());
        }

        if (((IStructuredSelection) prices.getSelection()).getFirstElement() != null)
        {
            manager.add(new Action(Messages.SecurityMenuDeletePrice)
            {
                @Override
                public void run()
                {
                    Security security = (Security) prices.getData(Security.class.toString());
                    if (security == null)
                        return;

                    Iterator<?> iter = ((IStructuredSelection) prices.getSelection()).iterator();
                    while (iter.hasNext())
                    {
                        SecurityPrice price = (SecurityPrice) iter.next();
                        if (price == null)
                            continue;

                        security.removePrice(price);
                    }

                    markDirty();

                    prices.setInput(security.getPrices());
                    latest.setInput(security);
                    transactions.setInput(security.getTransactions(getClient()));
                    events.setInput(security.getEvents());
                    updateChart(security);
                }
            });
        }

        if (prices.getTable().getItemCount() > 0)
        {
            manager.add(new Action(Messages.SecurityMenuDeleteAllPrices)
            {
                @Override
                public void run()
                {
                    Security security = (Security) prices.getData(Security.class.toString());
                    if (security == null)
                        return;

                    security.removeAllPrices();

                    markDirty();

                    prices.setInput(security.getPrices());
                    latest.setInput(security);
                    transactions.setInput(security.getTransactions(getClient()));
                    events.setInput(security.getEvents());
                    updateChart(security);
                }
            });
        }

        if (isSecuritySelected)
        {
            manager.add(new Separator());
            manager.add(new Action(Messages.SecurityMenuUpdateQuotes)
            {
                @Override
                public void run()
                {
                    Security security = (Security) prices.getData(Security.class.toString());
                    if (security != null)
                        securities.updateQuotes(security);
                }
            });
            manager.add(new Action(Messages.SecurityMenuImportQuotes)
            {
                @Override
                public void run()
                {
                    Security security = (Security) prices.getData(Security.class.toString());
                    if (security == null)
                        return;

                    Dialog dialog = new WizardDialog(getActiveShell(), new ImportQuotesWizard(security));
                    if (dialog.open() != Dialog.OK)
View Full Code Here

        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

    @Test
    public void testThatPortfolioTransactionIsImported() throws ParseException
    {
        Client client = buildClient();
        Portfolio portfolio = client.getPortfolios().get(0);
        Security security = client.getSecurities().get(0);

        PortfolioTransactionDef def = new PortfolioTransactionDef();

        def.build(client, portfolio, //
                        new String[] { "2013-01-01", security.getIsin(), "", "", "1000,00", "10,00", "11,00", "1,234",
                                        "BUY" }, //
                        buildField2Column(def));

        PortfolioTransaction t = portfolio.getTransactions().get(portfolio.getTransactions().size() - 1);
        assertThat(t.getSecurity(), is(security));
View Full Code Here

    @Test
    public void testThatSecurityPriceIsImported() throws ParseException
    {
        Client client = buildClient();
        Security security = client.getSecurities().get(0);

        SecurityPriceDef def = new SecurityPriceDef();

        def.build(client, security, //
                        new String[] { "2013-01-01", "123,45" }, //
                        buildField2Column(def));

        SecurityPrice price = security.getSecurityPrice(Dates.date(2013, Calendar.JANUARY, 1));
        assertThat(price.getValue(), is(12345L));
    }
View Full Code Here

        def.build(client, Messages.CSVDefSecurityMasterData, //
                        new String[] { "DE0008404005", "ALV.DE", "840400", "Allianz", "" }, //
                        buildField2Column(def));

        Security s = client.getSecurities().get(client.getSecurities().size() - 1);
        assertThat(s.getName(), is("Allianz"));
        assertThat(s.getIsin(), is("DE0008404005"));
        assertThat(s.getTickerSymbol(), is("ALV.DE"));
        assertThat(s.getWkn(), is("840400"));
    }
View Full Code Here

        Portfolio portfolio = new Portfolio();
        portfolio.setName("test");
        portfolio.setReferenceAccount(account);
        client.addPortfolio(portfolio);

        Security security = new Security();
        security.setName("SAP AG");
        security.setIsin("DE0007164600");
        security.setWkn("716460");
        security.setTickerSymbol("SAP.DE");
        client.addSecurity(security);

        return client;
    }
View Full Code Here

TOP

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

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.