4.4.1PRICE messages in OnMessage

Whenever there is a change to a requested price, the main OnMessage handler receives a PRICE message. For example:

Framework.OnMessage = function(Msg) {

if (Msg.is(FXB.MessageTypes.PRICE)) {

Msg.quotes[] contains a list of price changes

}

};

The FXB.Message object will contain a quotes[] array listing the changed prices. You may receive notifications for other markets in addition to the one(s) you have requested. For example, if you have only requested prices for a single market, you cannot rely on quotes.length being 1.

Each object in the quotes[] array has the following properties:

Property

Description

instrumentId

ID of the instrument, such as EUR/USD

time

Time of the most recent quote

bid

Latest bid price

ask

Latest ask price

high

High of the current period. Availability depends on account features.

low

Low of the current period. Availability depends on account features.

change

Change amount during the current period. Availability depends on account features.

changePc

Change amount as a percentage. Availability depends on account features.

updateMarker

See below

You can react to the changed prices either by looking at the quotes[] array, or by looking at the prices in the Framework.Instrumentscollection which will already have been updated.

The updateMarker is a bit-mask of what is changing in a quote. This is designed to help you minimise the work in updating a user interface. For example, if the bit-mask contains FLAG_PRICE_BID but not FLAG_PRICE_ASK, then you know that you only need to update the display of the bid price. You don't need to make the browser to do extra work updating an ask price which hasn't changed.

The possible flags are members of the FXB.UpdateFlags enumeration:

FXB.UpdateFlags.

Description

BID

Bid has changed

ASK

Ask has changed

HIGH

High has changed

LOW

Low has changed

CHANGEONDAY

Change-on-day has changed