Java API
© 2022 BidFX Systems Ltd. 9 of 11
however quickly receive feedback on the subscription via one of the event delegate callback
methods. If there is a problem then you will receive a SubscriptionStatus event. If a price was
obtained then you will receive a PriceUpdate event. Price updates have an implied status of
SubscriptionStatus.OK. Note that it is not uncommon for some price feeds to initially publish
SubscriptionStatus.PENDING, to notify the receipt of a subscription, soon followed by a price
update once the data becomes available from its own remote feed.
Subscribe has an optional argument, refresh. Setting this to true will cause the subscription to
simulate unsubscribing and resubscribing if the subscription is currently subscribed. This can
help with refreshing an expired Quote subscription.
Price Update Events
Upon receiving a price update in the form of PriceMapEvent, you'll want to access the data
inside of it. There are three available properties:
• A Subject from subject() equal to the subject passed to Subscribe, indicating the
instrument you have received an update for.
• A MapPrice from priceUpdate() that will contain only the fields received from the server
in the last update.
• An Optional<MapPrice> from mergedPrice containing only those fields which changed
in this most recent update.
By default, mergedPrice() will always return Optional.empty(). To enable full price maps, call
mergePriceUpdates() when settings up the Pricing object. This is done because many GUI
programs only care about the fields that changed, and merging the new update with the
existing fields would be a waste of cycles.
Price Maps
MapPrices are a map from Field to Value. Values are always returned as strings. The
FieldName enum contains a list of commonly used fields.
Subscription Status Events
Upon receiving a status update in the form of a SubscriptionStatusEvent, you'll want to access
the data inside of it. There are three properties:
• A Subject from getSubject() gives the subject of the subscription the status update
refers to.
• A SubscriptionStatus from getStatus() containing an enum value that defines the status
of the subscription.
• A String from getExplanation() containing a more detailed reason of the change in
status.
Most subscription status' result from temporary issues that can be resolved by the price
service. For example, if a connection goes down and fails over then the API will publish a