use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.
the class UpdateQuotesJob method addLatestQuotesJobs.
private void addLatestQuotesJobs(Dirtyable dirtyable, List<Job> jobs) {
for (Security s : securities) {
// if configured, use feed for latest quotes
// otherwise use the default feed used by historical quotes as well
String feedId = s.getLatestFeed();
if (feedId == null)
feedId = s.getFeed();
QuoteFeed feed = Factory.getQuoteFeedProvider(feedId);
if (feed == null)
continue;
Job job = createLatestQuoteJob(dirtyable, feed, s);
jobs.add(job);
// one request is made per host at a given time)
if (HTMLTableQuoteFeed.ID.equals(feedId)) {
job.setRule(HostSchedulingRule.createFor(s.getLatestFeedURL() == null ? s.getFeedURL() : s.getLatestFeedURL()));
} else if (// $NON-NLS-1$
feedId.startsWith("YAHOO")) {
// $NON-NLS-1$
job.setRule(new HostSchedulingRule("finance.yahoo.com"));
}
}
}
use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.
the class SecuritiesTable method addQuoteFeedColumns.
private void addQuoteFeedColumns() {
Function<Object, String> quoteFeed = e -> {
String feedId = ((Security) e).getFeed();
if (feedId == null || feedId.isEmpty())
return null;
QuoteFeed feed = Factory.getQuoteFeedProvider(feedId);
return feed != null ? feed.getName() : null;
};
// $NON-NLS-1$
Column column = new Column("qf-historic", Messages.ColumnQuoteFeedHistoric, SWT.LEFT, 200);
column.setGroupLabel(Messages.GroupLabelQuoteFeed);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return quoteFeed.apply(e);
}
});
column.setSorter(ColumnViewerSorter.create(quoteFeed::apply));
support.addColumn(column);
Function<Object, String> latestQuoteFeed = e -> {
Security security = (Security) e;
String feedId = security.getLatestFeed();
if (feedId == null || feedId.isEmpty())
return security.getFeed() != null ? Messages.EditWizardOptionSameAsHistoricalQuoteFeed : null;
QuoteFeed feed = Factory.getQuoteFeedProvider(feedId);
return feed != null ? feed.getName() : null;
};
// $NON-NLS-1$
column = new Column("qf-latest", Messages.ColumnQuoteFeedLatest, SWT.LEFT, 200);
column.setGroupLabel(Messages.GroupLabelQuoteFeed);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return latestQuoteFeed.apply(e);
}
});
column.setSorter(ColumnViewerSorter.create(latestQuoteFeed::apply));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("url-history", Messages.ColumnFeedURLHistoric, SWT.LEFT, 200);
column.setGroupLabel(Messages.GroupLabelQuoteFeed);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Security security = (Security) e;
return security.getFeedURL();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Security.class, "feedURL"));
support.addColumn(column);
// $NON-NLS-1$
column = new Column("url-latest", Messages.ColumnFeedURLLatest, SWT.LEFT, 200);
column.setGroupLabel(Messages.GroupLabelQuoteFeed);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Security security = (Security) e;
return security.getLatestFeedURL();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Security.class, "latestFeedURL"));
support.addColumn(column);
}
use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.
the class ReviewImportedQuotesPage method beforePage.
@Override
public void beforePage() {
String source = page.getSourceText();
// $NON-NLS-1$
QuoteFeed feed = Factory.getQuoteFeedProvider("GENERIC_HTML_TABLE");
List<Exception> errors = new ArrayList<Exception>();
quotes = feed.getHistoricalQuotes(source, errors);
PortfolioPlugin.log(errors);
setErrorMessage(null);
setPageComplete(!quotes.isEmpty());
tableSampleData.setInput(quotes);
tableSampleData.refresh(true);
// scroll up to top
if (!quotes.isEmpty())
tableSampleData.getTable().showItem(tableSampleData.getTable().getItem(0));
}
use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.
the class AbstractQuoteProviderPage method onExchangeChanged.
private void onExchangeChanged(SelectionChangedEvent event) {
Exchange exchange = (Exchange) ((IStructuredSelection) event.getSelection()).getFirstElement();
setStatus(null);
if (exchange == null) {
clearSampleQuotes();
} else {
QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
showSampleQuotes(feed, exchange);
}
}
use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.
the class UpdateQuotesJob method addHistoricalQuotesJobs.
private void addHistoricalQuotesJobs(Dirtyable dirtyable, List<Job> jobs) {
// randomize list in case LRU cache size of HTMLTableQuote feed is too
// small; otherwise entries would be evicted in order
Collections.shuffle(securities);
for (Security security : securities) {
Job job = new Job(security.getName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
QuoteFeed feed = Factory.getQuoteFeedProvider(security.getFeed());
if (feed == null)
return Status.OK_STATUS;
ArrayList<Exception> exceptions = new ArrayList<>();
if (feed.updateHistoricalQuotes(security, exceptions))
dirtyable.markDirty();
if (!exceptions.isEmpty())
PortfolioPlugin.log(createErrorStatus(security.getName(), exceptions));
return Status.OK_STATUS;
} catch (RateLimitExceededException e) {
schedule(2000);
return Status.OK_STATUS;
}
}
};
if (HTMLTableQuoteFeed.ID.equals(security.getFeed()))
job.setRule(HostSchedulingRule.createFor(security.getFeedURL()));
jobs.add(job);
}
}
Aggregations