Domain API Plugins
Domain packages plug in and enhance the core Refinery API. Configuration and code runs in an 'if exists' method, so that if it is not defined, the API behaves no differently. Client packages can also plug in to the same points, enabling further specific customisation.
Domain type plugins all follow the convention of .domain.*; configuration is of the convention .domain.cfg.*. Similarly, client plugins are of the convention .client.*. This documentation will list all configuration and functions as domain, but all apply to .client.* also.
All API plugins are optional when creating a domain or client package. Also bear in mind that domain packages may have client hooks exposed within their functionality. For example, a .client.adjustParams function may be available within getBars in the finance domain package.
Note: All functions and configuration below list input/output and types respectively; however, no validation is performed. Incorrect configuration or functions are likely to cause errors on process boot and/or API calls.
Configuration
.domain.cfg.paramscfg
The main API function, argument and type matrix. Defines what is accepted by a get* call in the system. Defaults for non-mandatory arguments can be set here.
| Column |
Type |
Description |
Example |
funcName |
symbol |
Name of API |
getTicks |
paramName |
symbol |
Argument name |
`startTime |
mapTo |
symbol |
Should this argument be mapped to a core argument |
idList |
paramType |
symbol |
Type of argument |
`T |
default |
string |
Default for argument if not mandatory (Will be casted to the paramType) |
"00:00:00.000" |
isRequired |
boolean |
Is parameter mandatory |
0b |
paramTypes |
list |
Supported types of argument |
enlist -19h |
.domain.cfg.paramsOptionsDict
For parameters above that may only take a subset of arguments, they can be defined in domain.paramsOptionsDict to enable validation of parameters before dispatch. The structure is a dictionary with key value pair arguments!options. For example, from the finance domain
.domain.paramsOptionsDict:(!). flip
((`corAxType ;`capChange`dividend );
(`calendarType ;`isOpen`openClose`nextDay`prevDay ));
.domain.cfg.reqParamExceptions
If a parameter is marked as mandatory in the *.cfg.paramscfg, the API validation will throw an error if it is missing from the argument set. In some circumstances, it is required to ignore the need for a mandatory parameter under conditions of a subset of other parameters.
| Column |
Type |
Description |
Example |
| funcName |
symbol |
Name of the API |
`getTicks |
| paramName |
symbol |
Parameter of API to look for a condition |
`dataType |
| paramValue |
Any |
The value of the parameter to enable the exception |
`order |
| exceptionParams |
symbol |
The parameter that is except from being mandatory |
`assetClass |
In the example above from the finance domain package, if the dataType is order then the assetClass does not need to be provided.
.domain.cfg.nonDefaultedParams
Parameters to be excluded from setting a default within the API.
Type - symbol list
Example:
.domain.nonDefaultedParams:`showFilter
.domain.cfg.tickStatsColumns
For getStats calls that apply to each row with tick-level granularity
| Column |
Type |
Description |
Example |
| colName |
symbol |
Name of the analytic |
`spread |
| agg |
mixed list |
Parse tree for analytic |
(-;askPrice;bidPrice) |
| tableNames |
symbol |
Tables which this applies to |
`quote |
In the example above, you can now use the parameters below to retrieve tick-by-tick spreads
`analytics`granularityUnit`dataType!(`spread;`tick;`quote)
Functions
Index
| Function |
Purpose |
API |
| .domain.checkParams |
validation |
all |
| .domain.applyDefaultParams |
argument adjustment |
all |
| .domain.preArgAdjust |
argument adjustment |
all |
| .domain.postArgAdjust |
argument adjustment |
all |
| .domain.adjustForChecking |
argument adjustment |
all |
| .domain.stats.preArgAdjust |
argument adjustment |
getStats |
| .domain.stats.postArgAdjust |
argument adjustment |
getStats |
| .domain.ticks.genWhereClause |
clause generation |
getTicks |
| .domain.stats.runDomainClauses |
clause generation |
getStats |
| .domain.checkSpecialFunctionality |
special functionality |
getTicks |
| .domain.runSpecialFunctionality |
special functionality |
getTicks |
| .domain.stats.checkSpecialFunctionality |
special functionality |
getStats |
| .domain.stats.runSpecialFunctionality |
special functionality |
getStats |
| .domain.stats.runSpecialFunctionality |
special functionality |
getStats |
| .domain.ticks.preResAdjust |
result adjustment |
getTicks |
| .domain.ticks.postResAdjust |
result adjustment |
getTicks |
| .domain.stats.preResAdjust |
result adjustment |
getStats |
| .domain.stats.postResAdjust |
result adjustment |
getStats |
| .domain.stats.getUnderlyingStatsTab |
table returned |
getStats |
| .domain.preJoinAdjustments |
pre join level adjustment |
all |
| .domain.postJoinAdjustments |
post join level adjustment |
all |
| .domain.join |
custom join |
all |
getTicks
| Function |
.domain.checkParams |
| Purpose |
validate the argument dictionary before dispatch. |
| Arguments |
[functionName (symbol);args (dictionary); argKey (symbol list)] |
| Output |
none |
| How to use |
Run custom checks on the inbound args dictionary and throw an error if it is not a valid call. Either use .log.err or a kdb signal. The error will be passed to user. |
| Function |
.domain.applyDefaultParams |
| Purpose |
apply custom default parameters to the argument dictionary. |
| Arguments |
[functionName (symbol);args (dictionary)] |
| Output |
args |
| How to use |
append any defaults to the arg dictionary, can be used to override core parameters' defaults. |
| Function |
.domain.preArgAdjust |
| Purpose |
Adjust arguments before core adjustments are made. |
| Arguments |
[functionName (symbol);args (dictionary)] |
| Output |
args |
| How to use |
adjust arguments in the arg dictionary. Useful for mapping user provided arguments to more complicated underlying arguments. |
| Function |
.domain.postArgAdjust |
| Purpose |
Adjust arguments after core adjustments are made. |
| Arguments |
[functionName (symbol);args (dictionary)] |
| Output |
args |
| How to use |
adjust arguments in the arg dictionary. |
| Function |
.domain.ticks.genWhereClause |
| Purpose |
Add clauses to the where clause for the getTicks select. |
| Arguments |
[args (dictionary)] |
| Output |
[args (dictionary)] |
| How to use |
Where clause for the functional select is assigned to args[`wc]. This can be modified here. |
| Function |
.domain.genColClause |
| Function |
.domain.checkSpecialFunctionality |
| Purpose |
To terminate the getTicks call at this point with a return of special functionality. |
| Arguments |
[args (dictionary)] |
| Output |
null () or domainFunc (symbol) - to be passed into .domain.runSpecialFunctionality |
| How to use |
If the getTicks API call is not a simple select, the function can be branched off into custom functionality and returned to user. For example, level 2 reconstruction in the finance domain package. The function returns a symbol to denote which special functionality should be used. |
| Function |
.domain.runSpecialFunctionality |
| Purpose |
To execute and return the special functionality. |
| Arguments |
[args (dictionary); domainFunc (symbol)] |
| Output |
(result (table); args (dictionary)) to be returned to gateway and to user |
| How to use |
Use the domainFunc argument to select which domain sub function to execute and return the special functionality. |
| Function |
.domain.ticks.preResAdjust |
| Purpose |
To modify results table before core adjustments for getTicks. |
| Arguments |
[result (table); args (dictionary)] |
| Output |
result (table) |
| How to use |
If any data needs to be adjusted or appended before core outbound adjustments are done. Output is re-assigned to the results within getTicks. |
| Function |
.domain.ticks.postResAdjust |
| Purpose |
To modify results table after core adjustments for getTicks. |
| Arguments |
[result (table); args (dictionary)] |
| Output |
result (table) |
| How to use |
If any data needs to be adjusted or appended after core outbound adjustments are done. Output is re-assigned to the results within getTicks. |
| Function |
.domain.adjustForChecking |
| Purpose |
To modify args dictionary to map timeCols to a different column. |
| Arguments |
[functionName (symbol); args (dictionary)] |
| Output |
args (dictionary) |
| How to use |
Adjust arguments in the arg dictionary. |
getStats
| Function |
.domain.stats.preArgAdjust |
| Purpose |
Adjust arguments before core adjustments are made for getStats. |
| Arguments |
[args (dictionary)] |
| Output |
args |
| How to use |
adjust arguments in the arg dictionary. Useful for mapping user provided arguments to more complicated underlying arguments. |
| Function |
.domain.stats.postArgAdjust |
| Purpose |
Adjust arguments after core adjustments are made for getStats. |
| Arguments |
[args (dictionary)] |
| Output |
args |
| How to use |
adjust arguments in the arg dictionary. |
| Function |
.domain.stats.runDomainClauses |
| Purpose |
To assign custom where clause or column clause. |
| Arguments |
[args (dictionary)] |
| Output |
args |
| How to use |
Add or modify args[wc] and args[cc], and return args. |
| Function |
.domain.stats.preResAdjust |
| Purpose |
To modify results table before core adjustments for getStats. |
| Arguments |
[result (table); args (dictionary)] |
| Output |
result (table) |
| How to use |
If any data needs to be adjusted or appended before core outbound adjustments are done. Output is re-assigned to the results within getStats. |
| Function |
.domain.stats.postResAdjust |
| Purpose |
To modify results table after core adjustments for getStats. |
| Arguments |
[result (table); args (dictionary)] |
| Output |
result (table) |
| How to use |
If any data needs to be adjusted or appended after core outbound adjustments are done. Output is re-assigned to the results within getStats. |
| Function |
.domain.stats.checkSpecialFunctionality |
| Purpose |
To terminate the getStats call at this point with a return of special functionality. |
| Arguments |
[args (dictionary)] |
| Output |
null () or domainFunc (symbol) - to be passed into .domain.runSpecialFunctionality |
| How to use |
If the getStats API call is not a aggregation, the function can be branched off into custom functionality and returned to user. The function returns a symbol to denote which special functionality should be used. |
| Function |
.domain.stats.runSpecialFunctionality |
| Purpose |
To execute and return the special functionality in getStats. |
| Arguments |
[args (dictionary); domainFunc (symbol)] |
| Output |
(result (table); args (dictionary)) to be returned to gateway and to user |
| How to use |
Use the domainFunc argument to select which domain sub function to execute and return the special functionality. |
| Function |
.domain.stats.getUnderlyingStatsTab |
| Purpose |
To return arguments table. |
| Arguments |
args (dictionary) |
| Output |
aggTab (table) |
| How to use |
Use arguments dictionary to return a select function table |
API join functionality
| Function |
.domain.preJoinAdjustments |
| Purpose |
To make adjustments the GW join of API before Refinery adjustments. |
| Arguments |
[args (dictionary); data (table)] |
| Output |
data (table) to continue with the join function |
| How to use |
make any adjustments to the data before continuing with Refinery join function |
| Function |
.domain.postJoinAdjustments |
| Purpose |
To make adjustments the GW join of API after Refinery adjustments. |
| Arguments |
[args (dictionary); data (table)] |
| Output |
data (table) |
| How to use |
make any adjustments to the data after applying the Refinery join function |
| Function |
.domain.join |
| Purpose |
Run custom domain join and return to user |
| Arguments |
[args (dictionary); data (table)] |
| Output |
data (table) returned directly to user |
| How to use |
Join the incoming data and return singular table |