Lambda Template

In the chapter we will introduce the last but most powerful feature of Visual Lambda, the Lambda template.

 

Fixed Value

Assuming user need to add a custom module to set the "Account" tag of a new order message as "123456789".

1. We create a new module with signature of "OrderManager_NewOrderHandler". Set action as "Action Group". Then set the first action as shown below.

 

2. The first parameter of "SetValue" is the input message.

 

3. The second parameter is a FIX tag. So we choose a FIX tag.

 

4. We choose the tag of "Account".

 

5. The third parameter is a string type. We use a constant value. So we choose "Value [String]".

 

6. We set the constant value of "1234567890".

 

7. The final module look like this:

 

Template Value

If we add that filter to a session order management handler. Every time a new order is sent throw that session, the account field of the order message will be set to "1234567890". Of course this is just an example because in reality user should at least add the filter to the "order cancel request" and "order cancel/replace request" handlers, too.

But what if we want to set a different account to orders through a different session? Do we have to create another Visual lambda module that is only slightly different than the current one?

We can certainly come out with a better idea. We introduced the concept of "Lambda Template".

For those familiar with the modern programming language, Lambda Template is like generic programming in C# and Java, or template in C++. Those non-programmers needn't to worry, either. We will explain more details below.

Lambda Template is easy to use. Instead of using a constant, we choose "Template" in the pop up menu of Visual Lambda Editor. Since in above example we already set the constant, we can use "Replace" to replace it with a template.

 

A dialog will pop up asking for the template name. Here we give it a name "MyAccount". In this example, we should leave "TemplateClass" as blank. We will discuss more details about template class later on.

 

Below is the final module. Note the node of "1234567890" has changed into a Lambda Template with name "MyAccount".