Search in sources :

Example 46 with SecurityPrice

use of name.abuchen.portfolio.model.SecurityPrice in project portfolio by buchen.

the class SimpleMovingAverage method determineStartPrice.

private SecurityPrice determineStartPrice(LocalDate smaPeriodEnd) {
    // check if an SMA can be calculated for this Date
    List<SecurityPrice> filteredPrices = null;
    LocalDate isBefore = smaPeriodEnd.plusDays(1);
    LocalDate isAfter = smaPeriodEnd.minusDays(rangeSMA);
    LocalDate lastDate = prices.get(prices.size() - 1).getDate();
    filteredPrices = this.getFilteredList(isBefore, isAfter);
    int i = 1;
    while (!this.checkListIsValidForSMA(filteredPrices)) {
        if (isBefore.plusDays(i).isAfter(lastDate) || isAfter.plusDays(i).isAfter(lastDate))
            return null;
        filteredPrices = this.getFilteredList(isBefore.plusDays(i), isAfter.plusDays(i));
        i++;
    }
    return filteredPrices.get(filteredPrices.size() - 1);
}
Also used : SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) LocalDate(java.time.LocalDate)

Example 47 with SecurityPrice

use of name.abuchen.portfolio.model.SecurityPrice in project portfolio by buchen.

the class CSVImportWizard method importSecurityPrices.

private boolean importSecurityPrices() {
    Security security = target != null ? target : selectSecurityPage.getSelectedSecurity();
    List<SecurityPrice> prices = importer.createItems(new ArrayList<>()).get(0).getSecurity().getPrices();
    boolean isDirty = false;
    for (SecurityPrice p : prices) {
        if (security.addPrice(p))
            isDirty = true;
    }
    return isDirty;
}
Also used : ArrayList(java.util.ArrayList) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Security(name.abuchen.portfolio.model.Security)

Example 48 with SecurityPrice

use of name.abuchen.portfolio.model.SecurityPrice in project portfolio by buchen.

the class ImportQuotesWizard method performFinish.

@Override
public boolean performFinish() {
    List<LatestSecurityPrice> quotes = reviewPage.getQuotes();
    for (LatestSecurityPrice p : quotes) {
        SecurityPrice quote = new SecurityPrice(p.getDate(), p.getValue());
        security.addPrice(quote);
    }
    return true;
}
Also used : LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Example 49 with SecurityPrice

use of name.abuchen.portfolio.model.SecurityPrice in project portfolio by buchen.

the class HTMLTableQuoteFeed method updateHistoricalQuotes.

@Override
public boolean updateHistoricalQuotes(Security security, List<Exception> errors) {
    List<LatestSecurityPrice> quotes = internalGetQuotes(security, security.getFeedURL(), errors);
    boolean isUpdated = false;
    for (LatestSecurityPrice quote : quotes) {
        boolean isAdded = security.addPrice(new SecurityPrice(quote.getDate(), quote.getValue()));
        isUpdated = isUpdated || isAdded;
    }
    return isUpdated;
}
Also used : LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Example 50 with SecurityPrice

use of name.abuchen.portfolio.model.SecurityPrice in project portfolio by buchen.

the class AlphavantageQuoteFeed method updateHistoricalQuotes.

@Override
public boolean updateHistoricalQuotes(Security security, List<Exception> errors) {
    OutputSize outputSize = OutputSize.FULL;
    if (!security.getPrices().isEmpty()) {
        SecurityPrice lastHistoricalQuote = security.getPrices().get(security.getPrices().size() - 1);
        int days = Dates.daysBetween(lastHistoricalQuote.getDate(), LocalDate.now());
        outputSize = days >= DAYS_THRESHOLD ? OutputSize.FULL : OutputSize.COMPACT;
    }
    List<SecurityPrice> prices = getHistoricalQuotes(SecurityPrice.class, security, outputSize, errors);
    boolean isUpdated = false;
    for (SecurityPrice p : prices) {
        boolean isAdded = security.addPrice(p);
        isUpdated = isUpdated || isAdded;
    }
    return isUpdated;
}
Also used : LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Aggregations

SecurityPrice (name.abuchen.portfolio.model.SecurityPrice)52 Security (name.abuchen.portfolio.model.Security)34 LocalDate (java.time.LocalDate)24 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)22 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)20 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)15 LatestSecurityPrice (name.abuchen.portfolio.model.LatestSecurityPrice)11 Client (name.abuchen.portfolio.model.Client)10 List (java.util.List)7 Values (name.abuchen.portfolio.money.Values)6 OpenDialogAction (name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)6 MessageFormat (java.text.MessageFormat)5 BiFunction (java.util.function.BiFunction)5 Function (java.util.function.Function)5 Collectors (java.util.stream.Collectors)5 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)5 Taxonomy (name.abuchen.portfolio.model.Taxonomy)5 Watchlist (name.abuchen.portfolio.model.Watchlist)5 Factory (name.abuchen.portfolio.online.Factory)5