public static class MarketPrice.Builder
extends java.lang.Object
Constructor and Description |
---|
Builder()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
MarketPrice |
build()
Builds the
MarketPrice object |
MarketPrice.Builder |
onComplete(MarketPrice.OnCompleteFunction function)
Sets the function to be called when the market price is complete.
|
MarketPrice.Builder |
onImage(MarketPrice.OnImageFunction function)
Sets the function to be called when the market price receives a
new image (all fields).
|
MarketPrice.Builder |
onState(MarketPrice.OnStateFunction function)
Sets the function to be called when the market price receives a new
state (Status).
|
MarketPrice.Builder |
onUpdate(MarketPrice.OnUpdateFunction function)
Sets the function to be called when the market price receives an
update (updated fields only).
|
MarketPrice.Builder |
withField(int fieldId)
Indicates that the
MarketPrice must subscribe to the
instrument using a view that contains this field Id. |
MarketPrice.Builder |
withField(java.lang.String fieldName)
Indicates that the
MarketPrice must subscribe to the
instrument using a view that contains this field name. |
MarketPrice.Builder |
withName(java.lang.String name)
Sets the name of the market price level 1 instrument to
subscribe to.
|
MarketPrice.Builder |
withOmmConsumer(com.thomsonreuters.ema.access.OmmConsumer ommConsumer)
Sets the EMA OmmConsumer used by the
MarketPrice to subscribe. |
MarketPrice.Builder |
withPartialUpdatesManagement(boolean partialUpdatesManagementActivated)
Indicates if the
MarketPrice has to manage partial updates. |
MarketPrice.Builder |
withServiceName(java.lang.String serviceName)
Sets the name of the service the market price instrument is published on.
|
MarketPrice.Builder |
withSynchronousMode()
Indicates if the
MarketPrice must be opened synchronously. |
MarketPrice.Builder |
withSynchronousMode(boolean autoDispatch)
Indicates if the
MarketPrice must be opened synchronously. |
MarketPrice.Builder |
withUpdates(boolean withUpdates)
Indicates you are interested in market price updates or not.
|
public MarketPrice.Builder withOmmConsumer(com.thomsonreuters.ema.access.OmmConsumer ommConsumer)
MarketPrice
to subscribe.
This OmmConsumer
must have been properly initialized and connected
to a Thomson Reuters real-time platform.ommConsumer
- the OmmConsumer that will be used by the
OmmConsumer
to subscribe.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withName(java.lang.String name)
name
- the name of the MarketPrice
.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withServiceName(java.lang.String serviceName)
MarketPrice
to subscribe.
If the service name is not set the default "ELEKTRON_DD" service name
is used.serviceName
- the name of the service the market price is published on.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withUpdates(boolean withUpdates)
withUpdates
to true
the MarketPrice
will be kept updated with the messages received from the EMA
OmmConsumer
. You will also be notified of changes via the
MarketPrice.OnImageFunction
or MarketPrice.OnUpdateFunction
functions if you
set them at build time. These calls may happen before and after the
MarketPrice
is complete. withUpdates
is not called, the default value
(true
) is used.withUpdates
- whether or not you are interested in market price
changes.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withPartialUpdatesManagement(boolean partialUpdatesManagementActivated)
MarketPrice
has to manage partial updates.
Partial updates are updates that can possibly change only a part of a
specific field. Partial updates only apply to RMTES field types and only
for some level 1 instruments (generally pages composed of ROW64_n or
ROW80_n fields). A good example is the "FXFX" page.
Partial updates management consumes additional resources. For this
reason, it must not be activated for instruments that do not receive
partial updates.
If withPartialUpdatesManagement
is not called, the default
value (false
) is used.partialUpdatesManagementActivated
- whether or not you want to
activate partial updates management.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withSynchronousMode()
MarketPrice
must be opened synchronously.
If withSynchronousMode
is not called, the MarketPrice
will be opened asynchronously.
By default the autoDispatch mode is false meaning that the MarketPrice
the MarketPrice.open()
method will not dispatch events but just wait until
the item is complete before returning control to the calling thread.
This means that EMA events must be dispatch either from another
application thread or from the EMA thread (see the API_DISPATCH EMA
operation model).Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withSynchronousMode(boolean autoDispatch)
MarketPrice
must be opened synchronously.
If withSynchronousMode
is not called, the MarketPrice
will be opened asynchronously.autoDispatch
- indicates if the MarketPrice will have to dispatch
EMA events when the MarketPrice.open()
method is called (see the
USER_DISPATCH EMA operation model) or if these events will be dispatched
by another thread. In the later case, the MarketPrice.open()
method
will not dispatch events but just wait until the item is complete.
This means that EMA events must be dispatch either from another
application thread or from the EMA thread (see the API_DISPATCH EMA
operation model).Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withField(int fieldId)
MarketPrice
must subscribe to the
instrument using a view that contains this field Id.
You can chain method calls to specify several fields like this:
MarketPrice theMarketPrice = new MarketPrice.Builder() . . . .withField(3) .withField(22) .withField(25) . . . .build();
MarketPrice
will only
receive images and updates that contain the indicated fields. If the
platform doesn't support views, the MarketPrice
will
receive images and updates for all fields.
.withField()
calls with ids and
names cannot be mixed with the same builder.fieldId
- the Id of a field to include to the view.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder withField(java.lang.String fieldName)
MarketPrice
must subscribe to the
instrument using a view that contains this field name.
You can chain method calls to specify several fields like this:
MarketPrice theMarketPrice = new MarketPrice.Builder() . . . .withField("DSPLY_NAME") .withField("BID") .withField("ASK") . . . .build();
MarketPrice
will only
receive images and updates that contain the indicated fields. If the
platform doesn't support views, the MarketPrice
will
receive images and updates for all fields.
.withField()
calls with ids and
names cannot be mixed with the same builder.fieldName
- the name of a field to include to the view.Builder
so that you can chain other Builder
methods calls.public MarketPrice.Builder onComplete(MarketPrice.OnCompleteFunction function)
MarketPrice theMarketPrice = new MarketPrice.Builder() .onComplete( (marketPrice) -> marketPrice.getFields().forEach( (field) -> println("\t" + field.description().acronym() + " (" + field.description().fid() + ") = " + field.value()) ) ) . . .
function
- function to be called when the market price is complete.public MarketPrice.Builder onImage(MarketPrice.OnImageFunction function)
MarketPrice theMarketPrice = new MarketPrice.Builder() .onImage( (marketPrice, image) -> image.forEach( (field) -> println("\t" + field.description().acronym() + " (" + field.description().fid() + ") = " + field.value()) ) ) . . .
function
- function to be called when the market price receives
a new image.public MarketPrice.Builder onUpdate(MarketPrice.OnUpdateFunction function)
MarketPrice theMarketPrice = new MarketPrice.Builder() .onUpdate( (marketPrice, update) -> update.forEach( (field) -> println("\t" + field.description().acronym() + " (" + field.description().fid() + ") = " + field.value()) ) ) . . .
function
- function to be called when the market price receives
an update.public MarketPrice.Builder onState(MarketPrice.OnStateFunction function)
MarketPrice theMarketPrice = new MarketPrice.Builder() .onState( (marketPrice, State) -> println("\tNew state received for <" + marketPrice.getName() + ">: " + state) ) . . .
function
- function to be called when the market price receives
a new state.public MarketPrice build()
MarketPrice
object