Search in sources :

Example 11 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method onFeedProviderChanged.

private void onFeedProviderChanged(SelectionChangedEvent event) {
    String previousExchangeId = null;
    if (comboExchange != null) {
        Exchange exchange = (Exchange) ((IStructuredSelection) comboExchange.getSelection()).getFirstElement();
        if (exchange != null)
            previousExchangeId = exchange.getId();
    }
    if (previousExchangeId == null && model.getTickerSymbol() != null) {
        previousExchangeId = model.getTickerSymbol();
    }
    QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) event.getSelection()).getFirstElement();
    createDetailDataWidgets(feed);
    if (comboExchange != null) {
        List<Exchange> exchanges = cacheExchanges.get(feed);
        comboExchange.setInput(exchanges);
        // select exchange if other provider supports same exchange id
        // (yahoo close vs. yahoo adjusted close)
        boolean exchangeSelected = false;
        if (exchanges != null && previousExchangeId != null) {
            for (Exchange e : exchanges) {
                if (e.getId().equals(previousExchangeId)) {
                    comboExchange.setSelection(new StructuredSelection(e));
                    exchangeSelected = true;
                    break;
                }
            }
        }
        if (!exchangeSelected)
            comboExchange.setSelection(null);
        setStatus(exchangeSelected ? null : MessageFormat.format(Messages.MsgErrorExchangeMissing, getTitle()));
    } else if (textFeedURL != null) {
        boolean hasURL = getFeedURL() != null && getFeedURL().length() > 0;
        if (hasURL)
            textFeedURL.setText(getFeedURL());
        setStatus(hasURL ? null : MessageFormat.format(Messages.EditWizardQuoteFeedMsgErrorMissingURL, getTitle()));
    } else {
        // get sample quotes?
        if (feed != null) {
            showSampleQuotes(feed, null);
        } else {
            clearSampleQuotes();
        }
        setStatus(null);
    }
}
Also used : Exchange(name.abuchen.portfolio.model.Exchange) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 12 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method beforePage.

@Override
public void beforePage() {
    if (!Objects.equals(tickerSymbol, model.getTickerSymbol())) {
        this.tickerSymbol = model.getTickerSymbol();
        // clear caches
        cacheExchanges = new HashMap<>();
        reinitCaches();
        new LoadExchangesJob().schedule();
        QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
        if (feed.getId() != null && feed.getId().indexOf(HTML) >= 0) {
            if (getFeedURL() == null || getFeedURL().length() == 0)
                clearSampleQuotes();
            else
                showSampleQuotes(feed, null);
        }
    }
}
Also used : AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 13 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class LatestQuoteProviderPage method getAvailableFeeds.

@Override
protected List<QuoteFeed> getAvailableFeeds() {
    List<QuoteFeed> feeds = new ArrayList<>();
    feeds.add(EMTPY_QUOTE_FEED);
    for (QuoteFeed feed : Factory.getQuoteFeedProvider()) {
        // adjusted close are only relevant for historical quotes)
        if (// $NON-NLS-1$
        feed.getId().equals("YAHOO-ADJUSTEDCLOSE"))
            continue;
        feeds.add(feed);
    }
    return feeds;
}
Also used : ArrayList(java.util.ArrayList) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Aggregations

QuoteFeed (name.abuchen.portfolio.online.QuoteFeed)13 HTMLTableQuoteFeed (name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed)10 AlphavantageQuoteFeed (name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed)8 ArrayList (java.util.ArrayList)6 Exchange (name.abuchen.portfolio.model.Exchange)5 Security (name.abuchen.portfolio.model.Security)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 MessageFormat (java.text.MessageFormat)2 List (java.util.List)2 Messages (name.abuchen.portfolio.ui.Messages)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 URISyntaxException (java.net.URISyntaxException)1 LocalDate (java.time.LocalDate)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 BiFunction (java.util.function.BiFunction)1