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.
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.