Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.Security


        @Override
        protected IStatus run(IProgressMonitor monitor)
        {
            try
            {
                Security s = new Security();
                s.setIsin(model.getIsin());
                if (exchange != null)
                    s.setTickerSymbol(exchange.getId());
                s.setFeed(feed.getId());
                s.setFeedURL(model.getFeedURL());

                // last 2 months as sample
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.MONTH, -2);
View Full Code Here


        });
    }

    private void fillContextMenu(IMenuManager manager)
    {
        final Security security = (Security) ((IStructuredSelection) securities.getSelection()).getFirstElement();
        if (security == null)
            return;

        manager.add(new AbstractDialogAction(Messages.SecurityMenuBuy)
        {
            @Override
            Dialog createDialog(Security security)
            {
                return new BuySellSecurityDialog(getShell(), getClient(), security, PortfolioTransaction.Type.BUY);
            }
        });

        manager.add(new AbstractDialogAction(Messages.SecurityMenuSell)
        {
            @Override
            Dialog createDialog(Security security)
            {
                return new BuySellSecurityDialog(getShell(), getClient(), security, PortfolioTransaction.Type.SELL);
            }
        });

        manager.add(new AbstractDialogAction(Messages.SecurityMenuDividends)
        {
            @Override
            Dialog createDialog(Security security)
            {
                return new DividendsDialog(getShell(), getClient(), null, security);
            }
        });

        manager.add(new AbstractDialogAction(Messages.SecurityMenuStockSplit)
        {
            @Override
            Dialog createDialog(Security security)
            {
                StockSplitWizard wizard = new StockSplitWizard(getClient(), security);
                return new WizardDialog(getShell(), wizard);
            }
        });

        manager.add(new Separator());

        manager.add(new AbstractDialogAction(Messages.SecurityMenuEditSecurity)
        {
            @Override
            Dialog createDialog(Security security)
            {
                return new EditSecurityDialog(getShell(), getClient(), security);
            }

            @Override
            protected void performFinish(Security security)
            {
                super.performFinish(security);
                updateQuotes(security);
            }
        });
        manager.add(new Separator());

        manager.add(new Action(Messages.SecurityMenuUpdateQuotes)
        {
            @Override
            public void run()
            {
                updateQuotes(security);
            }
        });
        manager.add(new AbstractDialogAction(Messages.SecurityMenuImportQuotes)
        {
            @Override
            Dialog createDialog(Security security)
            {
                return new WizardDialog(getShell(), new ImportQuotesWizard(security));
            }
        });

        manager.add(new Separator());
        manager.add(new WebLocationMenu(security));

        manager.add(new Separator());
        if (watchlist == null)
        {
            manager.add(new Action(Messages.SecurityMenuDeleteSecurity)
            {
                @Override
                public void run()
                {
                    if (!security.getTransactions(getClient()).isEmpty())
                    {
                        MessageDialog.openError(getShell(), Messages.MsgDeletionNotPossible,
                                        MessageFormat.format(Messages.MsgDeletionNotPossibleDetail, security.getName()));
                    }
                    else
                    {

                        getClient().removeSecurity(security);
View Full Code Here

    @Override
    protected void okPressed()
    {
        ((AbstractPage) tabFolder.getSelection().getData()).afterPage();

        Security security = model.getSecurity();
        boolean hasQuotes = !security.getPrices().isEmpty();
        boolean providerChanged = (model.getFeed() != null ? !model.getFeed().equals(security.getFeed()) : security
                        .getFeed() != null)
                        || (model.getTickerSymbol() != null ? !model.getTickerSymbol().equals(
                                        security.getTickerSymbol()) : security.getTickerSymbol() != null);

        model.applyChanges();

        if (hasQuotes && providerChanged)
        {
            MessageDialog dialog = new MessageDialog(getShell(), //
                            Messages.MessageDialogProviderChanged, null, //
                            Messages.MessageDialogProviderChangedText, //
                            MessageDialog.QUESTION, //
                            new String[] { Messages.MessageDialogProviderAnswerKeep,
                                            Messages.MessageDialogProviderAnswerReplace }, 0);
            if (dialog.open() == 1)
                security.removeAllPrices();
        }

        super.okPressed();
    }
View Full Code Here

        if (!doCreate)
            return null;

        String key = isin != null ? isin : tickerSymbol != null ? tickerSymbol : wkn;
        Security security = new Security(MessageFormat.format(Messages.CSVImportedSecurityLabel, key), isin,
                        tickerSymbol, QuoteFeed.MANUAL);
        security.setWkn(wkn);
        client.addSecurity(security);

        return security;
    }
View Full Code Here

            String tickerSymbol = getTextValue(Messages.CSVColumn_TickerSymbol, rawValues, field2column);
            String wkn = getTextValue(Messages.CSVColumn_WKN, rawValues, field2column);

            if (isin != null || tickerSymbol != null || wkn != null)
            {
                Security security = lookupSecurity(client, isin, tickerSymbol, wkn, true);
                transaction.setSecurity(security);
            }

            if (type != null)
                transaction.setType(type);
View Full Code Here

                        throws ParseException
        {
            if (!(target instanceof Security))
                throw new IllegalArgumentException();

            Security security = (Security) target;

            Date date = convertDate(Messages.CSVColumn_Date, rawValues, field2column);
            if (date == null)
                throw new ParseException(MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Date),
                                0);

            Long amount = convertAmount(Messages.CSVColumn_Quote, rawValues, field2column);
            if (amount == null)
                throw new ParseException(
                                MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Quote), 0);

            security.addPrice(new SecurityPrice(date, Math.abs(amount)));
        }
View Full Code Here

            if (isin == null && tickerSymbol == null && wkn == null)
                throw new ParseException(MessageFormat.format(Messages.CSVImportMissingOneOfManyFields,
                                Messages.CSVColumn_ISIN + ", " + Messages.CSVColumn_TickerSymbol + ", " //$NON-NLS-1$ //$NON-NLS-2$
                                                + Messages.CSVColumn_WKN), 0);

            Security security = lookupSecurity(client, isin, tickerSymbol, wkn, false);
            if (security != null)
                throw new ParseException(MessageFormat.format(Messages.CSVImportSecurityExists, security.getName(),
                                isin != null ? isin : tickerSymbol != null ? tickerSymbol : wkn), 0);

            String description = getTextValue(Messages.CSVColumn_Description, rawValues, field2column);
            if (description == null)
                description = MessageFormat.format(Messages.CSVImportedSecurityLabel, isin != null ? isin
                                : tickerSymbol != null ? tickerSymbol : wkn);

            String feed = QuoteFeed.MANUAL;
            if (tickerSymbol != null)
                feed = YahooFinanceQuoteFeed.ID;

            security = new Security(description, isin, tickerSymbol, feed);
            security.setWkn(wkn);
            client.addSecurity(security);
        }
View Full Code Here

        }
    }

    private void addSecurity(DataSeries item, List<Exception> warnings)
    {
        Security security = (Security) item.getInstance();
        PerformanceIndex securityIndex = (PerformanceIndex) dataCache.get(security);
        if (securityIndex == null)
        {
            securityIndex = PerformanceIndex.forInvestment(getClient(), security, getReportingPeriod(), warnings);
            dataCache.put(security, securityIndex);
        }

        ILineSeries series = chart.addDateSeries(securityIndex.getDates(), //
                        toDouble(securityIndex.getTotals(), Values.Amount.divider()), //
                        security.getName());
        item.configure(series);
    }
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.