Constructor
new module:caplin/fx/trademodel/FxTradeLeg(oTrade, nLegId)
caplin.fx.trademodel.FxTradeLeg
.
Extends:
Parameters:
Name | Type | Description |
---|---|---|
oTrade |
module:caplin/trading/trademodel/Trade | The trade of which this leg is a part. |
nLegId |
int | The (one based) leg index of this trade leg.
|
Extends
Methods
-
addDataFieldChangedListener(listener, fieldName, notifyImmediateopt)
-
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
module: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 totrue
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 themodule:caplin/trading/trademodel/DataFieldChangedListener#dataFieldChanged
method may be with anundefined
value.Parameters:
Name Type Attributes Description listener
module:caplin/trading/trademodel/DataFieldChangedListener The listener object to add. fieldName
String The field to listen to. notifyImmediate
boolean <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 tofalse
. -
addDataFieldsChangedListener(listener, fieldNames)
-
Adds a listener object that is called when any of the specified fields are updated.
Parameters:
Name Type Description listener
module:caplin/trading/trademodel/DataFieldChangedListener The listener object to add. fieldNames
Array The list of fields to send updates for. -
appendTraceData(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.
Parameters:
Name Type Description mTraceData
Map Data to be traced. - Inherited From:
-
dataFieldsUpdatedBySubscriber(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.
Parameters:
Name Type Description fieldData
module:caplin/trading/trademodel/DataHolder The new data from the server. -
getAmount() → {String}
-
Returns the number of units of the underlying financial instrument to be traded.
- Inherited From:
- See:
Returns:
The number of units- Type
- String
-
getAskFwdPrice()
-
Returns the price at which the dealer is willing to sell one unit of the base currency on the defined settlement date.
Returns:
A string formatted decimal. -
getAskPoints() → {FLOAT}
-
Returns the number of Forward Points for the Ask Rate. The number of forward points on a given exchange rate will be determined by the prevailing interest rates, the time period between the spot and forward rate, and other market factors.
Returns:
askPoints- Type
- FLOAT
-
getAskPrice()
-
Returns the price at which the dealer is willing to sell one unit of the base currency on the defined settlement date.
When the settlement date returned by
module:caplin/fx/trademodel/FxTradeLeg#getSettlementDate
is the spot date then this method returns the same value asmodule:caplin/fx/trademodel/FxTradeLeg#getAskSpotPrice
.Returns:
The price as a string formatted decimal. -
getAskSpotPrice()
-
Returns the price at which the dealer is willing to buy one unit of the base currency on the spot date.
This method will not return a value when this
TradeLeg
is the second leg within the parentTrade
object.Returns:
A string formatted decimal. -
getAskSwapPoints()
-
Returns the difference between the near and the far legs ask price
Returns:
A string formatted decimal. -
getAssetClass() → {String}
-
Returns the type of the financial instrument(s) to be traded — e.g FX, FI, EQUITY or COMMODITIES.
- Inherited From:
- See:
Returns:
The instrument type- Type
- String
-
getBaseCurrency() → {String}
-
Returns the base currency from the currency pair — this is the first currency within the instrument name.
Returns:
3-digit ISO currency code.- Type
- String
-
getBidFwdPrice()
-
Returns the price at which the dealer is willing to buy one unit of the base currency on the defined settlement date.
Returns:
A string formatted decimal. -
getBidPoints() → {FLOAT}
-
Returns the number of Forward Points for the Bid Rate. The number of forward points on a given exchange rate will be determined by the prevailing interest rates, the time period between the spot and forward rate, and other market factors.
Returns:
bidPoints- Type
- FLOAT
-
getBidPrice()
-
Returns the price at which the dealer is willing to buy one unit of the base currency on the defined settlement date.
When the settlement date returned by
module:caplin/fx/trademodel/FxTradeLeg#getSettlementDate
is the spot date then this method returns the same value asmodule:caplin/fx/trademodel/FxTradeLeg#getBidSpotPrice
.Returns:
A string formatted decimal. -
getBidSpotPrice()
-
Returns the price at which the dealer is willing to sell one unit of the base currency on the spot date.
This method will not return a value when this
TradeLeg
is the second leg within the parentTrade
object.Returns:
A string formatted decimal. -
getBidSwapPoints()
-
Returns the difference between the near and the far legs bid price
Returns:
A string formatted decimal. -
getBuySell() → {String}
-
Whether the user has requested only buy side prices, only sell side prices, or prices on both sides.
This value will be disambiguated and given a specific side, once the user executes the trade using
module:caplin/fx/trademodel/FxTradeLeg#setSide
.Returns:
'BUY', 'SELL', '2-WAY'- Type
- String
-
getDealtCurrency() → {String}
-
Returns the currency that relates to the amount within the amount field, and which the trade will be performed in.
This can be either the dealt currency or the term currency, but initially defaults to being the base currency.
- See:
Returns:
3-digit ISO currency code.- Type
- String
-
getFieldValue(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'.Parameters:
Name Type Description fieldName
String The unique identifier for the field. - Inherited From:
-
getFXInstrument()
-
Returns the complete RTTP subject name that this instrument can be requested with.
-
getFxInstrument()
-
- Deprecated:
- Please use
module:caplin/fx/trademodel/FxTradeLeg#getFXInstrument
instead.
- Please use
-
getInstrument() → {String}
-
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.- Inherited From:
- See:
Returns:
The instrument- Type
- String
-
getMaxTierLimit()
-
Returns the highest tier limit — this is effectively the highest amount the user can trade.
-
getNotDealtCurrency() → {String}
-
A convenience method that returns the currency from the pair that is not being used as the dealt currency.
If the dealt currency is the base currency, then this method will return the term currency, whereas if the dealt currency is the term currency then this method will return the base currency.
Returns:
3-digit ISO currency code.- Type
- String
-
getOppositeCurrency(sCurrency) → {String}
-
A convenience method that returns the other currency in a currency pair, given one of the two currencies.
Parameters:
Name Type Description sCurrency
String A string representation of the currency code (e.g GBP). Returns:
3-digit ISO currency code.- Type
- String
-
getPointsScaleFactor()
-
Returns the decimal point scaling factor that can be used to help determine the number of decimal places of data that should be shown in the pip segment of the display.
-
getPrice() → {String}
-
Returns either the bid price or the ask price, dependent on the side previously set with
module:caplin/fx/trademodel/FxTradeLeg#setSide
.If the user has clicked the bid button, and hence
module:caplin/fx/trademodel/FxTradeLeg#setSide
has been called with 'BUY', then the bid price is returned, otherwise the 'SELL' price will be returned.Returns:
A string formatted decimal.- Type
- String
-
getSettlementDate() → {String}
-
Returns the date the currencies will be exchanged &mdash also known as the delivery date.
Returns:
Date in YYYYMMDD format.- Type
- String
-
getSide() → {String}
-
Returns the side of the trade that the user has chosen to trade on.
Returns:
Either 'Bid' or 'Ask'.- Type
- String
-
getTenor()
-
Returns the tenor, which is a standarized code that can be used to determine the settlement date.
Example tenors are:
- SPOT &mdash generally two trading days in the future
- SPOT NEXT &mdash one trading day after the spot date
-
getTermCurrency() → {String}
-
Returns the term currency from the currency pair — this is the second currency within the instrument name.
Returns:
3-digit ISO currency code.- Type
- String
-
getTierLimit()
-
Returns the tier limit up to which the currently quoted prices will continue to be valid.
The prices quoted are dependent on the amount traded; generally, the greater the amount, the greater the unit price becomes since it requires the dealer to take a greater exposure to change within the market. The tier limit is the largest amount at which the current price will continue to be valid — if an amount larger than this is set (using
module:caplin/fx/trademodel/FxTradeLeg#setAmount
), then the quoted prices will update to reflect the new pricing tier. -
getTrade() → {module:caplin/trading/trademodel/Trade}
-
Returns the
module:caplin/trading/trademodel/Trade
object that this leg is a part of.- Inherited From:
Returns:
The trade -
isAskSide()
-
Returns
true
if the user is trading on the ask side — i.e. buying the base currency. -
isBidSide()
-
Returns
true
if the user is trading on the bid side — i.e. selling the base currency. -
isDealtCurrencyBought()
-
Returns
true
if the dealt currency is being bought.Whether this is a buy or sell from the traders perspective, rather than a bid or ask, as it is from the dealers perspective.
-
isDealtCurrencySold()
-
Returns
true
if the dealt currency is being sold.Whether this is a buy or sell from the traders perspective, rather than a bid or ask, as it is from the dealers perspective.
-
isPermissioned()
-
Returns whether the user is permissioned to trade on this leg, based on the results of querying the
module:caplin/services/security/PermissionService
singleton.The permission service is queried based on the instrument that is being traded within the leg (retrieved via
module:caplin/trading/trademodel/TradeLeg#getInstrument
) and the the trading protocol being used to perform the trade (retrieved viamodule:caplin/trading/trademodel/Trade#getTradingProtocol
).- Inherited From:
-
removeDataFieldChangedListener(listener, fieldName)
-
Removes the previously registered
DataFieldChangedListener
.Parameters:
Name Type Description listener
module:caplin/trading/trademodel/DataFieldChangedListener The listener to remove. fieldName
String The data field that the listener should be removed from. -
removeDataFieldsChangedListener(listener, fieldNames)
-
Removes a listener object from each of the passed fields.
Parameters:
Name Type Description listener
module:caplin/trading/trademodel/DataFieldChangedListener The listener object to remove. fieldNames
Array The list of fields to send updates for. -
removeInstrumentDataSubscriber()
-
Removes and unsubscribes the leg from the previously registered
module:caplin/trading/trademodel/InstrumentDataSubscriber
. -
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.
- Inherited From:
-
setAmount(amount)
-
Sets the number of units of the underlying financial instrument to be traded.
Parameters:
Name Type Description amount
String The number of units of the underlying financial instrument to be traded. -
setAssetClass(assetClass)
-
Sets the type of the instrument to be traded — e.g FX, FI, EQUITY or COMMODITIES.
Parameters:
Name Type Description assetClass
String The asset class that is being traded. -
setDealtCurrency(sValue)
-
Sets the currency that relates to the amount within the amount field, and which the trade will be performed in.
Parameters:
Name Type Description sValue
String A string representation of the currency code (e.g GBP). -
setFieldValue(fieldName, 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).
Parameters:
Name Type Description fieldName
String The field name of the field that has changed. sValue
String The new value of the field - Inherited From:
-
setFXInstrument(sValue)
-
Sets the instrument name, which consists of two concatenated 3-digit ISO currency codes (e.g. GBPUSD or EURSEK).
The first code within the instrument name is called the base currency (retrievable via
module:caplin/fx/trademodel/FxTradeLeg#getBaseCurrency
), while the second currency in the instrument name is called the term currency (retrievable viamodule:caplin/fx/trademodel/FxTradeLeg#getTermCurrency
).Parameters:
Name Type Description sValue
String 6 digit currency pair code. -
setInstrument(sValue)
-
Sets the instrument name, which consists of two concatenated 3-digit ISO currency codes (e.g. GBPUSD or EURSEK).
The first code within the instrument name is called the base currency (retrievable via
module:caplin/fx/trademodel/FxTradeLeg#getBaseCurrency
), while the second currency in the instrument name is called the term currency (retrievable viamodule:caplin/fx/trademodel/FxTradeLeg#getTermCurrency
).Parameters:
Name Type Description sValue
String 6 digit currency pair code. - Deprecated:
- Please use
instead.module:caplin/fx/trademodel/FxTradeLeg#setFXInstrument
- Please use
-
setInstrumentDataSubscriber(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.
Parameters:
Name Type Description instrumentDataSubscriber
module:caplin/trading/trademodel/InstrumentDataSubscriber | InstrumentDataSubscriber The subscriber that will retrieve all instrument data for this trade leg. -
setSettlementDate(sValue)
-
Set the settlement date for the trade leg.
Parameters:
Name Type Description sValue
String Date in YYYYMMDD format. -
setSide(sSide)
-
Sets whether the user wants to trade at the bid or the ask price.
If the side is 'Bid', then the user is selling the base currency, and buying the term currency. If the side is 'Ask', then the user is buying the base currency, and selling the term currency.
Parameters:
Name Type Description sSide
String A string representation of the side (either 'Bid' or 'Ask'). -
setTenor(sTenor)
-
Sets the tenor that logically denotes when the trade will be performed.
The trade leg uses the
BusinessDateProvider
service to calculate the actual settlement date based on the given tenor code.Parameters:
Name Type Description sTenor
String The tenor. -
setTradedPrice(sTradePrice)
-
Sets the price the user wishes to trade on — this may be different from the last price received from the server due to the latency in displaying updates to the screen.
Parameters:
Name Type Description sTradePrice
String Decimal formatted string. -
stop()
-
- See:
-
module:caplin/trading/trademodel/TradeLeg.prototype.stop
-
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.
- Inherited From:
-
toggleDealtCurrency()
-
Switches the dealt currency between the base and the term currency.