Setting parameters through the API
🔧

Setting parameters through the API

Setting parameters through the API

FIA can also be called from code using the API. We use Python for illustration, but other languages (Java, C++, C#) are also available.

A Python program that calls FIA will include calls of the following type:

FIA_python39.FIA_set_matrix( FIA_API_constants.FT_MATRIX_PORTFOLIO, p );
FIA_python39.FIA_set_string ( FIA_API_constants.FT_STRING_CARRY_DECOMPOSITION, "AGGREGATED" );
FIA_python39.FIA_set_integer ( FIA_API_constants.FT_INT_N_CORES, -1 );
FIA_python39.FIA_set_bool ( FIA_API_constants.FT_BOOL_SUMMARY_ATTRIBUTION_REPORT, True );

Symbolic constants

A symbolic constant represents a system-defined integer that is used to refer to a particular library parameter. For instance, the symbolic constant that refers to the security master data array is FT_SECURITY_DATA. The command to assign a data array called security_data to act as the security master data array is

FIA_set_parameter ( SYMBOLIC_CONSTANT, value );

The naming conventions for symbolic constants are

  • Each symbolic constant is a string delimited with an underscore character.
  • Symbolic constants are always in capitals.
  • All constants have the prefix ‘FT’.
  • The type of the constant is shown by the string immediately following the FT prefix. For instance, FT_STRING_CARRY_DECOMPOSITION refers to a string variable, while FT_BOOL_ROLLDOWN_ATTRIBUTION refers to a Boolean

Examples in Python, C# and Java can be found here.

💡
The values of SYMBOLIC_CONSTANT are provided in a header file. We strongly suggest that you use this header file, and the symbolic constants provided, rather than setting parameter values directly. The reason is that FIA's internal constant table can change between releases, but using the provided symbolic constant map will always ensure you are referring to the intended variable.

Setting Booleans from Python

In the Python API, a boolean is set as follows:

FIA_python36.FIA_set_bool ( FIA_API_constants.FT_BOOL_SUMMARY_ATTRIBUTION_REPORT, True );

Here we are using the function FIA_set_bool, which is part of package FIA_python36. The purpose of FIA_set_bool is to assign a value to a Boolean variable, as its name suggests.

FIA_set_bool takes two arguments: a symbolic constant corresponding to the value to be set, and the value that we assign to that symbolic constant.

Here we are setting the variable FT_BOOL_SUMMARY_ATTRIBUTION_REPORT, whic is part of package FIA_API_constants, hence the name of the package as a prefix.

💡
In FIA, the names of all symbolic constants are always prefixed by their type. For instance, a boolean-valued variable always has the prefix FT_BOOL, a string-valued variable the prefix FT_STRING, and so on. If you try to use FIA_set_bool on a string-valued variable, FIA will log an error and stop.