|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dxfeed.api.DXFeed
public abstract class DXFeed
Main entry class for DXFeed market data API. This class is thread-safe.
DXFeed feed =SeeDXEndpoint
.create
().connect
("demo.dxfeed.com:7300").getFeed
();
DXEndpoint
class for more configuration and control options.
DXFeedSubscription<Note, that order of calls is important here. By attaching listeners first and then setting subscription we ensure that the current quote gets received by the listener. SeeQuote
> sub = feed.createSubscription
(Quote.class
); sub.addEventListener
(new DXFeedEventListener<Quote>() { public void eventsReceived(List<Quote> quotes) { for (Quote quote : quotes) System.out.println("Mid = " + (quote.getBidPrice() + quote.getAskPrice()) / 2); } }); sub.addSymbols
("SPY");
DXFeedSubscription.addSymbols
for details.
DXFeedSubscription<MarketEvent
> sub = feed.<MarketEvent>createSubscription
(Quote.class
,Trade.class
); sub.addEventListener
(new DXFeedEventListener<MarketEvent>() { public void eventsReceived(List<MarketEvent> events) { for (MarketEvent event : events) System.out.println(event); } }); sub.addSymbols
("SPY");
DXFeedSubscription<Trade
> sub = feed.createSubscription
(Trade.class
); sub.addSymbols
("SPY"); while (true) { System.out.println(feed.getLastEvent
(new Trade("SPY"))); Thread.sleep(1000); }
Method Summary | ||
---|---|---|
abstract void |
attachSubscription(DXFeedSubscription<?> subscription)
Attaches the given subscription to this feed. |
|
|
createSubscription(java.lang.Class<? extends T>... eventTypes)
Creates new subscription for multiple event types that is attached to this feed. |
|
|
createSubscription(java.lang.Class<? extends T> eventType)
Creates new subscription for a single event type that is attached to this feed. |
|
|
createTimeSeriesSubscription(java.lang.Class<? extends T>... eventTypes)
Creates new time series subscription for multiple event types that is attached to this feed. |
|
|
createTimeSeriesSubscription(java.lang.Class<? extends T> eventType)
Creates new time series subscription for a single event type that is attached to this feed. |
|
abstract void |
detachSubscription(DXFeedSubscription<?> subscription)
Detaches the given subscription from this feed. |
|
abstract
|
getLastEvent(T event)
Returns the last event for the specified symbol and event type. |
|
|
getLastEvents(java.util.Collection<T> events)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final <T> DXFeedSubscription<T> createSubscription(java.lang.Class<? extends T> eventType)
createSubscription(Class[])
createSubscription(Class... eventTypes)}
This method creates new DXFeedSubscription
and invokes attachSubscription(com.dxfeed.api.DXFeedSubscription>)
.
DXFeedSubscription.DXFeedSubscription(Class)
,
attachSubscription(DXFeedSubscription)
public final <T> DXFeedSubscription<T> createSubscription(java.lang.Class<? extends T>... eventTypes)
createSubscrtiption(Class eventType)
This method creates new DXFeedSubscription
and invokes attachSubscription(com.dxfeed.api.DXFeedSubscription>)
.
DXFeedSubscription.DXFeedSubscription(Class[])
,
attachSubscription(DXFeedSubscription)
public final <T extends TimeSeriesEvent> DXFeedTimeSeriesSubscription<T> createTimeSeriesSubscription(java.lang.Class<? extends T> eventType)
createTimeSeriesSubscription(Class[])
createTimeSeriesSubscription(Class... eventTypes)}
This method creates new DXFeedTimeSeriesSubscription
and invokes attachSubscription(com.dxfeed.api.DXFeedSubscription>)
.
DXFeedTimeSeriesSubscription.DXFeedTimeSeriesSubscription(Class)
,
attachSubscription(DXFeedSubscription)
public final <T extends TimeSeriesEvent> DXFeedTimeSeriesSubscription<T> createTimeSeriesSubscription(java.lang.Class<? extends T>... eventTypes)
createTimeSeriesSubscription(Class eventType)
This method creates new DXFeedTimeSeriesSubscription
and invokes attachSubscription(com.dxfeed.api.DXFeedSubscription>)
.
DXFeedTimeSeriesSubscription.DXFeedTimeSeriesSubscription(Class[])
,
attachSubscription(DXFeedSubscription)
public abstract void attachSubscription(DXFeedSubscription<?> subscription)
DXFeedEventListener
via
DXFeedSubscription.addEventListener(com.dxfeed.api.DXFeedEventListener)
to get notified about data changes
and can change its data subscription via DXFeedSubscription
methods.
ObservableSubscriptionChangeListener
for the given subscription
via DXFeedSubscription.addChangeListener(com.dxfeed.api.osub.ObservableSubscriptionChangeListener)
method.
Attachment is lost when subscription is serialized and deserialized.
subscription
- the subscription.
java.lang.NullPointerException
- if the subscription is null.DXFeedSubscription
public abstract void detachSubscription(DXFeedSubscription<?> subscription)
ObservableSubscriptionChangeListener
from the given subscription
via DXFeedSubscription.removeChangeListener(com.dxfeed.api.osub.ObservableSubscriptionChangeListener)
method.
subscription
- the subscription.
java.lang.NullPointerException
- if the subscription is null.DXFeedSubscription
public abstract <T extends LastingEvent> T getLastEvent(T event)
LastingEvent
marker interface.
This method goes not make
any remote calls to the uplink data provider. It just retrieves last received event
from the local cache of this feed. The events are stored in the cache only if there is some
attached DXFeedSubscription
that is subscribed to the corresponding symbol and event type.
This method fills in the values for the last event into the event
argument.
If the last event is not available for any reason (no subscription, no connection to uplink, etc).
then the event object is not changed.
This method always returns the same event
instance that is passed to it as an argument.
T
- the event type.event
- the event.
java.lang.NullPointerException
- if the event is null.public <T extends LastingEvent> java.util.Collection<T> getLastEvents(java.util.Collection<T> events)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |