|
||||||||||
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 = DXFeed.createConnectedFeed
("demo.dxfeed.com:7300",
Executors.newSingleThreadExecutor());
DXFeedSubscription<Quote> sub = feed.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. SeecreateSubscription
(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
(Arrays.asList("SPY"));
DXFeedSubscription.addSymbols
for details.
DXFeedSubscription<Event> sub = feed.createSubscription
(Quote.class
,Trade.class
); sub.addEventListener
(new DXFeedEventListener<Event>() { public void eventsReceived(List<Event> events) { for (Event event : events) System.out.println(event); } }); sub.addSymbols
(Arrays.asList("SPY"));
DXFeedSubscriptionsub = feed. createSubscription
(Trade.class
); sub.addSymbols
(Arrays.asList("SPY")); while (true) { System.out.println(feed.getLastEvent
(new Trade("SPY"))); Thread.sleep(1000); }
Constructor Summary | |
---|---|
protected |
DXFeed()
Protected constructor for implementations of this class only. |
Method Summary | ||
---|---|---|
abstract void |
attachSubscription(DXFeedSubscription<?> subscription)
Attaches the given subscription to this feed. |
|
static DXFeed |
createConnectedFeed(java.lang.String address,
java.util.concurrent.Executor executor)
Creates DXFeed that is connected to the market data uplink via a specified address. |
|
|
createSubscription(java.lang.Class<? extends T>... eventTypes)
Creates new subscription 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DXFeed()
Method Detail |
---|
public static DXFeed createConnectedFeed(java.lang.String address, java.util.concurrent.Executor executor)
Event notifications that arrive over this feed will be processed by a specified executor
.
See Executors
for some ready-to-use implementations.
address
- data source address.executor
- executor to process arriving events.
java.lang.NullPointerException
- if address or executor are null.
java.lang.IllegalArgumentException
- if address has invalid format.public final <T extends Event> DXFeedSubscription<T> createSubscription(java.lang.Class<? extends T>... eventTypes)
DXFeedSubscription
and invokes attachSubscription(com.dxfeed.api.DXFeedSubscription>)
.
DXFeedSubscription.DXFeedSubscription(Class[])
public abstract void attachSubscription(DXFeedSubscription<?> subscription)
DXFeedSubscriptionChangeListener
for the given subscription
via DXFeedSubscription.addSubscriptionChangeListener(com.dxfeed.api.DXFeedSubscriptionChangeListener)
method.
Attachment is lost when subscription is serialized.
subscription
- the subscription.
java.lang.NullPointerException
- if the subscription is null.DXFeedSubscription
public abstract void detachSubscription(DXFeedSubscription<?> subscription)
DXFeedSubscriptionChangeListener
for the given subscription
via DXFeedSubscription.removeSubscriptionChangeListener(com.dxfeed.api.DXFeedSubscriptionChangeListener)
method.
subscription
- the subscription.
java.lang.NullPointerException
- if the subscription is null.DXFeedSubscription
public abstract <T extends Event> T getLastEvent(T event)
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 avilable for any reason (no subscription, no connection to uplink,
not applicable to this event type, etc), then the event object is not changed.
This method always returns the same event
that is passed to it as an argument.
T
- the event type.event
- the event.
java.lang.NullPointerException
- if the event is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |