Class DXFeed
Main entry class for dxFeed API.
This class is a wrapper for FeedNative.
Read it first Javadoc.
public class DXFeed
- Inheritance
-
DXFeed
- Inherited Members
Methods
CreateSubscription(IEnumerable<Type>)
Creates new subscription for a list of event types that is attached to this feed.
public DXFeedSubscription CreateSubscription(IEnumerable<Type> eventTypes)
Parameters
eventTypes
IEnumerable<Type>The list of event types. Events types must be implement IEventType and have EventCodeAttribute.
Returns
- DXFeedSubscription
The created subscription.
Exceptions
- ArgumentException
If one on the specified Type has no EventCodeAttribute.
CreateSubscription(params Type[])
Creates new subscription for a list of event types that is attached to this feed.
public DXFeedSubscription CreateSubscription(params Type[] eventTypes)
Parameters
eventTypes
Type[]The list of event types. Events types must be implement IEventType and have EventCodeAttribute.
Returns
- DXFeedSubscription
The created DXFeedSubscription.
Exceptions
- ArgumentException
If one on the specified Type has no EventCodeAttribute.
GetInstance()
Gets a default application-wide singleton instance of feed. Most applications use only a single data-source and should rely on this method to get one.
public static DXFeed GetInstance()
Returns
GetLasEventIfSubscribed<TE>(object)
Returns the last event for the specified event type and symbol if there is a subscription for it. This method works only for event types that implement ILastingEvent marker interface. This method does 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 event type and symbol. The subscription can also be permanently defined using DXEndpoint properties. All subscription does not count for that purpose. If there is no subscription, then this method returns null.
If there is a subscription, but the event has not arrived from the uplink data provider, this method returns an non-initialized event object: its GetLastEvent<TE>(TE) property is set to the requested symbol, but all the other properties have their default values.
Use GetLastEventAsync<T>(object, CancellationToken) method if an event needs to be requested in the absence of subscription.
Note, that this method does not work when DXEndpoint was created with StreamFeed role (never fills in the event).
public TE? GetLasEventIfSubscribed<TE>(object symbol) where TE : ILastingEvent
Parameters
symbol
objectThe symbol.
Returns
- TE
The event or null if there is no subscription for the specified event type and symbol.
Type Parameters
TE
The event type.
GetLastEventAsync<T>(object, CancellationToken)
Requests the last event for the specified event type and symbol. This method works only for event types that implement ILastingEvent marker interface. This method requests the data from the uplink data provider, creates new event of the specified event type, and Result the resulting task with this event.
public Task<T> GetLastEventAsync<T>(object symbol, CancellationToken token = default) where T : ILastingEvent
Parameters
symbol
objectThe symbol.
token
CancellationTokenThe cancellation token.
Returns
- Task<T>
The task for the result of the request.
Type Parameters
T
The type of event.
GetLastEvent<TE>(TE)
Returns the last event for the specified event instance. This method works only for event types that implement ILastingEvent marker interface. This method does 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. All subscription does not count for that purpose.
Use GetLastEventAsync<T>(object, CancellationToken) method if an event needs to be requested in the absence of subscription.
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.
This method provides no way to distinguish a case when there is no subscription from the case when
there is a subscription, but the event data have not arrived yet. It is recommended to use
GetLasEventIfSubscribed<TE>(object) method
instead of this GetLastEvent
method to fail-fast in case when the subscription was supposed to be
set by the logic of the code, since GetLasEventIfSubscribed<TE>(object)
method returns null when there is no subscription.
Note, that this method does not work when DXEndpoint was created with StreamFeed role (never fills in the event).
public TE GetLastEvent<TE>(TE e) where TE : ILastingEvent
Parameters
e
TEThe event.
Returns
- TE
The same event.
Type Parameters
TE
The type of event.
GetLastEvents<TE>(IList<TE>)
Returns the last events for the specified list of event instances. This is a bulk version of GetLastEvent<TE>(TE) method.
Note, that this method does not work when DXEndpoint was created with StreamFeed role (never fills in the event).
public IList<TE> GetLastEvents<TE>(IList<TE> events) where TE : ILastingEvent
Parameters
events
IList<TE>The collection of events.
Returns
- IList<TE>
The same collection of events.
Type Parameters
TE
The type of event.
GetTimeSeriesAsync<T>(object, long, long, CancellationToken)
Requests time series of events for the specified event type, symbol, and a range of time. This method works only for event types that implement ITimeSeriesEvent interface. his method requests the data from the the uplink data provider, creates a list of events of the specified event type, and Result the resulting task with this list.
public Task<IEnumerable<T>> GetTimeSeriesAsync<T>(object symbol, long from, long to, CancellationToken token = default) where T : ITimeSeriesEvent
Parameters
symbol
objectThe symbol.
from
longThe time, inclusive, to request events from Time.
to
longThe time, inclusive, to request events from Time. Use long.MaxValue to retrieve events without an upper limit on time.
token
CancellationTokenThe cancellation token.
Returns
- Task<IEnumerable<T>>
The task for the result of the request.
Type Parameters
T
The event type.