The TradeLeg
class represents the exchange of a financial instrument and the resultant cash flow. One
or more TradeLeg
instances are contained within a single caplin.trading.trademodel.Trade
instance — this provides the transactional wrapper around a complete trade.
Attributes | Name and Description |
---|---|
|
caplin.trading.trademodel.TradeLeg(caplin.trading.trademodel.Trade trade, int legId)
Constructs an instance of |
Attributes | Name and Description |
---|---|
|
void
addDataFieldChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, String fieldName, boolean notifyImmediate)
Adds a listener that is called when the specified field is updated. |
|
void
addDataFieldsChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, Array fieldNames)
Adds a listener object that is called when any of the specified fields are updated. |
|
void
appendTraceData(Map mTraceData)
Append trace data into the internal data structure, so it can be sent to the server for analysis. |
|
void
dataFieldsUpdatedBySubscriber(caplin.trading.trademodel.DataHolder fieldData)
This method is a callback method used by the subscriber to notify the leg when new data is received from the server. |
|
String
getAmount()
Returns the number of units of the underlying financial instrument to be traded. |
|
String
getAssetClass()
Returns the type of the financial instrument(s) to be traded — e.g FX, FI, EQUITY or COMMODITIES. |
|
Variant
getFieldValue(String fieldName)
Returns the field value with the specified name. |
|
String
getInstrument()
Returns the financial instrument that is currently being traded on this leg. |
|
caplin.trading.trademodel.Trade
getTrade()
Returns the caplin.trading.trademodel.Trade object that this leg is a part of. |
|
boolean
isPermissioned()
Returns whether the user is permissioned to trade on this leg, based on the results of querying the caplin.services.security.PermissionService singleton. |
|
void
removeDataFieldChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, String fieldName)
Removes the previously registered |
|
void
removeDataFieldsChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, Array fieldNames)
Removes a listener object from each of the passed fields. |
|
void
removeInstrumentDataSubscriber()
Removes and unsubscribes the leg from the previously registered caplin.trading.trademodel.InstrumentDataSubscriber. |
|
void
resume()
Resume a previously suspended indicative data subscription on the trade leg. |
|
void
setAmount(String amount)
Sets the number of units of the underlying financial instrument to be traded. |
|
void
setAssetClass(String assetClass)
Sets the type of the instrument to be traded — e.g FX, FI, EQUITY or COMMODITIES. |
|
void
setFieldValue(String fieldName, String sValue)
Sets the value within the trade leg. |
|
void
setInstrument(String instrument)
Sets the financial instrument that will be traded on this leg. |
|
void
setInstrumentDataSubscriber(caplin.trading.trademodel.InstrumentDataSubscriber instrumentDataSubscriber)
Sets the |
|
void
stop()
Stops all operations on the trade leg. |
|
void
suspend()
Temporarily suspends the indicative data subscription on the trade leg. |
►
caplin.trading.trademodel.TradeLeg(caplin.trading.trademodel.Trade trade, int legId)
Constructs an instance of caplin.trading.trademodel.TradeLeg
.
caplin.trading.trademodel.Trade | trade | The trade of which this leg is a part. |
int | legId | The (one based) leg index of this trade leg. |
trade
is not a valid instance of caplin.trading.trademodel.Trade.
►
void
addDataFieldChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, String fieldName, boolean notifyImmediate)
Adds a listener that is called when the specified field is updated.
If it's more convenient it's also possible to add leg field listeners directly on the associated caplin.trading.trademodel.Trade instance, where the given field names must have the leg prefix prepended, e.g. 'L1_Amount' rather than 'Amount'.
N.b. If the notifyImmediate
flag is set to true
and there is a
possibility that the field in question does not have a value at the point the listener is registered, then the first
call to the caplin.trading.trademodel.DataFieldChangedListener#dataFieldChanged method may be with an
undefined
value.
caplin.trading.trademodel.DataFieldChangedListener | listener | The listener object to add. |
String | fieldName | The field to listen to. |
boolean | notifyImmediate | (Optional) if set to true then the listener will be immediately
notified of the fields current value, otherwise the listener will first be notified immediately the field changes
value. If omitted it defaults to false . |
►
void
addDataFieldsChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, Array fieldNames)
Adds a listener object that is called when any of the specified fields are updated.
caplin.trading.trademodel.DataFieldChangedListener | listener | The listener object to add. |
Array | fieldNames | The list of fields to send updates for. |
►
void
appendTraceData(Map mTraceData)
Append trace data into the internal data structure, so it can be sent to the server for analysis. This does not fire any listeners or run any derivations.
Map | mTraceData | Data to be traced. |
►
void
dataFieldsUpdatedBySubscriber(caplin.trading.trademodel.DataHolder fieldData)
This method is a callback method used by the subscriber to notify the leg when new data is received from the server. The field names arriving from the server are not prefixed with the leg number.
caplin.trading.trademodel.DataHolder | fieldData | The new data from the server. |
►
String
getAmount()
Returns the number of units of the underlying financial instrument to be traded.
►
String
getAssetClass()
Returns the type of the financial instrument(s) to be traded — e.g FX, FI, EQUITY or COMMODITIES.
►
Variant
getFieldValue(String fieldName)
Returns the field value with the specified name.
The field name follows the java beans naming convention. For any methods
getXxx()
/setXxx()
there should be a field with the corresponding name, 'xxx'.
String | fieldName | The unique identifier for the field. |
►
String
getInstrument()
Returns the financial instrument that is currently being traded on this leg.
The format of the name is dependent on the asset class. Any processing for specific asset classes should be added
to subclasses of TradeLeg
. The instrument name is generally not understood by Liberator. Liberator
requires a subject name that consists of a concatenation of asset class and instrument name.
►
caplin.trading.trademodel.Trade
getTrade()
Returns the caplin.trading.trademodel.Trade object that this leg is a part of.
►
boolean
isPermissioned()
Returns whether the user is permissioned to trade on this leg, based on the results of querying the caplin.services.security.PermissionService singleton.
The permission service is queried based on the instrument that is being traded within the leg (retrieved via #getInstrument) and the the trading protocol being used to perform the trade (retrieved via caplin.trading.trademodel.Trade#getTradingProtocol).
►
void
removeDataFieldChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, String fieldName)
Removes the previously registered DataFieldChangedListener
.
caplin.trading.trademodel.DataFieldChangedListener | listener | The listener to remove. |
String | fieldName | The data field that the listener should be removed from. |
►
void
removeDataFieldsChangedListener(caplin.trading.trademodel.DataFieldChangedListener listener, Array fieldNames)
Removes a listener object from each of the passed fields.
caplin.trading.trademodel.DataFieldChangedListener | listener | The listener object to remove. |
Array | fieldNames | The list of fields to send updates for. |
►
void
removeInstrumentDataSubscriber()
Removes and unsubscribes the leg from the previously registered caplin.trading.trademodel.InstrumentDataSubscriber.
►
void
resume()
Resume a previously suspended indicative data subscription on the trade leg. If there is no indicative data subscription, it does nothing. If this trade leg is not suspended it does nothing.
►
void
setAmount(String amount)
Sets the number of units of the underlying financial instrument to be traded.
String | amount | The number of units of the underlying financial instrument to be traded. |
►
void
setAssetClass(String assetClass)
Sets the type of the instrument to be traded — e.g FX, FI, EQUITY or COMMODITIES.
String | assetClass | The asset class that is being traded. |
►
void
setFieldValue(String fieldName, String sValue)
Sets the value within the trade leg. Initial the trade instance is asked to validate the change. If all is well then the change is made within the leg and the data change listeners are notified (called in response to user input).
String | fieldName | The field name of the field that has changed. |
String | sValue | The new value of the field |
►
void
setInstrument(String instrument)
Sets the financial instrument that will be traded on this leg.
String | instrument | The instrument to trade. |
►
void
setInstrumentDataSubscriber(caplin.trading.trademodel.InstrumentDataSubscriber instrumentDataSubscriber)
Sets the InstrumentDataSubscriber
used to be obtain the prices for the instrument.
For certain trade protocols (e.g. ESP) the prices are pre-populated. In this case, when the user initiates the trade the existing price is used.
caplin.trading.trademodel.InstrumentDataSubscriber | instrumentDataSubscriber | The subscriber that will retrieve all instrument data for this trade leg. |
►
void
stop()
Stops all operations on the trade leg.
This method should be called when the trade leg is no longer needed as it releases any resources held by the trade leg. This method does not remove listeners that were registered using the #addDataFieldChangedListener or #addDataFieldsChangedListener methods.
Any data associated with the leg will be cleared when this method is called.
►
void
suspend()
Temporarily suspends the indicative data subscription on the trade leg.
If there is no indicative data subscription, or if the trade leg is already suspended, calling this method has no effect.