How to process a ViewDefenition using ViewProcessor

I am trying to submit a ViewDefenition to the ViewProcessor.
But then am not getting there so far.

I added a new component and grabbed the the ViewProcessor and ViewDefenitionRepository instants.
Next i created a client to submit the ViewDefenition but then am stuck there.

ViewDefinition equityDefenition = _viewDefinitionRepository.getDefinition("Equity Portfolio View");
ViewClient vc = _viewProcessor.createViewClient(new UserPrincipal("Vineeth", ""));
EnumSet<ViewExecutionFlags> flags = EnumSet.of(ViewExecutionFlags.RUN_AS_FAST_AS_POSSIBLE);
ViewExecutionOptions executionOptions = ExecutionOptions.singleCycle(, new MarketDataSpecification());

Here , i tired many combinations of the execution options but none seem to take me there.
From looking into the code i figured out that the ViewDefenition can be run as a single cycle , batch and infinite process.
I am looking for just a run specification.
The above code is erroring out telling “Error with market data provider”.
I am not able to grab the concepts in execution options.
I am not sure what to do here.

I am trying to run the functions over the historical data and it don’t involve live data.

Any pointers or suggestions would be greatly helpful.


Now i am facing a different issue.
I somehow made the ViewProcessor to start processing but now its not able to find the registered function.
I learned that in OG-Example , the functions are registered using the component repositoryConfigurationSource.

But then i am not able to make out how to relate repositoryConfigurationSource to viewprocessor!!!

Kindly help me out here.


View processor construction, and configuration, is typically done from a Spring XML file. For example, example-viewprocessor-spring.xml, in the OG-Examples project:

A RepositoryConfigurationSource is used by RepositoryFactoryBean to create a FunctionRepository instance. This holds instances of FunctionDefinition which define the function repository.

This FunctionRepository instance can then be used to construct a CompiledFunctionService which also holds references to the FunctionCompilationContext and a FunctionRepositoryCompiler which will be needed to make use of the functions. This is used by both the view processor to construct graphs for execution and by the calculation nodes to execute the graphs.

A FunctionResolver instance must also be created, that corresponds to the same function repository, which will define how to select appropriate functions from that repository to construct the dependency graph.

The FunctionResolver and CompiledFunctionService instances are then passed to the ViewProcessor instance via the ViewProcessorFactoryBean.


thanks @andrew

I understand the flow from your comment.
However am still pondering on few other questions.
I added a new component by adding a new entry in the example.ini file.
Then i grabbed the ViewProcessor instance and ViewDefinitionRepository instance.
Then i added this code to submit a ViewDefenition to Viewprocessor

Here my assumption is that the function repository component is first read and it is some how linked to the ViewProcessor. And that the viewprocessor i got is linked to the function repository.

Anyway i also have the same ViewProcessor and ViewDefenition repostiory instances as the one WebAnalytics.
Now in the above code , am giving the same ViewDefenitioin as given by the WebAnalytics tab.

But then when i give a ViewDefenition for processing , ViewProcessor is not able to find the function but then when the same ViewDefeniton is given by WeAnalytics its working fine.


The issue might be that , i need to link the FunctionRepostiroy with viewprocessor myself.
Or it can be something else.

In anyway please let me know what i have missed.


Thank you for the clarification on what you are trying to do.

If the view is working from the web analytics tab, and you are using the same ViewProcessor instance, then it is correctly configured with your function repository.

It is possible that the historical data is not available. In line 2 of gist 2776780 the historical specification is declared with today’s date; there may not be points for this in the underlying timeseries database. Timeseries are often updated at the close of day so the most recent point is likely to be the previous working day.

With the view running in the web analytics view, can you drill down the dependency graph view to see which market data inputs are at the leaf nodes of the graph. Are there entries for these in the timeseries database? If so, do you get the same error if you set the HistoricalMarketDataSpecification for a date on which values are available?


Hello @Andrew ,

Changing the date with an existing date in the DB is not helping.
I made sure that for that particular security a date existed in time series and changed the value at code to .
HistoricalMarketDataSpecification hd = MarketData.historical(LocalDate.of(2010, 6, 25) ,null, null);

But then am getting the same error -

Also without giving the execution option , am getting this strange error -
I feel its a bug.

Coming back to my requirement. I am planning to write a function when invoked will read data values from the historical time series master and produce the results. Here i am not planning to provide datasource to ViewClient while attaching.

How can i achieve this ?

Following is the complete dump of what i have been doing.

What i want -

  • Write my own function and attach it to the function repo - This is kind of done
  • Run a portfolio against a function and harvest the result - This is what am trying to do.

What i did so far -

  • Extended WebsiteBasicsComponentFactory to grab the instances i want. Extended Class -
  • Published a new class for localhost:8080/jax/reports REST end point. -
  • Replaced WebsiteBasicsComponentFactory with the new class i extended in config/fullstack/example.ini
  • Edited the “Equity Portfolio” portfolio which comes with the OG-Example to include just one Position ( This is for my convenience) . The position is of that of YHOO .
  • Edited “Equity Portfolio View” ViewDefenition to include just “CAPM Beta” function
  • Triggered the ViewDefenition submission using the http call ‘http://localhost:8080/jax/reports
  • And this is what i see in the console -

Here i couldn’t find any documentation on how to run a portfolio against a viewDefenition. So i don’t have a full idea on the concepts of MarketDataSpecification or most of the options in execution options.

Any kind of direction or pointers would be of great help.


The meaning of the first parameter to the attachToViewProcess method on ViewClient without the execution options parameter is slightly different. When execution options are not specified, the first parameter must be an identifier of an existing view process not a view definition. This is the cause of the stack trace displayed in gist 2780960.

Normally we would write functions that declare data requirements (e.g. Market_Value) so that whether the data comes from a historical time series master for a given date, a specific market data snapshots, or live market data, can be specified through the data source parameter to a view client. This gives a lot of flexibility at the point at which the view client is being used without having to alter the function definition.

It is possible however to write a function that sources data directly from a historical time series and operate from that. The function would have to declare no input requirements (i.e. its getRequirements implementation return the empty set). In the execute method the FunctionExecutionContext will contain the historical time series source (see OpenGammaExecutionContext.getHistoricalTimeSeriesSource) that it can use to source its data values. Note that with no “market data” as direct or indirect inputs to the function it will only be executed on a full calculation cycle - any intermediate cycles will use the result it generated on the last full cycle.

If this is unclear I can post some code later this afternoon to demonstrate more fully.

phew !!!
Finally got it working :slight_smile:
Thanks @Andrew , i owe it to you.

How i did - As you said , i emptied the list returned by getValueRequirements()
My New Function -

Still i would love to see the code examples on how to pass parameters while attaching the Viewdefention.

Hello again @Andrew ,
Thanks for your support earlier , i was able to invoke functions on portfolio using viewprocessor.
My next target is to get an idea on how passing valueRequirement works.
I believe we are using MarketDataSpecification to specify the ValueRequirement for each Functions being called.
I am trying to use HistoricalMarketDataSpecification class here.

Kindly explain the how to sent ValueRequirements using this.


Hi @Andrew ,

After lot of poking around and with the help of this -
documentation i am able to understand how the whole graph , valuerequirement things fit in.
My next issue is that i am not able to make the code work.

It will help me a lot if you can give a working code example of calling ValueProcessor to invoke process function which have some input value requirement.


Thanks for the helpful thread. I am still confused in the complex design phase. I am not able to understand how to choose the model to be used for pricing. For example if I just add this for my barriers portfolio…

private ViewDefinition getBarriersViewDefinition(final String barrierPortfolioName)
final UniqueId portfolioId = getPortfolioId(barrierPortfolioName).toLatest();
final ViewDefinition viewDefinition = new ViewDefinition(barrierPortfolioName + " View", portfolioId, UserPrincipal.getTestUser());

  final ViewCalculationConfiguration defaultCalc = new ViewCalculationConfiguration(viewDefinition, DEFAULT_CALC_CONFIG);

  addValueRequirements(defaultCalc, EquitySecurity.SECURITY_TYPE,
          new String[] {ValueRequirementNames.FAIR_VALUE});
  defaultCalc.addPortfolioRequirement(EquitySecurity.SECURITY_TYPE, ValueRequirementNames.PNL, ValueProperties.with(ValuePropertyNames.CURRENCY, Currency.USD.getCode()).get());
  return viewDefinition;


There are too many things missing. I haven’t specified the model to be used to calculate the values. This is pretty basic stuff, but am quite poor in understanding complex java design. Any simple guidance on how to add a viewprocessor or some sort of model to this?

Thanks in advance

So, in general, ValueRequirements have a range of Value Properties (which we also refer to as constraints), but there are often default values. If you look at

You can see the available ValueRequirements on Equity barrier options and what the constraints are that are available. If you then look at a specific entry e.g. Present Value, then it will show you example values you might use for those properties. Some of these will require specific things like Volatility surfaces definitions and specifications to be created and added to the config system.

For example, the model is often selected using a property called ‘CalculationMethod’ which gets set to e.g. ‘BlackModel’.

Hope that helps.