Id mapping¶
What is Id mapping¶
Id mapping is a way to assign certain symbols to an alternate symbol. This assigning/mapping can be either 1-to-1 or many-to-1, as you can map multiple symbols to the same symbol.
Suppose you have a column with the days of the week as your symbols:
| id | description |
|---|---|
| `mon | 1st day of the week |
| `tues | 2nd day of the week |
| `wed | 3rd day of the week |
| `thurs | 4th day of the week |
| `fri | 5th day of the week |
| `sat | 6th day of the week |
| `sun | 7th day of the week |
And you want to group your symbols together. You would assign them:
| inputSymbol | mappedSymbol |
|---|---|
`weekdays |
`mon `tues `wed `thurs `fri |
`weekend |
`sat `sun |
This allows you to call weekdays in your query and get returned mon, tues, wed, thurs & fri .
How to apply idMapping¶
Go to the default folder in the state-config directory and manually add the symbols to the customSymbologyMap.csv file.
Example of customSymbologyMap.csv¶
| inputSymbol | mappedSymbol | alwaysMap | returnAsMappedSym |
|---|---|---|---|
`weekdays |
`mon `tues `wed `thurs `fri |
0 | 1 |
`weekend |
`sat `sun |
0 | 1 |
Columns for idMapping¶
As discussed above, the first two columns of the customSymbologyMap.csv designate which symbols are mapped. In this table there are two other columns, alwaysMap and returnAsMappedSym; these columns are boolean values (1 or 0). These are turned on and off as needed and they do as their names imply.
If alwaysMap is set to true (1) then when the query uses an inputSymbol, it will look to map the columns without the need of being activated within the query itself.
returnAsMappedSym will return the value as the mappedSymbol rather than the inputted value, but if you want weekend returned instead of sat & sun in your table, have this value set to 0 and the inputSymbol will be returned instead.
Using idMapping in a query¶
These methods of adding the custom mapping to the system will then allow the inputSymbol parameter to be used instead of the actual idList variable. For idMapping to work, within the query the value for the parameters needs to be set to 1b (true). Otherwise it won't work, unless alwaysMap is set to 1 as stated above.
.gwClient.query.sync[`getTicks;`idList`idMapping`dataClass`dataType`startDate`endDate ! (`weekdays;1b;data;tableName;.z.d;.z.d)]
Returned table for weekday¶
| id | description |
|---|---|
| `mon | 1st day of the week |
| `tues | 2nd day of the week |
| `wed | 3rd day of the week |
| `thurs | 4th day of the week |
| `fri | 5th day of the week |
.gwClient.query.sync[`getTicks;`idList`idMapping`dataClass`dataType`startDate`endDate ! (`weekend;1b;data;tableName;.z.d;.z.d)]
Returned table for weekend¶
| id | description |
|---|---|
| `sat | 6th day of the week |
| `sun | 7th day of the week |