Examples of LatestSecurityPrice


Examples of name.abuchen.portfolio.model.LatestSecurityPrice

            {
                return columnIndex == 0 ? element.toString() : null;
            }
            else
            {
                LatestSecurityPrice p = (LatestSecurityPrice) element;
                switch (columnIndex)
                {
                    case 0:
                        return Values.Date.format(p.getTime());
                    case 1:
                        return Values.Quote.format(p.getHigh());
                    case 2:
                        return Values.Quote.format(p.getLow());
                    case 3:
                        return Values.Quote.format(p.getValue());
                    case 4:
                        return String.format("%,d", p.getVolume()); //$NON-NLS-1$
                }
            }
            return null;
        }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

        List<Exception> errors = new ArrayList<Exception>();
        feed.updateLatestQuotes(securities, errors);
        assertThat(errors.size(), is(0));

        LatestSecurityPrice latest = securities.get(0).getLatest();
        assertThat(latest.getValue(), is(1371L));
        assertThat(latest.getTime(), equalTo(Dates.date(2011, Calendar.SEPTEMBER, 29)));
        assertThat(latest.getHigh(), is(1375L));
        assertThat(latest.getLow(), is(1370L));
        assertThat(latest.getVolume(), is(10037));
        assertThat(latest.getPreviousClose(), is(1271L));

        latest = securities.get(1).getLatest();
        assertThat(latest.getHigh(), is(-1L));
        assertThat(latest.getLow(), is(-1L));
        assertThat(latest.getVolume(), is(-1));

        latest = securities.get(3).getLatest();
        assertThat(latest.getTime(), equalTo(Dates.today()));
    }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

        List<Exception> errors = new ArrayList<Exception>();
        feed.updateLatestQuotes(securities, errors);

        // not first, but second security must have value
        LatestSecurityPrice latest = adidas.getLatest();
        assertThat(latest.getValue(), is(4920L));

        assertThat(errors.size(), is(1));

        assertThat(errors.get(0).getMessage(), containsString(daimler.getTickerSymbol()));
    }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

                long previousClose = asPrice(values[5]);

                int volume = asNumber(values[6]);

                LatestSecurityPrice price = new LatestSecurityPrice(lastTradeDate, lastTrade);
                price.setHigh(daysHigh);
                price.setLow(daysLow);
                price.setPreviousClose(previousClose);
                price.setVolume(volume);

                boolean isAdded = security.setLatest(price);
                isUpdated = isUpdated || isAdded;
            }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

        price.setTime(date);
        price.setValue(v);

        if (price instanceof LatestSecurityPrice)
        {
            LatestSecurityPrice latest = (LatestSecurityPrice) price;

            q = priceFormat.parse(values[5]);
            latest.setVolume(q.intValue());

            q = priceFormat.parse(values[2]);
            latest.setHigh((long) (q.doubleValue() * 100));

            q = priceFormat.parse(values[3]);
            latest.setLow((long) (q.doubleValue() * 100));
        }
    }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

            {
                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;

                LatestSecurityPrice l1 = (LatestSecurityPrice) p1;
                LatestSecurityPrice l2 = (LatestSecurityPrice) p2;

                double v1 = (((double) (l1.getValue() - l1.getPreviousClose())) / l1.getPreviousClose() * 100);
                double v2 = (((double) (l2.getValue() - l2.getPreviousClose())) / l2.getPreviousClose() * 100);
                return Double.compare(v1, v2);
            }
        }));
        support.addColumn(column);
    }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

            int size = quotes.size();
            if (size > 0)
            {
                Collections.sort(quotes);

                LatestSecurityPrice latest = quotes.get(size - 1);
                LatestSecurityPrice previous = size > 1 ? quotes.get(size - 2) : null;
                latest.setPreviousClose(previous != null ? previous.getValue() : latest.getValue());

                boolean isAdded = security.setLatest(latest);
                isUpdated = isUpdated || isAdded;
            }
        }
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

                {
                    Element row = rows.get(rowIndex);

                    try
                    {
                        LatestSecurityPrice price = extractPrice(row, specs);
                        if (price != null)
                            prices.add(price);
                    }
                    catch (Exception e)
                    {
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

        // row can be empty if it contains only 'th' elements
        if (cells.size() == 0)
            return null;

        LatestSecurityPrice price = new LatestSecurityPrice();

        for (Spec spec : specs)
            spec.column.read(cells.get(spec.index), price);

        return price;
View Full Code Here

Examples of name.abuchen.portfolio.model.LatestSecurityPrice

                valueVolume.setText(EMPTY_LABEL);
                valuePreviousClose.setText(EMPTY_LABEL);
            }
            else
            {
                LatestSecurityPrice p = security.getLatest();

                valueLatestPrices.setText(Values.Amount.format(p.getValue()));
                valueLatestTrade.setText(Values.Date.format(p.getTime()));
                long daysHigh = p.getHigh();
                valueDaysHigh.setText(daysHigh == -1 ? Messages.LabelNotAvailable : Values.Amount.format(daysHigh));
                long daysLow = p.getLow();
                valueDaysLow.setText(daysLow == -1 ? Messages.LabelNotAvailable : Values.Amount.format(daysLow));
                long volume = p.getVolume();
                valueVolume.setText(volume == -1 ? Messages.LabelNotAvailable : String.format("%,d", volume)); //$NON-NLS-1$
                long prevClose = p.getPreviousClose();
                valuePreviousClose.setText(prevClose == -1 ? Messages.LabelNotAvailable : Values.Amount
                                .format(prevClose));
            }
        }
View Full Code Here
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.