Unable to add a sample function

I am trying to add a new function to the OG simulated example

  1. I wrote a function as https://gist.github.com/febintt/7909919
    it is variant from LastHistoricalValueFunction available with the platform.
  2. wrote code for saving function definition as https://gist.github.com/febintt/7909990
  3. added a single line to save the function in the config https://gist.github.com/febintt/7910071
  4. added a new vew defintion populator as https://gist.github.com/febintt/7910128
    the new view is visible in the view select menu in the analytics tab.

I could see the newly added columns in the analytics table view. but values are not populated.
from the documentations and some previous discussion threads, I could read that the function is automatically mapped b/w the view definitions column name and value specification in the function definition.
can someone help me to get the values?

I’ve had a look and can’t see anything that leaps out as me as obviously wrong so i’ve asked a colleague of mine to take a look.

There are two likely reasons why there are no values being calculated for these columns:

The line added to ExampleFunctionConfigurationPopulator is not quite right. This defines the new functions against the name “EXAMPLE_FUNCTIONS” in the configuration database, but this entry is then replaced by a line further on in the file which defines “EXAMPLE_FUNCTIONS” as the union of “FINANCIAL_FUNCTIONS”, “STANDARD_FUNCTIONS”, and “CUBE_FUNCTIONS”. Modifying the code to https://gist.github.com/andrewgriffin/7929888 should address this. The new functions are written into a new configuration entry (called “custom”) and that is then merged into the overall “EXAMPLE_FUNCTIONS” set used by the engine.

The function is now in the repository, and is correctly defined, but only tells the system how to calculate DOUBLE_CLOSE at the SECURITY level. The grid of values displayed in the web interface shows values at the PORTFOLIO_NODE, POSITION, and TRADE level. One option is to add the following line to MyFunctions.java:

AnalyticsFunctions.addScalingAndSummingFunction(functions, DoubleLastHistoricalValueFunction.DOUBLE_VALUE_NAME);

(https://gist.github.com/andrewgriffin/7930386)

The function repository will now include rules to get from a value at the security level to values at the TRADE/POSITION level (by multiplying the security level value by the trade/position quantity) and to the PORTFOLIO_NODE level (by summing the position values). Depending on the meaning of the DOUBLE_CLOSE value, you might not want the value from the security level to be multiplied by the trade/position quantity. In which case, the AnalyticsFunctions.addUnitScalingAndSummingFunction may be more suitable. If producing a value at the aggregate level in this way makes no sense, or if a custom aggregation strategy is needed, then further alternatives are the addUnitScalingFunction and addScalingFunction methods from the same class.

I have been trying to get some values on the equity portfolio available with the example simulated and I would like to populate values from historical timeseries CLOSE which is also available with example simulated. I would like to see the market value (quantity * latest value of the CLOSE from the historical time series) of the equity portfolio(from the total portfolio level to the leaf trade level.)

I am sorry to change my requirement a bit. but it would be very useful if I could write some function near to a meaningful one.

Can I find an example similar to such a function in the example simulated?

  1. So I rewrote the function as https://gist.github.com/febintt/7944280
  2. Added the function to the function repo as https://gist.github.com/febintt/7944299
  3. created the view https://gist.github.com/febintt/7944314

Am going the right way?

Yes… I got it finally working. Thanks for helping me out.