Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.SecurityPrice


            if (a.getFunds() == 0)
                continue;

            SecurityPosition sp = new SecurityPosition(null);
            sp.setShares(Values.Share.factor());
            sp.setPrice(new SecurityPrice(snapshot.getTime(), a.getFunds()));
            vehicle2position.put(a.getAccount(), new Item(sp));
        }

        // portfolio
        if (snapshot.getJointPortfolio() != null)
View Full Code Here


        fiveYearsAgo.add(Calendar.YEAR, -5);

        Calendar cal = feed.caculateStart(security);
        assertThat(cal, equalTo(fiveYearsAgo));

        security.addPrice(new SecurityPrice(Dates.today(), 100));
        cal = feed.caculateStart(security);
        assertThat(cal.getTime(), equalTo(Dates.today()));
    }
View Full Code Here

        feed.updateHistoricalQuotes(security, new ArrayList<Exception>());

        assertThat(security.getPrices().size(), is(2257));

        assertThat(security.getPrices().get(0), //
                        equalTo(new SecurityPrice(Dates.date(2003, Calendar.JANUARY, 1), 2935)));

        assertThat(security.getPrices().get(security.getPrices().size() - 1),
                        equalTo(new SecurityPrice(Dates.date(2011, Calendar.SEPTEMBER, 22), 3274)));
    }
View Full Code Here

        feed.updateHistoricalQuotes(security, new ArrayList<Exception>());

        assertThat(security.getPrices().size(), is(2257));

        assertThat(security.getPrices().get(0), //
                        equalTo(new SecurityPrice(Dates.date(2003, Calendar.JANUARY, 1), 2255)));

        assertThat(security.getPrices().get(security.getPrices().size() - 1),
                        equalTo(new SecurityPrice(Dates.date(2011, Calendar.SEPTEMBER, 22), 3274)));
    }
View Full Code Here

                Security security = node.getBackingSecurity();
                if (security == null)
                    return null;

                SecurityPrice price = security.getSecurityPrice(Dates.today());
                return Values.Quote.format(price.getValue());
            }
        });
        support.addColumn(column);

        column = new Column("deltashares", Messages.ColumnDeltaShares, SWT.RIGHT, 100); //$NON-NLS-1$
View Full Code Here

        Calendar start = Calendar.getInstance();
        start.setTime(Dates.today());

        if (!security.getPrices().isEmpty())
        {
            SecurityPrice lastHistoricalQuote = security.getPrices().get(security.getPrices().size() - 1);
            start.setTime(lastHistoricalQuote.getTime());
        }
        else
        {
            start.add(Calendar.YEAR, -5);
        }
View Full Code Here

                int[] indices = new int[export.size()];

                int ii = 0;
                for (Security security : export)
                {
                    SecurityPrice p = new SecurityPrice(cal.getTime(), 0);
                    indices[ii] = Collections.binarySearch(security.getPrices(), p);
                    ii++;
                }

                boolean hasValues = false;
View Full Code Here

            return null;
        }

        public String getColumnText(Object element, int columnIndex)
        {
            SecurityPrice p = (SecurityPrice) element;
            switch (columnIndex)
            {
                case 0:
                    return Values.Date.format(p.getTime());
                case 1:
                    return Values.Quote.format(p.getValue());
                case 2:
                    if (model.isChangeHistoricalQuotes() && p.getTime().before(model.getExDate()))
                    {
                        long shares = p.getValue() * model.getOldShares() / model.getNewShares();
                        return Values.Quote.format(shares);
                    }
                    return null;
                default:
                    return null;
View Full Code Here

        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                SecurityPrice latest = ((Security) e).getSecurityPrice(Dates.today());
                return latest != null ? Values.Quote.format(latest.getValue()) : null;
            }
        });
        column.setSorter(ColumnViewerSorter.create(new Comparator<Object>()
        {
            @Override
            public int compare(Object o1, Object o2)
            {
                SecurityPrice p1 = ((Security) o1).getSecurityPrice(Dates.today());
                SecurityPrice p2 = ((Security) o2).getSecurityPrice(Dates.today());

                if (p1 == null)
                    return p2 == null ? 0 : -1;
                if (p2 == null)
                    return 1;

                long v1 = p1.getValue();
                long v2 = p2.getValue();
                return v1 > v2 ? 1 : v1 == v2 ? 0 : -1;
            }
        }));
        support.addColumn(column);
    }
View Full Code Here

        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                SecurityPrice price = ((Security) e).getSecurityPrice(Dates.today());
                if (!(price instanceof LatestSecurityPrice))
                    return null;

                LatestSecurityPrice latest = (LatestSecurityPrice) price;
                return String.format("%,.2f %%", //$NON-NLS-1$
                                ((double) (latest.getValue() - latest.getPreviousClose()) / (double) latest
                                                .getPreviousClose()) * 100);
            }

            @Override
            public Color getForeground(Object element)
            {
                SecurityPrice price = ((Security) element).getSecurityPrice(Dates.today());
                if (!(price instanceof LatestSecurityPrice))
                    return null;

                LatestSecurityPrice latest = (LatestSecurityPrice) price;
                return latest.getValue() >= latest.getPreviousClose() ? Display.getCurrent().getSystemColor(
                                SWT.COLOR_DARK_GREEN) : Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
            }
        });
        column.setSorter(ColumnViewerSorter.create(new Comparator<Object>()
        {
            @Override
            public int compare(Object o1, Object o2)
            {
                SecurityPrice p1 = ((Security) o1).getSecurityPrice(Dates.today());
                SecurityPrice p2 = ((Security) o2).getSecurityPrice(Dates.today());

                if (!(p1 instanceof LatestSecurityPrice))
                    return p2 == null ? 0 : -1;
                if (!(p2 instanceof LatestSecurityPrice))
                    return 1;
View Full Code Here

TOP

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

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.