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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations