Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 1
finaquant® calcs 1.01 in a Nutshell finaquant® calcs is a Commercial .NET
Library for Analytical Table Computations.
Primary features:
1) Table Functions
2) Persistent Table Array
3) Calculation Nodes & Networks
Product updates and downloads at:
finaquant.com/FinaquantCalcs
Email: [email protected]
Table Functions
A Table Function is a function with data tables as input and output parameters.
Table functions of finaquant® calcs can be compared to a stored procedures of database engines like
Oracle and MySQL, with a difference that a table function operates on in-memory tables.
Tables In, Tables Out Solving analytical problems needs a holistic approach ignoring artificial business classifications like
marketing analytics, or risk analytics, web, commission or performance analytics, business
intelligence and so on.
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 2
All these analytical applications are based on:
1. Historical data; mostly in form of data tables
2. Ability to simulate, which requires in-memory tables
In all these analytical applications you have some input tables, and you apply some analytical
operations on these input tables to generate some meaningful output tables.
Table Functions can replace Database Programming General-purpose table functions of finaquant® calcs can replace traditional SQL-based database
programming and stored procedures for analytical computations.
Note that for purposes like storing transactions, data update and data collection, SQL-based
programming is still the more appropriate option.
The advantages of a table function library become obvious for analytical computations based on
historical data, like:
financial planning
reporting
commission & fee calculations
business analytics
simulations & scenario analysis
optimizations
What is a Calculation Node A Calculation Node is a single unit (a worker ant in an Ants Nest) of a Calculation Network (i.e.
network of nodes) that carries a single table function. In compliance with its table function, a node
can have multiple input and output tables.
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 3
Briefly, this is what a Calculation Node does:
1. Reads all input tables from various databases, or from the output of another node.
2. Validates all input tables.
3. Executes the assigned table function to generate output tables.
4. Validates all output tables.
5. Writes output tables to the configured data stores. Most typical data store is the generic
database as explained in article: Persistent Table Array
You can configure the behavior of each Calculation Node such that:
A user-defined table function which can have multiple input and output tables is assigned to
node
Input tables can be fetched from a database, or from another node.
Standard validation parameters can be assigned to each input or output.
User-defined validation functions can be assigned to each input or output.
User-defined delegate functions can be registered to node events like
AfterReadingInputsJustBeforeExecution
Input Sources for a Calculation Node Where can a Calculation Node get its input tables from?
There are four possible input sources:
1. Explicit assignment of an input table to an in-memory table.
2. A user-defined delegate (reader) function
3. Generic database of the calculation engine
4. Output table of another calculation node
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 4
Explicit assignment (1) can be useful for tests and simulations.
A user-defined delegate function (2) can fetch the input table from any data store, increasing the
flexibility, but also the complexity of the node.
A relational database (3) is the most typical input source for operational calculations, like dealer
commissions, performance fees, financial plans, and so on.
Output of a calculation node (4) can feed another node in a calculation network.
Task Sequence and Log Table of a Calculation Node
Typical task sequence of a Calculation Node:
1. Read table-valued inputs from a data store
2. Validate input tables
3. Execute table function of node to generate output tables
4. Validate output tables
5. Write output tables to a data store
More information:
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 5
Calculation Nodes and Networks
Task Sequence and Log Table of a Calculation Network A Calculation Network can have multiple Calculation Nodes that are executed in sequence. Output
tables of a node can be inputs to subsequent nodes
Simulations and Optimizations with Calculation Nodes & Networks Because table-valued functions have in-memory data tables as input and output parameters, a
Calculation Network can operate totally disconnected from a database.
After you have fed all the static inputs, you can vary some selected input tables in real-time and run
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 6
simulations.
Thus, you can use the .net library finaquant® calcs for both operational and analytical calculations.
Once you have configured a Calculation Network for an operational calculation, you can use the
same Network for simulations.
The real-time simulation ability makes all sorts of analytical evaluations possible, like scenario
analysis and optimizations in order to produce strategic information for decision support.
Demo functions in Visual Studio project FinaquantCalcsStarter Visual Studio project FinaquantCalcsStarter with demo functions for getting started can be
downloaded at finaquant.com/FinaquantCalcs
List of functions
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 7
Network methods (Calculation Network)
Method Short description AddNode Add a node to network ToString Format network information as printable string Clone Clone calculation network Add_InputSource_to_Node Add a new input source to selected node of the
network; this method has multiple overloads Replace_InputSource_of_Node Replace an existing input source of selected node; this
method has multiple overloads Clone_InputSource Clone InputSource considering relative or absolute
node reference if InputMode = FeederNodeOutput Set_OutputSink_LogTable Set output sink (DataStore) for log table Unset_OutputSink_LogTable Unset output sink for log table so that it is not stored
anywhere ReadLogTable_from_Database Get log table of network from database ReadLogTableParameters Read log table from generic database to get basic
execution parameters ExecuteNetwork Read and validate all inputs, execute table functions
of all nodes, validate and write all output tables
Network properties (Calculation Network)
Property Short description NetworkName Get or set network name DataStore_Network DataStore (database connection) for reading or
writing table instances as input/output parameters of the node
ConnectionString Database connection string NodeCount Get the number of nodes in network this[int NodeIndex] Get or set (replace) a node of network
Network events (Calculation Network)
Event Short description BeforeExecutingNetwork Event is fired before executing the calculation
network, before reading all input tables AfterExecutingNetwork Event is fired after executing the calculation network,
before writing log table to data store
Node methods (Calculation Node)
Method Short description GetInput Get the table-valued parameter of selected input SetInput Assign a table to a selected input GetOutput Get the table-valued parameter of selected output Get_InputTimestamp Get timestamp of selected input Get_OutputTimestamp Get timestamp of selected output Get_Input_IfNullPermitted Check if a null-valued table is permitted for selected
input Set_Input_IfNullPermitted Set IfNullPermitted = true if a null-valued table is
permitted for selected input Get_Output_IfNullPermitted Check if a null-valued table is permitted for selected
output Set_Output_IfNullPermitted Set IfNullPermitted = true if a null-valued table is
permitted for selected output Get_Input_ContainsFields Get the vector of fields that should be contained by
the selected input table Set_Input_ContainsFields Set the vector of fields that should be contained by
the selected input table
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 8
Get_Output_ContainsFields Get the vector of fields that should be contained by the selected output table
Set_Output_ContainsFields Set the vector of fields that should be contained by the selected output table
Get_Input_ExcludesFields Get the vector of fields that should NOT be contained by the selected input table
Set_Input_ExcludesFields Set the vector of fields that should NOT be contained by the selected input table
Get_Output_ExcludesFields Get the vector of fields that should NOT be contained by the selected output table
Set_Output_ExcludesFields Set the vector of fields that should NOT be contained by the selected output table
Get_Input_TableFields Get TableFields (field structure) that should be equal to TableFields of selected input table
Set_Input_TableFields Set TableFields (field structure) that should be equal to TableFields of selected input table
Get_Output_TableFields Get TableFields (field structure) that should be equal to TableFields of selected output table
Set_Output_TableFields Set TableFields (field structure) that should be equal to TableFields of selected output table
Get_Input_ValidationFunction Get validation (delegate) function for the selected input table
Set_Input_ValidationFunction Set validation (delegate) function for the selected input table
Get_Input_ValidationParameters Get all validation parameters for a selected input table
Set_Input_ValidationParameters Set all validation parameters for a selected input table Get_Output_ValidationParameters Get all validation parameters for a selected output
table Set_Output_ValidationParameters Set all validation parameters for a selected output
table Validate_AllInputs Check validity of all input tables Validate_AllOutputs Check validity of all output tables Add_InputSource Add a new input source; this method has several
overloads Get_InputSource Get InputSource object Replace_InputSource Replace an existing input source; this method has
several overloads ReadInput Fetch selected input table from the given data source
type ReadAllInputs Fetch all inputs from indicated data sources ReadInput_from_Database Read selected input table from generic database ReadOutput_from_Database Read selected output table from generic database Get_OutputSink Get OutputSink object Add_OutputSink Add a new output sink to node Replace_OutputSink Replace an existing output sink of node Set_OutputSink_LogTable Set output sink (data store) for log table Unset_OutputSink_LogTable Unset output sink for log table so that it is not stored
anywhere ReadLogTable_from_Database Get log table of node from generic database ReadLogTableParameters Read log table from generic database to get basic
execution parameters ExecuteNode Read and validate all input tables, execute table
function, validate and write all output tables Clone Clone node ResetNode Unset all execution-related timestamps by setting
them to null. After unset node behaves as if it was
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 9
never executed before.
Node properties (Calculation Node)
Property Short description NodeName Get or set Name of node NetworkName Get or set network name CalcInstance Calculation Instance parameter of last execution StartTimeOfLastExecution Start time of last node execution EndTimeOfLastExecution End time of last node execution IfLastExecutionSuccessful Return true if last node execution was successfully
completed IfGetTimeStampsFromLogTable If true, get execution timestamps like
ExecutionStartTime and ExecutionEndTime from the log table of the node in generic database
IfLastExecutionWasSkipped True means previous execution was skipped due to old inputs
AllInputs_ContainFields Vector of fields that should be contained in all input tables
AllOutputs_ContainFields Vector of fields that should be contained in all output tables
AllInputs_ExcludeFields Vector of fields that should NOT be contained in any of the input tables
AllOutputs_ExcludeFields Vector of fields that should NOT be contained in any of the output tables
AllInputs_MinColumnCount Minimum number of columns that should be contained in all input tables
AllInputs_MaxColumnCount Maximum number of columns that can be contained in all input tables
AllInputs_MinRowCount Minimum number of rows that should be contained in all input tables
AllInputs_MaxRowCount Maximum number of rows that can be contained in all input tables
AllInputs_ValidationFunc User-defined validation function for all input tables AllOutputs_ValidationFunc User-defined validation function for all output tables dataStore DataStore (database connection) for reading or
writing table instances as input or output parameters of the node
ConnectionString Database connection string AllInputs_CustomReaderFunc User-defined function for reading all input tables of
node AllOutputs_CustomWriterFunc User-defined function for storing all output tables of
node
Node events (Calculation Node)
Event Short description BeforeReadingInputs Event is fired before reading all input tables from
assigned data sources AfterReadingInputsBeforeValidation Event is fired after having read all input tables just
before validating these input tables AfterValidatingInputsBeforeNodeExecution Event is fired after having validated all input tables
just before executing the table function of the node AfterNodeExecutionBeforeValidatingOutputs Event is fired after having execuded the table function
of the node just before validating output tables AfterValidatingInputsBeforeNodeExecution Event is fired after having validated all input tables
just before executing the table function of the node AfterNodeExecutionBeforeValidatingOutputs Event is fired after having execuded the table function
of the node just before validating output tables
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 10
AfterValidatingOutputsBeforeWriting Event is fired after having validated all output tables just before writing them to assigned data sinks
AfterWritingAllOutputs Event is fired after writing all output tables to assigned data sinks
TableMatrix methods (table functions)
Method Short description
Creating tables manually Help page: Creating tables manually Demo function in FinaquantProtosStarter: Create_MatrixTable_manually
CreateTableWithMatrices_A Create MatrixTable with given fields and value matrices. Matrix columns must match the field order defined in TblFields.
CreateTableWithMatrices_B Create MatrixTable with given fields and value matrices. Matrix columns must match the field order defined in vector ColumnNames.
CreateEmptyTable Create table without rows CreateTableWithElements_A Create a table with given element values. Reads
elements row by row; element order must match field order.
CreateTableWithElements_B Create a table with given element values. Reads elements row by row; element order must match field order.
Table element, row and column operations Help page: Element, row and column operations Demo function in FinaquantProtosStarter: Table_element_row_column_operations
GetFieldNames Get field names for text and numeric attributes, and key figures
GetFieldType Get the field type for a given field name IfIdenticalFields Return true if two tables have exactly the same fields
and field types IsEqual Return true if two tables have identical fields and
rows Clone Clone table IfFieldExistsInTable Return true if given field name exists as a column in
table GetFieldValue Get value of a field with given row index SetFieldValue Set value of a field with given row index GetTextAttribValue Get field value in table for a given text attribute and
row index SetTextAttribValue Set value of a text attribute in a row SetNumAttribValue Set value of a numeric attribute GetKeyFigValue Get field value in table for a given key figure name
and row index SetKeyFigValue Set value of a key figure GetTableRow Get complete row of a table, return value vectors GetTableRow Get complete row of a table, return TableRow object. PartitionColumn Column partition of table; return subtable with given
column names ExcludeColumns Column partitioning: Exclude given columns from
table PartitionRow Row partition of table; return subtable with given row
indices PartitionTable Column and row partition of table; return subtable
with given columns and row indices
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 11
AppendRowsToTable Append table2 to table1 vertically; both tables must have identical columns
AppendColumnsToTable Append table2 to table1 horizontally; tables must have distinct fields with identical number of rows
ReOrderColumns Reorder table columns w.r.t. field order in given TableFields object
UniqueAttributeRows Return table with attribute and date columns (only), with unique rows
InsertHierarchicallyRelatedAttribute Insert a new hierarchically related (higher) attribute (text or numeric) into table
InsertDateRelatedAttribute Insert a new numeric attribute into table which is related with the given date field.
InsertNewColumn Insert new column to table with fixed default value for all rows
AssignValueToField Assign a value to a field in rows with given position indices
AssignRandomValues Assign random values to a numeric attribute or key figure of input table within lower and upper limits
RenameColumn Change the name of a field in table CopyColumnValues Copy values of a field to another ShuffleRows Shuffle rows of table by N times swapping randomly
selected row pairs AddRowToTable Add a new row to table.
Creating test tables Help page: Creating test tables by combinations Demo functions in FinaquantProtosStarter: Create_TestTable_by_combination_ (1-3)
CombinateTableRows Generate a test table with independent and dependent attributes as all possible row combinations of input tables.
CombinateFieldValues_B Generate a table with all possible combinations of field values; random values for key figures within given ranges.
CombinateMatrixRows_A Generate a table with all possible row combinations of value matrices
CombinateMatrixRows_B Generate a table with all possible row combinations of value matrices and key figures with given value ranges
CombinateFieldValues_A Generate a table with all possible combinations of field values
Table aggregation functions Help page: Table aggregation functions Demo function in FinaquantProtosStarter: Table_aggregation_functions
AggregateAllKeyFigures Aggregates table to obtain a table of unique attribute-rows, and aggregates all key figures
AggregateAllKeyFigures_UserFunc Aggregate all key figures of table using delegate function given for each key figure
AggregateSelectedKeyFigure_A Aggregates selected (input) key figure w.r.t. all attributes of table to produce a new key figure for aggregated values
AggregateSelectedKeyFigure_A_UserFunc Aggregates selected (input) key figure w.r.t. all attributes of table to produce (insert) a new key figure for aggregated values
AggregateSelectedKeyFigure_B Aggregates selected (input) key figure w.r.t. selected reference attributes to produce a new key figure for aggregated values
AggregateSelectedKeyFigure_B_UserFunc Aggregates selected (input) key figure w.r.t. all attributes of table to produce (insert) a new key figure
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 12
for aggregated values
Table arithmetics Help page: Table arithmetics Demo function in FinaquantProtosStarter: Table_arithmetics
AddAllKeyFigures (operator +) Add all key figures of table2 to key figures of table1 with matching attribute rows
SubtractAllKeyFigures (operator -) Subtract all key figures of table2 from key figures of table1 with matching attribute rows
MultiplyAllKeyFigures (operator *) Multiply all key figures of table1 by key figures of table2 with matching attribute rows
DivideAllKeyFigures (operator /) Divide all key figures of table1 by key figures of table2 with matching attribute rows
AddSelectedKeyFigures Add selected key figure of table2 to selected key figure of table1 with matching attribute rows
SubtractSelectedKeyFigures Subtract selected key figure of table2 from selected key figure of table1 with matching attribute rows
MultiplySelectedKeyFigures Multiply selected key figure of table1 with selected key figure of table2 with matching attribute rows
DivideSelectedKeyFigures Divide selected key figure of table1 by selected key figure of table2 with matching attribute rows
AddScalarToAllKeyFigures (operator +) Add scalar value to all key figures of input table SubtractScalarFromAllKeyFigures (operator -) Subtract scalar value from all key figures of input table MultiplyAllKeyFiguresWithScalar (operator *) Multiply all key figures of input table with scalar DivideAllKeyFiguresByScalar (operator /) Divide all key figures of input table by scalar AddScalarToSelectedKeyFigure Add scalar x to selected key figure of table SubtractScalarFromSelectedKeyFigure Subtract scalar x from selected key figure of table MultiplySelectedKeyFigureByScalar Multiply selected key figure of table by scalar x DivideSelectedKeyFigureByScalar Divide selected key figure of table by scalar x
Sorting and Filtering tables Related articles: Sorting tables with finaquant® protos Filtering tables with finaquant® protos Demo function in FinaquantProtosStarter: Filtering_tables_with_conditions
SortRows Sort rows of table w.r.t. given fields and sort options (ASC/DESC)
FindRows Find rows of input table that match to rows of condition table.
FilterTableA Filter input table with a condition table. FilterTableB Filter input table with a condition cell. FilterTableC Filter input table with a list (array) of condition cells.
Combining (joining) tables Help page: Table functions for combining tables Demo function in FinaquantProtosStarter: Combining_tables
CombineKeyFigures Combine key figures of two tables. Output table contains all the columns and rows of Table1 plus additional key figures from Table2.
CombineTables Combine fields of two tables by matching common attributes. Output table contains all the columns and rows of Table1, plus added fields from Table2.
CombineTablesFirstMatch Combine fields of two tables by matching common attributes. Only the first (top-most) matched row of Table2 is added to matching row of Table1.
Date filtering and sampling Related article: Filtering and sampling tables by dates Demo functions in FinaquantProtosStarter: Filtering_tables_by_dates Sampling_tables_for_target_dates
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 13
DateRangeFilter Simple date range filter. Selects (or deselects if ExcludeDateRange = true) all rows with dates within the given range.
FilterDatesMonthly Filter days considering date range as well as month and week days.
FilterDatesQuarterly Filter days considering date range as well as quarter and week days.
SampleDatesMonthly_A Sample dates for allowed month and week days with the given search logic and return a subtable with the source and target days.
Table transformation functions Help page: Table transformation functions Related articles: Transforming rows: row-by-row processing of tables Table functions for transforming subtables Function Router Demo functions in FinaquantProtosStarter: Table_transformation_functions Row_by_Row_processing_of_table Transforming_subtables Function_Router Matrix_Function_Router
GetSubTables Generate sub-tables with selected columns (SubColumns) that correspond to rows of unique table
TransformKeyFigures Transform key figure(s) of table with a single scalar argument function like round() – with other parameters
TransformRows Transform rows; row-by-row processing of a table by a user-defined delegate function
TransformRowsDic Transform rows of table with a user-defined formula TransformSubMatrices Apply a user-defined matrix function on all subtables
of a table containing number fields only (i.e. numeric attributes and key figures)
TransformSubtables Transform subtables; apply a user-defined table function on all subtables of an input table.
FunctionRouterA Function router with condition table as filtering method. Apply selected user-defined table functions on selected subtables of input table.
FunctionRouterB Function router with condition list array as filtering method. Apply selected user-defined table functions on selected subtables of input table.
FunctionRouterC Function router with condition matrix table as filtering method. Apply selected user-defined table functions on selected subtables of input table.
MatrixFunctionRouterA Matrix Function Router with condition table as filtering method. Apply selected user-defined matrix functions on selected subtables of input table.
MatrixFunctionRouterB Matrix Function Router with condition list array as filtering method. Apply selected user-defined matrix functions on selected subtables of input table.
MatrixFunctionRouterC Matrix Function Router with condition matrix table as filtering method. Apply selected user-defined matrix functions on selected subtables of input table.
Import/Export Help page: Exporting/importing tables to/from XML and Excel files Demo functions in FinaquantProtosStarter: Export_Import_MatrixTable_Excel Export_Import_MatrixTable_XML
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 14
Export_To_DataTable Convert TableMatrix to DataTable Import_from_DataTable Convert DataTable to MatrixTable Export_to_CSVfile Export table to semicolon delimited CSV file Import_from_CSVfile Import table from semicolon delimited CSV file Export_table_to_XML Store table as XML file Import_table_from_XML Import (read) table from an XML file ToString Format table data as a printable string
TableMatrix properties
Property Short description IsEmpty Return true if table has no fields ColumnNames Return all ordered field names (text, numeric, key
figure) TextAttributeFields Get ordered field names of text attributes NumAttributeFields Get ordered field names of numeric attributes KeyFigureFields Get ordered field names of key figures TextAttribValues Get value matrix for text attributes; columns match
ordered fields NumAttribValues Get value matrix for numeric attributes; columns
match ordered fields KeyFigValues Get value matrix for key figures; columns match
ordered fields ColumnCount Number of fields in table RowCount Number of rows in table tableFields Return TableFields object of table with field
definitions metaData Return reference to MetaData object of table IsUniqueAttributeRows Return true if table has unique attribute rows; no two
rows with same attribute value combinations
PersistentTableArray methods
Method Short description PersistentTableArray(string TableName, DataStore dstore)
Initiate a persistent array of tables
MatrixTable ReadTableInstance(TableRow InstanceKeys)
Write table instance into database
public MatrixTable ReadTableInstance(TableRow InstanceKeys)
Read table instance from database
GetMatchingTableInstancesA Read all table instances from database whose instance keys match condition table
GetMatchingTableInstancesB Read all table instances from database whose instance keys match condition cell table
Using a Persistent Table Array with array syntax:
PersTblArr[InstanceKey] = CostTable; CostTable as in-memory table is written into database with the instance key InstanceKey
CostTable = PersTblArr[InstanceKey]; An instance table is read from database and assigned to CostTable (of type MatrixTable)
PersistentTableArray properties
Property Short description string TableName Get table name DataStore dataStore Get DataStore object string Node Get and set node name string Network Get and set network name MatrixTable this[TableRow InstanceKeys] Get and set instance table as an element of persistent
table array
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 15
DataStore methods
Method Short description public DataStore(string Provider) Initiate DataStore object with a Provider string like
"System.Data.Odbc" or "System.Data.SqlClient" OpenConnection(string connectionString) Initiate database connection CloseConnection() Close database connection CheckIfDatabaseExists Check if a database (schema) with given name exists CheckIfTableExists Check if database table with given name exists GetDBTableFields Get fields of database table CheckIfTableInstanceExists Check if table instance exists CheckIfTableIsEmpty Check if table exists but has no entries CheckIfTableInstanceIsLocked Check if database table instance is locked (not
overwritable) LockTableInstance Unlock table instance so that it can be overwritten
again LockAllInstancesOfTable Lock all instances of a table UnlockAllInstancesOfTable Unlocks all instances of a table WriteTableInstance Insert whole table into database along with instance
parameters. Overwrite an existing table instance unless it is locked.
DeleteTableInstance Delete table instance from database unless it is locked ReadTableInstance (1) Read table instance from database ReadTableInstance (2) Read table instance with given field structure from
database ReadTableInstance (3) Read a list of table instances from database ReadMatchingTableInstancesA Read all table instances from database whose
instance keys match condition table ReadMatchingTableInstancesB Read all table instances from database whose
instance keys match condition cell table CopyTableInstance Copy table instance from source to target ReadWholeTable Read all instances of a database table GetTableInstanceList Get the list of all instances in a database table FindTableInstanceInfo Find table instances matching the search criteria GetTableInstanceInfo Get all table instance information for a given table ReadWholeDBTable Read whole database table into a DataTable
MetaData methods
Method Short description CreateEmptyMasterData Create empty meta data without any fields ReadFieldsFromDataTable Read field definitions (names and types) from
DataTable with two columns: field name and field type
ImportFromXMLfile Read (import) meta data (fields & hierarchies) from XML file
AddNewField Add new field to meta data. Field name must match the required field name pattern.
AddNewHierarchy Add a new hierarchy matrix to meta data GetFieldType Return field type; return undefined as field type if
field is not found in meta data GetFieldName Return field name with the given position index CheckFieldAndType Return true if there is a field with the given type in
meta data GetHierarchyFields Get the ordered fields of a hierarchy GetHierarchyMatrix Return hierarchy matrix with given position index
(hierarchy no) IfFieldExists Return true if field is found in meta data
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 16
CheckIfProperFieldName Check if given string is a proper field name for a table ToString Convert meta data into printable string CheckIfHieararchy Return true if text matrix is a valid hierarchy ExportToDataSet Export meta data into a DataSet ExportToXMLfile Write (export) meta data into an XML file
MetaData properties
Property Short description IsEmpty Return true if no field is registered yet FieldCount Return number of fields registered in meta data HierarchyCount Return number of hierarchy matrices in meta data HierarchyFields Return array of field names for each hierarchy HierarchyMatrices Return array of hierarchy matrices
TableFields (table structure) methods
Method Short description CreateTableFields Define all table fields; all field names must be pre-
defined in master data CreateEmptyTableFields Create an empty TableFields object without any fields CreateTableFields Define table fields with column delimited list of
ordered field names IsEqual Return true if two TableFields objects has exactly the
same fields IfFieldExists Return true if field is found in TableFields object Clone Clone TableFields object AddNewField Add a new field to a TableFields object ToString Convert TableFields to printable string
TableRow methods
Method Short description CreateTableRow Create row with given table fields and ordered field
values CreateDefaultTableRow Create a row with default initial values for each field CloneTableRow Clone table row object CreateTableRowWithElements Create row with given ordered element values for
each field GetFieldNames Get field names for text attributes, numeric attributes
and key figures IfIdenticalFields Return true if two rows have exactly the same fields
and field types IsEqual Return true if two rows have exactly identical fields
and field values Clone Clone a row GetFieldValue Get value of a field in row SetFieldValue Set value of a field in row GetTextAttributeValue Return value of given text attribute SetTextAttributeValue Set value of given text attribute GetNumAttributeValue Return value of given numeric attribute SetNumAttributeValue Set value of given numeric attribute GetKeyFigureValue Get value of given key figure SetKeyFigureValue Set value of given key figure
TableRow properties
Property Short description FieldCount Return number of fields in row; return 0 if row is null
or empty
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 17
ColumnNames Return all ordered field names as string vector TextAttributes Return text attribute field names as string vector NumericAttributes Return numeric attribute field names as string vector KeyFigures Return key figure field names as string vector TextAttribValues Return text attribute values as string vector NumAttribValues Return numeric attribute values as numeric vector KeyFigValues Return key figure values as key field vector metaData Return reference to MetaData object of row GetTableFields Return reference to TableFields object of row
KeyMatrix methods (matrix class for key figures of type double)
Method Short description CreateEmptyMatrix Create empty matrix CreateIdentityMatrix Create NxN identity matrix CreateConstantMatrix Create NxM matrix with constant element values CloneMatrix Clone matrix ArrayToMatrix Convert array to matrix CreateSequentielMatrix Creates matrix with sequential element values CreateRandomMatrix Create matrix with random element values between 0
and 1 CreateMatrixWithElements Create matrix by entering comma seperated element
values; elements are read row-by-row into matrix VectorsToMatrix Append a comma seperated list of vectors either row
by row, or column by column to create a matrix SumOfElements Sum of elements in matrix; row-by-row, column-by-
column or all elements ToString Convert matrix to printable string Transpose Transpose matrix MatrixToVector Convert matrix to vector by reading elements row or
column wise OneDimMatrixToVector Convert 1-dimensional matrix to vector ToVector Convert a row or column of matrix into a vector MatrixPartition Get submatrix by partitioning: Mout = M[iVrows,
iVcols] RowPartition Matrix row partition: Mout = M[iVrows, :] i.e. selected
rows with all columns ColPartition Matrix column partition: Mout = M[:, iVcols] i.e.
selected columns with all rows AssignMatrixToPartition Assign matrix to matrix partition: M1[RowInd,
ColdInd] = M2 AssignScalarToPartition Assign scalar to matrix partition: M1[RowInd, ColdInd]
= x MultiplyElementWise Element-wise multiplication of two equal-sized
matrices (R = M1 .* M2) DivideElementWise Element-wise division of two equal-sized matrices (R =
M1 ./ M2) AddMatrices (+) Sum of two equal-sized matrices (R = M1 + M2) AddScalarToMatrix (+) Matrix scalar sum (Mout = M + x); add a scalar value
to all matrix elements MultiplyMatrixWithScalar (*) Matrix scalar multiplication (R = M * x) MultiplyMatrices (*) Matrix multiplication from linear algebra: R = M1 x M2 MultiplyWithVector Multiply rows or columns of matrix M with
corresponding elements of vector V Determinant Determinant of matrix; M must be a NxN square
matrix Inverse Inverse matrix; M must be a square matrix with non-
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 18
zero determinant AppendMatrix Append matrix M2 to M1 either vertically or
horizontally AggregateMatrix Matrix aggregation: Apply the given aggregation
function (sum, min, max, avg) on matrix elements AggregateMatrixUserFunc Aggregate each column of matrix with corresponding
delegate function OperationOnElements Apply the given mathematical operation like
Math.Abs(), Math.Floor(), Math.Sin() etc. on each element of matrix.
OperationOnElements_OP Apply the given mathematical operation with additional parameters like Math.Round on each element of vector, with other parameters
FindElements Find the index pairs (RowInd, ColInd) of matrix elements that satisfy the search criterion
GenerateMatrixByCombinations Convert value sets for each column into a matrix of all possible value combinations
ArrayToMatrix Convert an array of type double[,] to a matrix of key figures
OneDimArrayToMatrix Convert a 1-dimensional array of type double[] to a matrix of key figures
KeyMatrix properties
Property Short description nRows Row count of matrix nCols Column count of matrix M[i,j] Access an element of matrix M with row and column
indices i and j respectively toArray Convert matrix to a two dimensional array ([,]) ElementCount Element count of matrix (nRows x nCols) IsEmpty Return null if matrix is null or empty
NumMatrix methods (matrix class for numeric attributes of type integer)
Method Short description CreateEmptyMatrix Create empty matrix CreateIdentityMatrix Create NxN identity matrix CreateConstantMatrix Create NxM matrix with constant element values CloneMatrix Clone matrix ArrayToMatrix Convert array to matrix CreateSequentielMatrix Creates matrix with sequential element values CreateRandomMatrix Create matrix with random element values between
minValue and maxValue CreateMatrixWithElements Create matrix by entering comma seperated element
values; elements are read row-by-row into matrix VectorsToMatrix Append a comma seperated list of vectors either row
by row, or column by column to create a matrix SumOfElements Sum of elements in matrix; row-by-row, column-by-
column or all elements ToString Convert matrix to printable string Transpose Transpose matrix MatrixToVector Convert matrix to vector by reading elements row or
column wise OneDimMatrixToVector Convert 1-dimensional matrix to vector ToVector Convert a row or column of matrix into a vector MatrixPartition Get submatrix by partitioning: Mout = M[iVrows,
iVcols]
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 19
RowPartition Matrix row partition: Mout = M[iVrows, :] i.e. selected rows with all columns
ColPartition Matrix column partition: Mout = M[:, iVcols] i.e. selected columns with all rows
AssignMatrixToPartition Assign matrix to matrix partition: M1[RowInd, ColdInd] = M2
AssignScalarToPartition Assign scalar to matrix partition: M1[RowInd, ColdInd] = x
MultiplyElementWise Element-wise multiplication of two equal-sized matrices (R = M1 .* M2)
DivideElementWise Element-wise division of two equal-sized matrices (R = M1 ./ M2)
AddMatrices (+) Sum of two equal-sized matrices (R = M1 + M2) AddScalarToMatrix (+) Matrix scalar sum (Mout = M + x); add a scalar value
to all matrix elements MultiplyMatrixWithScalar (*) Matrix scalar multiplication (R = M * x) MultiplyMatrices (*) Matrix multiplication from linear algebra: R = M1 x M2 MultiplyWithVector Multiply rows or columns of matrix M with
corresponding elements of vector V Determinant Determinant of matrix; M must be a NxN square
matrix AppendMatrix Append matrix M2 to M1 either vertically or
horizontally AggregateMatrix Matrix aggregation: Apply the given aggregation
function (sum, min, max, avg) on matrix elements OperationOnElements Apply the given mathematical operation like
Math.Abs(), Math.Floor(), Math.Sin() etc. on each element of matrix.
FindElements Find the index pairs (RowInd, ColInd) of matrix elements that satisfy the search criterion
UniqueRows Unique matrix: Output matrix Mu (unique matrix) contains distinct (unique) rows of input matrix M1 without a particular order
IfUniqueRows Return True if all rows of input matrix M are unique SortRows Matrix sort: Sort rows of matrix in either ascending or
descending order GenerateMatrixByCombinations Convert value sets for each attribute into a matrix of
all possible value combinations ArrayToMatrix Convert an array of type int[,] to a matrix of numeric
attributes OneDimArrayToMatrix Convert a 1-dimensional array of type int[] to a matrix
of numeric attributes
NumMatrix properties
Property Short description nRows Row count of matrix nCols Column count of matrix M[i,j] Access an element of matrix M with row and column
indices i and j respectively toArray Convert matrix to a two dimensional array ([,]) ElementCount Element count of matrix (nRows x nCols) IsEmpty Return null if matrix is null or empty
TextMatrix methods (matrix class for text attributes of type string)
Method Short description CreateEmptyMatrix Create empty matrix CreateIdentityMatrix Create NxN identity matrix
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 20
CreateConstantMatrix Create NxM matrix with constant element values CloneMatrix Clone matrix ArrayToMatrix Convert array to matrix CreateMatrixWithElements Create matrix by entering comma seperated element
values; elements are read row-by-row into matrix VectorsToMatrix Append a comma seperated list of vectors either row
by row, or column by column to create a matrix ToString Convert matrix to printable string Transpose Transpose matrix MatrixToVector Convert matrix to vector by reading elements row or
column wise OneDimMatrixToVector Convert 1-dimensional matrix to vector ToVector Convert a row or column of matrix into a vector MatrixPartition Get submatrix by partitioning: Mout = M[iVrows,
iVcols] RowPartition Matrix row partition: Mout = M[iVrows, :] i.e. selected
rows with all columns ColPartition Matrix column partition: Mout = M[:, iVcols] i.e.
selected columns with all rows AssignMatrixToPartition Assign matrix to matrix partition: M1[RowInd,
ColdInd] = M2 AssignScalarToPartition Assign scalar to matrix partition: M1[RowInd, ColdInd]
= x AppendMatrix Append matrix M2 to M1 either vertically or
horizontally UniqueRows Unique matrix: Output matrix Mu (unique matrix)
contains distinct (unique) rows of input matrix M1 without a particular order
GenerateMatrixByCombinations Convert value sets for each attribute into a matrix of all possible value combinations
ArrayToMatrix Convert an array of type string[,] to a matrix of text attributes
OneDimArrayToMatrix Convert a 1-dimensional array of type string[] to a matrix of text attributes
TextMatrix properties
Property Short description nRows Row count of matrix nCols Column count of matrix M[i,j] Access an element of matrix M with row and column
indices i and j respectively toArray Convert matrix to a two dimensional array ([,]) ElementCount Element count of matrix (nRows x nCols) IsEmpty Return null if matrix is null or empty
KeyVector methods (vector class for key figures of type double)
Method Short description ArrayToVector Convert an array of type double[] into a vector of key
figures CreateEmptyVector Create an empty vector without any elements CreateConstantVector Create a vector with all elements sharing the same
value CreateSequenceVector Create a vector with sequential values like [2, 4, 6, ...] CreateRandomVector_A Create a vector with random element values between
0 and 1 CreateRandomVector_B Create a vector with random element values between
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 21
LowerLimit and UpperLimit CreateVectorWithElements Create a vector by entering comma seperated
element values like (2.5, 3.2, ...) ToString Convert vector into a printable string AddScalarToVector (+) Add a scalar value x to all elements of vector AddTwoVectors (+) Add elements of vector V1 to elements of vector V2 MultiplyVectorWithScalar (*) Multiply all elements of vector with a scalar x DotProduct Dot product of two vectors V1 and V2 SumOfAllElements Sum of all elements of vector VectorToMatrix Convert vector to a matrix of given row and column
size VectorToOneDimMatrix Convert vector to a 1-dimensional matrix; 1xN or Nx1
matrix depending on FillOpt Partition Vector partition: Select vector elements with given
indices, Vout = Vin[Vind] AssignToPartition Assign a vector to selected vector elements: V1[Vind]
:= V2 Reverse Reverse the order of elements in vector Append Append vector V2 to V1 such that output vector Vout
= [V1, V2] FindIndices Find vector indices such that V1 = V2(Vind) Union Union of vector elements. Output is a vector with
distinct (unique) elements Intersection Intersection of vector elements. Output is a vector
with distinct (unique) elements SetDifference Vector set difference: Vout = V1 - V2 Aggregate Apply a given standard aggregation function (sum,
min, max, avg) on vector elements Aggregate_MyFunc Vector aggregation with user-defined aggregation
function OperationOnElements Apply the given mathematical operation like
Math.Abs(), Math.Floor(), Math.Sin() etc. on each element of vector.
OperationOnElements_OP Apply the given mathematical operation with additional parameters like Math.Round on each element of vector.
FindElements Find the values (Vval) and indices (Vind) of vector elements that satisfy the search criterion
CompareElements Compare equality of the elements of two equal-length vectors V1 and V2; return 1 or 0 as comparison result; 1 for matched, 0 for not matched
ExcludeElements Exclude elements with given position indices from vector
IfValueFoundInSet Return true if value is found in set; otherwise false
ArrayToVector Convert an array of type double[] into a vector of key figures
KeyVector properties
Property Short description V[i] Access an element of vector V with position index i nLength Vector length (number of elements in vector) toArray Convert vector to array IsEmpty Return true if vector is null or empty
NumVector methods (vector class for numeric attributes of type integer)
Method Short description
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 22
ArrayToVector Convert an array of type double[] into a vector of key figures
CreateEmptyVector Create an empty vector without any elements CreateConstantVector Create a vector with all elements sharing the same
value CreateSequenceVector Create a vector with sequential values like [2, 4, 6, ...] CreateRandomVector Create vector with random element values between
0+StartValue and nRandomRange+StartValue-1 CreateVectorWithElements Create a vector by entering comma seperated
element values like (2.5, 3.2, ...) CreateRandomVector Create vector with random element values between
LowerLimit and UpperLimit defined by range ToString Convert vector into a printable string AddScalarToVector (+) Add a scalar value x to all elements of vector AddTwoVectors (+) Add elements of vector V1 to elements of vector V2 MultiplyVectorWithScalar (*) Multiply all elements of vector with a scalar x DotProduct Dot product of two vectors V1 and V2 SumOfAllElements Sum of all elements of vector VectorToMatrix Convert vector to a matrix of given row and column
size VectorToOneDimMatrix Convert vector to a 1-dimensional matrix; 1xN or Nx1
matrix depending on FillOpt Sort1 Sort vector with QuickSort in ascending order Sort2 Sort vector with System.Array.Sort Partition Vector partition: Select vector elements with given
indices, Vout = Vin[Vind] AssignToPartition Assign a vector to selected vector elements: V1[Vind]
:= V2 Reverse Reverse the order of elements in vector Append Append vector V2 to V1 such that output vector Vout
= [V1, V2] FindIndices Find vector indices such that V1 = V2(Vind) Unique Get (unsorted) unique vector with distinct elements IsUnique Return true if vector has unique (i.e. distinct)
elements IfV2containsV1 Return true if vector V2 contains all elements of V1 Union Union of vector elements. Output is a vector with
distinct (unique) elements Intersection Intersection of vector elements. Output is a vector
with distinct (unique) elements SetDifference Vector set difference: Vout = V1 - V2 Aggregate Apply a given standard aggregation function (sum,
min, max, avg) on vector elements Aggregate_MyFunc Vector aggregation with user-defined aggregation
function OperationOnElements Apply the given mathematical operation like
Math.Abs(), Math.Floor(), Math.Sin() etc. on each element of vector.
FindElements Find the values (Vval) and indices (Vind) of vector elements that satisfy the search criterion
CompareElements Compare equality of the elements of two equal-length vectors V1 and V2; return 1 or 0 as comparison result; 1 for matched, 0 for not matched
ExcludeElements Exclude elements with given position indices from vector
IfValueFoundInSet Return true if value is found in set; otherwise false
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 23
IncrementMDCounter Increment multi-digit (multi-dimensional) counter. Useful for cartesian multiplication of attribute values, and dynamic sized loops
ArrayToVector Convert an array of type int[] into a vector of numeric attributes
NumVector properties
Property Short description V[i] Access an element of vector V with position index i nLength Vector length (number of elements in vector) toArray Convert vector to array IsEmpty Return true if vector is null or empty
TextVector methods (vector class for text attributes of type string)
Method Short description ArrayToVector Convert an array of type double[] into a vector of key
figures CreateEmptyVector Create an empty vector without any elements CreateConstantVector Create a vector with all elements sharing the same
value CreateVectorWithElements Create a vector by entering comma seperated
element values like (2.5, 3.2, ...) ToString Convert vector into a printable string VectorToMatrix Convert vector to a matrix of given row and column
size VectorToOneDimMatrix Convert vector to a 1-dimensional matrix; 1xN or Nx1
matrix depending on FillOpt Sort1 Sort vector with QuickSort in ascending order Sort2 Sort vector with System.Array.Sort Partition Vector partition: Select vector elements with given
indices, Vout = Vin[Vind] AssignToPartition Assign a vector to selected vector elements: V1[Vind]
:= V2 Reverse Reverse the order of elements in vector Append Append vector V2 to V1 such that output vector Vout
= [V1, V2] FindIndices Find vector indices such that V1 = V2(Vind) Unique Get (unsorted) unique vector with distinct elements IsUnique Return true if vector has unique (i.e. distinct)
elements IfV2containsV1 Return true if vector V2 contains all elements of V1 Union Union of vector elements. Output is a vector with
distinct (unique) elements Intersection Intersection of vector elements. Output is a vector
with distinct (unique) elements SetDifference Vector set difference: Vout = V1 - V2 OperationOnElements Apply the given operation on each element of vector. FindElements Find the values (Vval) and indices (Vind) of vector
elements that satisfy the search criterion ExcludeElements Exclude elements with given position indices from
vector IfValueFoundInSet Return true if value is found in set; otherwise false
ToLowerLetters Convert all vector elements to small letter strings
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 24
ArrayToVector Convert an array of type string[] into a vector of text attributes
TextVector properties
Property Short description V[i] Access an element of vector V with position index i nLength Vector length (number of elements in vector) toArray Convert vector to array IsEmpty Return true if vector is null or empty
DateFunctions methods
Method Short description DateDifferenceInDays Return time interval between two dates (d1 - d2) in
terms of days DateToString Return date string (ShortDateString) of format
"20.07.2012" NumberToDateString Convert serial day number to date string of format
"20.07.2012" (ShortDateString) DateAddDays Add days to a given date; days to be added can be
positive or negative DateToNumber Convert DateTime to serial day number; number of
days since 30.12.1899 DayToNumber Convert date given as (day, month, year) to serial day
number NumberToDate Convert serial day number to DateTime Month Return month (1-12) for a given serial day number Quarter Return quarter (1-4) for a given serial day number HalfYear Return semi-year (1-2) for a given serial day number Year Return year for a given serial day number AddMonthsToDay Add months to date (date as serial day number) AddQuartersToDay Add quarters to date (date as serial day number) AddHalfYearsToDay Add half-years to date (date as serial day number) AddPeriodsToDay Add periods to date LastDayOfMonth Return last day of month as serial day number LastDayOfQuarter Return last day of quarter as serial day number LastDayOfHalfYear Return last day of half-year as serial day number LastDayOfYear Return last day of year as serial day number DayOfMonth Return day of month (1-31) DayOfQuarter Return day of quarter (1-92) DayOfHalfYear Return day of half-year (1-183) DayOfYear Return day of year (1-365) GenerateMonthlySampleDates Generate sample dates for a range from
FirstDayOfRange to LastDayOfRange. GenerateQuarterlySampleDates Generate sample dates for a range from
FirstDayOfRange to LastDayOfRange FindDateRange Determine boundaries of date range filter as a
function of sampling parameters. Returns first and last days of the required filter range.
DataTable extensions
Method Short description FQ_ConvertToString Convert DataTable into a printable string FQ_ConvertToMatrixTable Convert DataTable into MatrixTable FQ_PartitionColumn Column partition: Return a DataTable with selected
columns FQ_ViewTable View DataTable in grid view (read-only)
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 25
FQ_StoreTableAsXMLfile Store DataTable as XML file. FQ_ReadTableFromXMLfile Read DataTable from XML file FQ_ExportToExcelFile Export DataTable into an excel file. Note: Works only
if you have Microsoft Office/Excel (2007 or 2010) FQ_ImportFromExcelFile Read DataTable from a sheet of excel file. Note:
Works only if you have Microsoft Office/Excel (2007 or 2010)
ValueRange methods (KeyValueRange and NumValueRange) CreateRange Create a range object with lower and upper limits
ValueRange properties (KeyValueRange and NumValueRange) LowerLimit Return lower limit of range UpperLimit Return upper limit of range
CalcsHelp methods ProductInformation Product, release and copyright information, permitted
use disclaimer ShowLicenseInformation Show user license information for Finaquant Protos.
Display form to get a permanent license if this is not already done.
Version 29. Aug 2013 - R1.01 ©Finaquant Analytics finaquant.com
Page| 26
Release notes Release Date Notes
1.01 29 Aug 2013 First release of Finaquant Calcs