getOrderAnalyticSummary
The getOrderAnalyticSummary
API is used to query the OrderAnalytics
table. It is intended to retrieve records from the OrderAnalytics
table, applying any filters specified, and calculate summary functions on these records. The summary functions required should be listed in the supplied dictionary of arguments.
Gateway URL
The gw variable below is defined as an IPC connection to the Service Gateway. For example `:insights-qe-gateway:5050 would connect to the query environment gateway within an insights namespace.
// API arguments dictionary.
args: (!) . flip (
(`table; `OrderAnalytics);
(`startTS; 2023.07.21D10:00:00);
(`endTS; 2023.07.21D10:30:00);
(`summaryFunctions; `orderCount`fillRate)
);
opts:()!()
last gw(`getOrderAnalyticSummary;args;`callback;opts);
instrumentID orderCount fillRate
--------------------------------
CPG LN 1 1
EA US 10 0.9
ENB CN 5 1
HON US 10 0.7
ICLR US 8 1
..
Gateway URL
The $INSIGHTS_URL
, $INSIGHTS_CLIENT_ID
, $INSIGHTS_CLIENT_SECRET
variables should point at your kdb Insights install.
INSIGHTS_TOKEN=`curl -s --header "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=$INSIGHTS_CLIENT_ID&client_secret=$INSIGHTS_CLIENT_SECRET" \
"${INSIGHTS_URL}/auth/realms/insights/protocol/openid-connect/token" | jq -cr ".access_token"`
DATA=`curl -s -X POST "${INSIGHTS_URL}/servicegateway/fsi/getOrderAnalyticSummary" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $INSIGHTS_TOKEN" \
-d "$(jq -n \
'{
table : "OrderAnalytics",
startTS : "2023.07.21D10:00:00",
endTS : "2023.07.21D10:30:00",
summaryFunctions : ["orderCount","fillRate"]
}' | jq -cr .)"`
echo $DATA | jq -cr '.payload'
When issuing an IPC request, synchronous requests return a tuple where the first element is the response payload and the second is the response data. Refer to the asynchronous requests section for how to use the callback argument to get an asynchronous response. Read the extended options section for how to use the options like timeouts for your IPC call.
Arguments
Most of the arguments are shared with getTicks and getStats. The argument unique to getOrderAnalyticSummary
is summaryFunctions
.
name | required | type | default | example | description |
---|---|---|---|---|---|
table | yes | symbol | N/A | `OrderAnalytics | Name of the table to retrieve data from. Should always be OrderAnalytics . |
startTS | yes | timestamp | -0Wp | .z.p-1D | Inclusive start time of period of interest. It is recommended that this field is always used to limit scope of data in the response and to maximize query efficiency. |
endTS | yes | timestamp | 0Wp | .z.p | Exclusive end time of period of interest. It is recommended that this field is always used to limit scope of data in the response and to maximize query efficiency. |
filter | no | list | () | ("<";`price;111) | Refer to the filter section for more info. |
fill | no | symbol | () | `forward | Fills the outbound result after aggregation. Using any fill will "rack" the data, giving rows for windows that did not happen. Options are `null`zero`forward`linear`linearStep |
temporality | no | symbol | `continuous | `slice | Sets the range of data in view for each day within the query. Support two types of temporality: `continuous (default) which takes a continuous range of the data, and `slice which returns data within the startTS and endTS dates that is between the times defined in the slice argument. |
slice | no | symbol | () | (0D12:00:00;0D13:00:00) | Sets the time range to grab between each date in the startTS and endTS range when using a temporality of slice. |
sortCols | no | symbol[] | () | (`desc;`instrumentID) | Columns to sort (ascending) result data on. |
agg | no | list | () | ((`avg`price);(`first`price)) | Specifies the aggregations to perform. Read the agg section for supported formats. |
groupBy | no | symbol[] | identifier column | `exch | List of columns to group aggregation result by. |
summaryFunctions | no | symbol[] | () | `orderCount | Summary functions to apply to results. Refer to the summaryFunctions section for more details. |
summaryFunctions
List of summary functions to apply to results. Supplying a null symbol as this argument or excluding the argument altogether will apply all configured summary functions to the results.
args: (!) . flip (
(`table; `OrderAnalytics);
(`startTS; 2023.07.21D10:00:00);
(`endTS; 2023.07.21D10:30:00);
(`summaryFunctions; `orderCount`fillRate)
);
last gw(`getOrderAnalyticSummary;args;`callback;()!());
instrumentID orderCount fillRate
--------------------------------
CPG LN 1 1
EA US 10 0.9
ENB CN 5 1
HON US 10 0.7
ICLR US 8 1
..
INSIGHTS_TOKEN=`curl -s --header "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=$INSIGHTS_CLIENT_ID&client_secret=$INSIGHTS_CLIENT_SECRET" \
"${INSIGHTS_URL}/auth/realms/insights/protocol/openid-connect/token" | jq -cr ".access_token"`
DATA=`curl -s -X POST "${INSIGHTS_URL}/servicegateway/fsi/getOrderAnalyticSummary" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $INSIGHTS_TOKEN" \
-d "$(jq -n \
'{
table : "OrderAnalytics",
startTS : "2023.07.21D10:00:00",
endTS : "2023.07.21D10:30:00",
summaryFunctions : ["orderCount","fillRate"]
}' | jq -cr .)"`
echo $DATA | jq -cr '.payload'
Configuring additional summary functions
The default summary functions available are:
`orderCount;
`sharesExecuted;
`fillRate;
`orderCompletionRate;
`durationMins;
`partRate;
`executionShortfall;
`executionShortfallStderr;
`spreadNormalizedExecutionShortfall;
`startToEndReturn;
`startToEnd5MinReturn;
`startToEnd30MinReturn
These are configured in the equitiesEa.api.summary.da.config.q
file in the EquitiesEA
Accelerator package.
To configure additional summary functions to be available for application using getOrderAnalyticSummary
, edit the equitiesEa.api.summary.da.config.q
file.
The function definitions for any new summary functions should then be added to the .eqea.api.summary.clauses
variable. If a new summary function should be included as a default, the name of the summary function must be added to the .eqeq.api.summary.defaults
list variable.
In order to edit the equitiesEa.api.summary.da.config.q
file, the Accelerator must be unpacked. You can then edit them with a text editor. Then, the package should be pushed and deployed.
Unpack
Refer to the following documentation for general commands to unpack and re-package a package.
Edit
Now you can make the changes required to the equitiesEa.api.summary.da.config.q
file.
Once changes have been made and packaged, the updated package must be pushed before being deployed.
Push and deploy
Refer to the following documentation on pushing a package.
Read the instructions to deploy an assembly.