Difference between ValueSpecification , ValueRequirement and ValueProperties


I have a vague idea what they are but i dont have a precise defenition for them. It would be of great help if this is explained elaborately.


ValueRequirements and ValueSpecifications are used to describe or index values. A ValueRequirement is the less specific form and used to request production of a value (e.g. Present Value of Security X). These are used in view definitions and are passed to the graph building algorithm when the view is prepared for execution. A ValueSpecification is more specific and accurately describes the actual values (e.g. Present Value of Security X as calculated by the Foo function). These are used within a dependency graph to describe data flows, act as keys to the value caches used to hold intermediate and terminal outputs produced by the calculation nodes when a graph executes, are present in the execution results received by a view client.


A discussion of ValueProperties is available at:


As a consequence of how value properties and constraints are defined it is possible for two or more different ValueRequirements to be satisfied by a single ValueSpecification. It is also possible for two or more different ValueSpecifications to satisfy a single ValueRequirement.



Thanks @Andrew , that helped me a lot in getting the concepts right.
This leave me with another question.
I need to pass key/value pairs to certain functions being invoked by viewProcessor.
Like if i am writing a function which reads historical time series from date A to date B , how will my function know the values of A and B ?



You should be able to set constraints like ‘StartDate’ and ‘EndDate’ on your value requirement and then in your first getResults() function:

getResults(final FunctionCompilationContext context, final ComputationTarget target) 

you do something like:

   final Set<ValueSpecification> results = Sets.newHashSet();
   final ComputationTargetSpecification targetSpec = target.toSpecification();
      new ValueSpecification(
        ValueRequirementNames.VINEETH_VALUE, targetSpec,
  return results;

You can get at the values the user actually provided when the execute() method is called with something like:

 String startDateStr = desiredValue.getConstraint(ValuePropertyNames.START_DATE);
 String endDateStr = desiredValue.getConstraint(ValuePropertyNames.END_DATE);

where desiredValue is one of the parameters passed to execute(). Note that the START_DATE and END_DATE value property names don’t have to be put in ValuePropertyNames, you can have your own constants in e.g. VineethValuePropertyNames and these will just be strings like ‘StartDate’ and ‘EndDate’ that you use in the constraints in your view definition.

Note that you can think of constraints/ValueProperties as view compile time parameters - they can’t change once the view is running. We are planning on adding a run-time parameter mechanism so we can pass parameters that will change while a view is running, but it’s not available yet. You shouldn’t need it for your use-case though.


Hello @jim , Thanks for your reply.
I have a confusions here
As per the getRestults defenition
getResults(FunctionCompilationContext, ComputationTarget) - returns a set of value specifications describing the objects produced by the function, as they apply to the supplied target

getResults should tell what are the results coming from my OG Function rather than what should be going into it.
And i want Start date and end date as input to the function.

I didn’t quite understand how this fits in.



The constraints are not considered inputs in the same way as market data - as I said, they are view compile-time parameters that are set once when you start a view process. We do realise that per-compute cycle parmeters are useful too, and as I said we’ll be adding them, but this is the way you’ll have to do it for now. Technically you could implement other mechanisms to get the data into your function by simulating the inputs as market data, but I wouldn’t recommend it.

In summary, the getResults() code snipped I presented is just saying to the engine ‘this function produces outputs satisfying requests for VineethValue with constraints on it of StartDate and EndDate which can have any value’. The engine will then match your function when StartDate and EndDate are provided. If you want them to be optional, you can specify that too.

Thinking further about your possible use case (I’m sketchy about your actual requirements although you appear to be doing some kind of historical time series analysis), it might be better to save you from changing your view definition each day by having a single parameter ‘SeriesLength’ or something and then calculate the start and end date using the current valuation time.

You can get the valuation time (which is now if your view process is live, or set to a different time if it’s using historical or snapshot data) by getting the valuation clock:

Clock clock = executionContext.getValuationClock();
LocalDate today = clock.today();

Of course this might not be suitable for you, so it’s just an idea.


One more thing @jim ,

I tried the solution you told , but it doesn’t seem to work.

MyOGFunction code - https://gist.github.com/2835315
The configuration at UI side - http://twitpic.com/9qweia/full
The error am seeing - https://gist.github.com/2835319

Am getting the error that it is not able to resolve the function.



What is the value of VineethCustomValue?


public static final String VineethCustomValue = “MyOGFunction”;
in ./OG-Engine/src/com/opengamma/engine/value/ValueRequirementNames.java



Ok, we’ve found your problem is due to PLAT-1356 - the position scaling function currently only propagates a specific set of value properties through to the underlying security level function. @andrew is working on a fix, you can track progress via JIRA. We’ll get back to you here when it’s ready.


@Jim - Thanks man.


A fix has now been pushed into the develop branch (our bleeding edge branch) and I cherry-picked it and also merged into the dev/stable branch also, which is probably what you should be basing your work off (basically 1.0 + a couple of hot fixes, including PLAT-1356).


Finally got it working.
New function code - https://gist.github.com/2845458



Hello again @Jim ,

Seems this is not what i was looking.
What i am looking is for simply pass some parameters to the executing functions.
And adding it to the viewDefenition doesn’t look like a good idea as the constrains are global to all instance of the function execution.
Which means if i change it in viewDefenition , it would be applied to all function executions.
I came to the conclusion when i noticed that the uniqueID of the viewDefenition is passed to viewClient rather than the viewDefenition instance

So basically i am looking for other options.

I can crack this if i get some unique id for each viewDefenition execution.
Even that i am not able to find.

To sum up , i am trying to assign a unique ID to each viewDefenition execution.
I will map this unique ID to a singleton instance which will hold the configuration specific to the function run.
And from inside the execute() function , i should be able to grab this unique ID and able to reverse map the configuration stored in the singleton function.

Any pointers on this direction would be of great help.



Like I said before, the engine doesn’t currently support per-cycle parameters without changing the view definition or using market data as inputs. However, we can think of a couple of hacky ways of doing what you want until the engine supports it directly.

  1. If you run the view using a ViewCycleExecutionSequence you can specify the valuation time for each cycle. You could make this change for each cycle and use it as a key to look up your parameters
  2. You could use a global (i.e. singleton) queue of sets of your parameters and just pull another one off for each cycle. If you need to pair inputs with outputs, then you could output the parameters as computed values into the result set
  3. Most horrifically, you could set a static variable, and run single cycles of the engine between changes
Obviously, for all of these you'll have to forgo using remote calc nodes unless you explicitly deal with the distribution of the values yourself.


Hello @jim ,

Thanks for the reply.
Let me try any of the above to achieve the requirement until engine supports this.
Also i feel this as a basic requirement and it will help if you can paste the bug id related to this feature request.



Hi ,

The suggestion given by @jim on setting unique ID for each cycle have helped me achieve my requirement.
But then i am looking forward for engine to support parameter passing and unique id assigning for each view process attaching.

Further , i understand that the general architecture of function execution is to run a function and give a single double value output. This way we can use the same function for both analytics tab and generating values out of historical data.

In case of historical data , i need to understand how to use historical data specification class. I haven’t got a clue till now on how to use it :expressionless:
My next step would be on achieving this goal.
So if anyone of you can help me on this , i would appreciate it a lot.



Functions don’t have to output a single double - they can output anything that has a fudge builder, which includes a LocalDataDoubleTimeSeries, for example. The UI will even render it as a time series pop-up.

As for your other question, I don’t understand what you mean by ‘historical data specification class’. We don’t have a class called that. Can you elaborate?



Hello @jim ,

Sorry about the lack in clarity of the question.

In the file ./OG-Financial/src/com/opengamma/batch/BatchJobRunner.java

  HistoricalMarketDataSpecification marketDataSpecification = MarketData.historical(observationDate, null, null);

  ViewExecutionOptions executionOptions = ExecutionOptions.batch(valuationTime, marketDataSpecification, null);

To start with what exactly is marketDataSpecification class for ?
Here what is observationDate and valuationTime.
How can i pump values to my function execution using the above ?
My idea of the class marketDataSpecification is that it can specify a series of time stamps and various ValueSpecefications assosiated with each timestamp (Like close or PX_LAST) Which are taken as input by the functions that are executed by ViewDefenition. I know very well that this is not completely what it is , so i need your help on this part.

I have been pondering on these questions for some time and am sure i wont make it without your help.



Hello @jim ,

I am waiting for your reply here.
It would be of great help to me if you can give some pointers here.