How to register a new function to ViewProcessor

I have created a new function as per the wiki -

But then its unclear on how to register this function to ViewProcessor
I tried creating a ViewConfiguration with that function but on trying to execute am getting

 [java] 09:20:19.729 [DependencyGraphBuilder-1] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[MyFunction, CTSpec[POSITION, DbPrt-DbPos~2299-1021~5-0], EMPTY]
 [java] 09:20:19.730 [Computation job for ViewProcess[ViewProcess~main-0 on DbCfg~1091]] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[MyFunction, CTSpec[PORTFOLIO_NODE, DbPrt~2299~5], EMPTY]

Look at ExampleStandardFunctionConfiguration if you’re running the examples or DemoStandardFunctionConfiguration if you’re using Bloomberg. You need to add a registration of your function in there.

@jim - I am badly stuck again for the last few days :frowning:
I saw the class that you have described in last comment before itself.
But then i observed the following

  1. The functions under the OPTION list in the ViewDefenition configuration is read from the class file - ./OG-Engine/src/com/opengamma/engine/value/
    Here , i don’t understand how newly inserted functions are added to the function list under ViewDefenition columns until we add the string variable to ValueRequirementNames which is not available from OG-Example.

2)I tired to execute my portfolio on the function told in documentation -
Steps i performed to do it

  • Added
    public static final String StandardEquityModelFunction = “StandardEquityModel”;
  • Added functionConfigs.add(functionConfiguration(StandardEquityModelFunction.class));
    in ExampleStandardFunctionConfiguration

The option StandardEquityModel was appearing in the configuration tab but then on executing the portfolio over the ViewDefention am getting the following error.

 [java] 01:10:43.127 [DependencyGraphBuilder-3] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[StandardEquityModel, CTSpec[PORTFOLIO_NODE, DbPrt~1124~0], EMPTY]
 [java] 01:10:43.128 [DependencyGraphBuilder-3] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[StandardEquityModel, CTSpec[POSITION, DbPrt-DbPos~1098-1118~0-0], EMPTY]
 [java] 01:10:43.129 [DependencyGraphBuilder-4] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[StandardEquityModel, CTSpec[POSITION, DbPrt-DbPos~1182-1514~0-0], EMPTY]
 [java] 01:10:43.130 [DependencyGraphBuilder-4] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn't resolve ValueReq[StandardEquityModel, CTSpec[POSITION, DbPrt-DbPos~1120-2187~0-0], EMPTY]

Kindly tell me what i missed here.
Any clue or pointers would be greatly appreciated.


Currently you will need to add your Value requirement name to if you want to be able to edit them via the web ui - we’re aware that it’s not a particularly sustainable situation, and there’s been a JIRA issue about it open for just over a month (PLAT-2034). Until that gets tackled, you’ll need to either make your own addition to or alternatively you can edit the XML representation of the ViewDefinition by using the old ‘green screen’ web UI (accessible by browsing to /jax). Bear in mind that the equity model example is taken from an existing class - you’ll need to change the class name and function description (returned by getShortName() on your function) otherwise you’ll get a clash. Also, you seem to be calling your ValueRequirementName the same as the function name. The value requirement name should represent the output you want from your function e.g. ‘VineethCustomValue’ or something (there’s an odd mix of using camel-case and using spaces in value requirement names that we should standardise). It need not (and usually does not) relate to the name of the function.

Hello @jim ,

Thanks again for your efforts even on a beautiful Sunday.
But then your reply is not helping me much.
First of all , kindly elaborate on “The value requirement name should represent the output you want from your function”.
What i understood was that it doesn’t matter what the variable name we put at

Following is the steps i followed to add a new function but am hitting the same error.

  1. Added a new function in OG-Platform/projects/OG-Examples/src/com/opengamma/examples/function/
    Please find the code here -
    The class is the exact copy of the class metnioined in the documentation but then class name and value returned by getShortName is changed.
  2. Added the line
    public static final String VineethCustomValue = “MyOGFunction”;
    New =
  3. Ran “ant build” in OG-Engine , OG-Web
  4. Added line
    functionConfigs.add(functionConfiguration(SimpleFuturePresentValueFunction.class, SECONDARY));
    New =
  5. Ran ant jetty-debug in OG-Example
  6. Added the portfolio “Equity Portfolio” to “Equity Portfolio View” from configuration tab
  7. Removed all functions from the column tab and added MyOGFunction only.
  8. Gave a run for the view “Equity Portfolio View” with default aggregation from the Analytics tab
    9)Am hitting this error
    [java] 01:00:40.413 [DependencyGraphBuilder-1] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn’t resolve ValueReq[MyOGFunction, CTSpec[POSITION, DbPrt-DbPos~1100-2105~0-0], EMPTY]

COMPLETE log - in 89874

Kindly look into it and reply the post.
I badly need your help here buddy.


My point about the requirement name you chose was that it gave me the impression that you thought the names had to be closely related to the names of the functions. You are correct in assuming you can call them whatever you want.

I assume your point 4 was a copy/paste error as you appear to have the correct line in the gist. Your function is where the problem is. Both getResults and execute still are returning FAIR_VALUE where you want e.g VineethCustomValue.

Also, your function is also coded up to operate on a per-security basis. You’ll need to either add: a position scaling function for your new value requirement in the function configuration, or change getTargetType to return POSITION. If you do the latter you’ll need to also change anywhere the target (the Security or Position object) is referenced as it’ll change from being a Security to a Position (you can the Security underlying the position by calling getSecurity() on the position). Lastly the function currently specifies that it only operates on equities, so you’ll need a portfolio with some equities in it to reference (the example equity portfolio should be fine) in your view definition.

There may be other things that need tweaking (e.g. The currency constraint), but see how you get on.


Thanks a ton @jim , that helped.
Though am getting this error -
[java] 09:41:04.112 [DependencyGraphBuilder-4] ERROR c.o.e.d.GetTerminalValuesCallback - Couldn’t resolve ValueReq[MyOGFunction, CTSpec[PORTFOLIO_NODE, DbPrt~1314~4], EMPTY]

Things are working

Good stuff.

You’re seeing that error because you haven’t added a summing function to handle portfolio aggregation. Look at the calls elsewhere addFilteredSummingFunction() or addSummingFunction() in the ExampleStandardFunctionConfiguration (there used to be a difference between the two methods in how constraints were propagated down the dep graph, but I think they’re equivalent now). If your function calculation is linear, this should add up the results you get at the POSITION level at each portfolio node to give you a total aggregate.


@jim - finally got that piece also working.
I added a summing function for position type and get it working.

Later i tried with a Equity type target function and got that working too.
In Equity type , i learned that i need to add a scaling function for position AND and summing function for Equities.

Equity type function -

Lines added in

addSummingFunction(functionConfigs, ValueRequirementNames.VineethCustomValue);
addScalingFunction(functionConfigs, ValueRequirementNames.VineethCustomValue);

Thanks again @jim , i would never have reached here without your help.
But then , i feel you need to lay down some more details in the documentation.


Totally agreed, we’ll try and improve the documentation. Really great to hear you’ve managed to get some values out!