Skip to main content

Transaction and trade order conditions and actions

Every time the user creates or modifies a transaction or a trade order, FA runs rules on it. Transaction class methods for the rule condition and action are listed below.

Conditions

Transaction attribute

Syntax

Additional information

Return type

Type code

type

Preference - Transactions

String

Status code

status

Transaction: OK, DEL or NF

Trade order: ORDER

String

Order status (if trade order)

orderStatus

Trade order window

4=Open

1=Executable

3=Cancelled

2=Executed

5=Accepted

6=In execution

12=Partially executed in the market

7=Executed in the market

8=Rejected

9=Expired

10=Sent to execution

11=Settled in market

String

Price

price

Price = amount x unit price. That is, price in security currency before fees and taxes are applied.

double

Trade amount in security currency

tradeAmount

price +/- fees +/- taxes in security currency

double

Trade amount in portfolio currency

tradeAmountInPortfolioCurrency

double

Trade amount in account currency

tradeAmountInAccountCurrency

double

Account

account

Account is not mandatory. Check if null before accessing account attributes.

Boolean

Account's visibility

account.visibility

TRUE = visible

FALSE = not visible

Boolean

Account's number

account.number

String

Account's BIC

account.bic

String

Settlement place

settlementPlaceCode

Asset classes and typesAsset classes and types

String

Marketplace

marketPlaceCode

String

Counter contact

counter

Contact

Parent portfolio

parentPortfolio

Portfolio

Parent portfolio's primary contact

primaryContact

Primary contact is not mandatory. Check if null before accessing primaryContact attributes.

Contact

Parent portfolio's primary contact's Contact ID

primaryContactId

String

Parent portfolio’s primary contact’s type code

primaryContactTypeCode

String

Parent portfolio’s primary contact's tag

primaryContact.hasTag("$1")

Boolean

Parent portfolio's group names

services.getPortfolioService().findPortfolioGroupNamesByPortfolio($t.parentPortfolio).contains("$1")

String

Security code

securityCode

If transaction has security, it returns the code. Otherwise, if transaction has an account, it returns the account number.

String

Security type

securityTypeCode

String

Security

security

Security is not mandatory. Check if null before accessing security attributes.

Security

Security tag

security.hasTag("$1")

Boolean

Transaction type effect

type.amountEffect
  • 1 adds amount

  • 0 no effect

  • -1 reduces amount

String

Fee

cost
cost2

double

Has tag

hasTag("$1")

Doesn't have tag

hasNotTag("$1")

Has group tag

hasGroupTag("$1")

Doesn't have group tag

hasNotGroupTag("$1")

Actions

Action

Syntax

Additional information

Change transaction status

$t.setStatus("$1")

Transaction statuses: OK, NF, DEL

Trade order status: ORDER

Change trade order status

$t.setOrderStatus("$1")

4,0,1,2,3,5,…

Set a tag

$t.setTag("$1")

Adds a new tag or changes an existing group tag.

Remove a tag

$t.removeTag("$1")

Set transaction type

$t.setTransactionTypeByCode("$1",services)

Sets transaction type on a transaction / trade order based on a code

Apply a cost or a tax on a transaction or trade order

$t.applyCost1(absolute,relative,min,max,calculationMethod,costTypeCode,services)

Parameters: double absolute, double relative, double min, double max, int calculationMethod, String costTypeCode, Services services

E.g. setting a relative cost of type FEE

$t.applyCost1(0,$1,0,0,0,"FEE",services)

Other methods:

$t.applyCost2
$t.applyTax1
$t.applyTax2

Calculates tax2 against total cost of the transaction

$t.applyTax2OnTotalCost(relative,min,max,calculationMethod,costTypeCode,services)

If absolute cost/tax is given, it is used. Otherwise, relative (%) cost is applied.

Min and max used if greater than zero.

Calculation method

0 = Method from the trade order. If not defined, same as 1

1 = NOTDEFINED (defaults to unit based)

2 = UNITBASED

3 = GROSSTRADEAMOUNTBASED

4 = NETTRADEAMOUNTBASED

costTypeCode is tax type code with tax methods.

Always just give ‘services’ as a param.

Change transaction or trade order type

$t.setType(services.getPortfolioService().loadTransactionType("$1"))

Needs to be a transaction type code that is defined in Preferences.

Changing settlement date by adding e.g. 2 business days taking security’s holiday calendar into account.

$t.setSettlementDate(com.fasolutions.math.util.BusinessDaysUtil.nextBusinessDate($t.getTransactionDate(),2, $t.getSecurity().getHolidayCalendar(),services.securityService.getReferenceData()))

Convert an amount from one currency to another

  1. PositionUtils.fxRate(services,fromCurrencyCode,toCurrencyCode,date)
  2. PositionUtils.convertFx(services, amount, fromCurrencyCode, toCurrencyCode, decimals)
  3. PositionUtils.convertFx(services, amount, fromCurrencyCode, toCurrencyCode)

Requires importing

  1. Returns an FX rate between "from currency" to "to currency". FX rate can be used to convert from one currency to another currency. E.g. [amount in from currency] x fxRate = [amount in to currency]

  2. Converts an amount from one currency to another currency using specific date's FX rate using given number of decimals in the return value.

  3. Converts an amount from one currency to another currency using specific date's FX rate using 2 decimals in the return value.

import fi.fasolutions.mod.portfoliomanagement.util.PositionUtils

Set string to internal info and keep existing information

$t.setIntInfoString("String1", "String2")

Adds the given strings as a key value pair string (e.g. "String1=String2") in the internal info without removing existing data.