The Value Bucket block can be used to store multiple pairs of numeric values which can be retrieved as needed. Each pair consists of a KEY which the user can use to locate a specific pair, and a VALUE which is the actual numeric value of interest to the user. The Value Bucket block operates in the following manner:
A discrete event message received through the store port triggers the Value Bucket block.
When triggered, the Value Bucket block adds to its internal hash table (see: Internal data collection for more information about hash tables) a new entry consisting of a KEY and a VALUE.
After the addition of the new entry, the Value Bucket block will look at the input message, and search through its internal hash table to locate the entry whose key value matches the input lookup port.
Once it finds the correct entry, it outputs the entry's value through the val output port.
Afterwards, it passes on the original message unchanged through its out port.
Optionally, you can also set up the Value Bucket block to empty its internal hash table and reset its value to a NaN (Not A Number) when a discrete event message triggers the reset port.
Example Count the traded quantity above the open price for a contract
The Value Bucket block uses the Fields Formula Editor to specify the values for the storeKey and storeVal ports.
The Value Bucket block's internal hash table can be conceptualized as a simple table with two columns: KEY and VALUE. In the following example, suppose that the Value Bucket block is triggered by a discrete event message every time a trade occurs in a given instrument. When triggered, the Value Bucket will extract and use the Trade Price as the KEY; and the Trade Quantity as the VALUE of each new entry. A user might create such table to maintain and use the running volume at different prices during a trading session.
Suppose that the Value Bucket block already has three entries in its internal hash table, as shown in the following illustration.
Suppose that a new trade occurs at Price 1290 25, for a Quantity of 3. A discrete event message containing this information will trigger the Value Bucket block. When triggered, the block will extract and add a new entry to its internal hash table using the Trade price and the Trade Quantity.
Suppose that the user specifies the Hole input as 1289 50. The block will search through its internal hash table to locate the entry whose KEY value matches the input Hole value. Afterwards, it will output the VALUE of the corresponding entry as 7.
To customize the block, update the Block Properties.
|Name||Name to display beneath the block on the ADL canvas|
Occasionally, two entries in the hash table will end up with the same KEYs. In this case, the Value Bucket will resolve the conflict through one of the three methods chosen by the user:
Equations used to calculate the value of the entry's key and value pair
The edit link opens the Fields Formula Editor.