Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.SecurityPrice


    public void testCapitalGainsWithPartialSellDuringReportPeriodWithFees()
    {
        Client client = new Client();

        Security security = new Security();
        security.addPrice(new SecurityPrice(Dates.date(2010, Calendar.JANUARY, 1), 10000));
        security.addPrice(new SecurityPrice(Dates.date(2011, Calendar.JUNE, 1), 11000));
        client.addSecurity(security);

        Portfolio portfolio = new Portfolio();
        portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010, Calendar.JANUARY, 1), security,
                        PortfolioTransaction.Type.BUY, 1000000, 100, 0, 0));
View Full Code Here


        for (AccountSnapshot a : accounts)
        {
            SecurityPosition sp = new SecurityPosition(null);
            sp.setShares(Values.Share.factor());
            sp.setPrice(new SecurityPrice(getTime(), a.getFunds()));
            answer.put(a.getAccount(), new AssetPosition(a.getAccount(), sp, assets));
        }
        return answer;
    }
View Full Code Here

        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);
View Full Code Here

                {
                    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);
                    }
View Full Code Here

            dates = new Date[prices.size()];
            values = new double[prices.size()];
        }
        else
        {
            index = Math.abs(Collections.binarySearch(prices, new SecurityPrice(chartPeriod, 0),
                            new SecurityPrice.ByDate()));

            if (index >= prices.size())
            {
                // no data available
                chart.redraw();
                return;
            }

            dates = new Date[prices.size() - index];
            values = new double[prices.size() - index];
        }

        for (int ii = 0; index < prices.size(); index++, ii++)
        {
            SecurityPrice p = prices.get(index);
            dates[ii] = p.getTime();
            values[ii] = p.getValue() / Values.Quote.divider();
        }

        ILineSeries lineSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, Messages.ColumnQuote);
        lineSeries.setXDateSeries(dates);
        lineSeries.setLineWidth(2);
View Full Code Here

    {
        List<LatestSecurityPrice> quotes = reviewPage.getQuotes();

        for (LatestSecurityPrice p : quotes)
        {
            SecurityPrice quote = new SecurityPrice(p.getTime(), p.getValue());
            security.addPrice(quote);
        }

        return true;
    }
View Full Code Here

            {
                iter.remove();
            }
            else
            {
                SecurityPrice price = p.getSecurity().getSecurityPrice(time);
                p.setPrice(price);
            }
        }

        return new PortfolioSnapshot(portfolio, time, collection);
View Full Code Here

        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

                        QuoteFeed.MANUAL);
    }

    public SecurityBuilder addPrice(String date, long price)
    {
        SecurityPrice p = new SecurityPrice(new DateTime(date).toDate(), price);
        security.addPrice(p);
        return this;
    }
View Full Code Here

        return this;
    }

    public SecurityBuilder generatePrices(long startPrice, DateMidnight start, DateMidnight end)
    {
        security.addPrice(new SecurityPrice(start.toDate(), startPrice));

        Random random = new Random();

        DateMidnight date = start;
        long price = startPrice;
        while (date.compareTo(end) < 0)
        {
            date = date.plusDays(1);

            if (date.getDayOfWeek() > DateTimeConstants.SATURDAY)
                continue;

            price = (long) ((double) price * ((random.nextDouble() * 0.2 - 0.1d) + 1));
            security.addPrice(new SecurityPrice(date.toDate(), price));
        }

        return this;
    }
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.