How to use dynamic portfolio creation code

Hi ,

I am struggling to learn how to use dynamic portfolio generation using OG. I have found that the particular module comes in OG-Financial.
lets say the input i am having is daily time series of N companies and the benchmark of that stockmarket. I want to apply CAPMBeta model to get the top 10 companies.
How can i go with it.

Any pointers would be of great help

Thanks
Vineeth

Currently our aggregation framework (implementation of AggregationFunction) can only operate on pre-computed or static data, not live computed results. The way we currently do things such as aggregations by beta are to write a utility that saves the results attached to the trade or position as an attribute or time series and then read that at aggregation time. Note that some of the aggregation functions have a ‘use attributes’ flag - this is what this is for. The other approach is to store the value in a timeseries, and many of the aggregators have a mode which allows that (which has the advantage of not overwriting the previous value each day).

Neither approach is ideal, and we’re planning to change the way aggregation works in the next major version of the compute engine to allow completely dynamic aggregates based on results. We’ve already established how to do it, but it’s a structural change that will go alongside a redesigned position/security master database, so it’ll take some months to do all the necessary work.

Jim

Hello Jim ,

Thank you for your reply.
Currently am trying to use beta function on data stored in our own DB.
I guess it will take time to apply on the dynamic data i want to give openGamma.

Still if you can give some idea on how to actually use beta function in the current form , be it static or not , it will help me understand the concept and the system.

Any help in this direction is appreciated.

Thanks
Vineeth

So, it depends if you mean that you want the system to aggregate portfolios by beta, or if you mean you want the system to calculate CAPM Beta for you. If you mean the former, the aggregator looks for the latest value in a time series with an identifier that matches that of the position you’ve created in a portfolio. More specifically, it looks up a time series with the field name APPLIED_BETA (which is where we store a precomputed beta, typically from Bloomberg). So if you have a position with a Bloomberg ticker of ‘AAPL US Equity’, that references a security in the security master (which we create using a Bloomberg loader that populates the Security Master entry with field lookups from Bloomberg). That security has a ‘bundle’ of the various identifiers which can be used to look up that security. Within the aggregator, we are able to access the security object, and we take the identifier bundle and pass it to the HistoricalTimeSeriesSource interface, which looks up that bundle with a field of ‘APPLIED_BETA’ and using the ‘DEFAULT_TSS_CONFIG’, which is a set of rules stored in the configuration master that specifies how to resolve any ambiguities if multiple time series are found (e.g. if you have one sampled at the time the new york markets close, do you choose that over the London close?).

That beta value is then used to place the position into one of several pre-determined ‘buckets’, and we then create an arbitrary portfolio using those. So, the steps you need are:

  1. Create security objects in the security master either from e.g. csv files as provided in the examples package, or using a custom built loader for your data provider.

  2. Create your portfolio with references to those portfolios, again there are examples in the examples package.

  3. Populate the time series database with APPLIED_BETA field data. This will be done in a similar way to the way PX_LAST data is currently populated in the examples from a file, or you can write your own provider that reads from e.g. Yahoo or Google.

  4. Build a view definition, set the columns you want to see (may include CAPM Beta for example), and set the portfolio to the one you’ve created.

  5. Go to the analytics view and try and load it, then choose ‘Beta’ under the ‘Aggregate by’ drop-down.

If you want to just see computed CAPM beta, you can skip step 3 here, and make sure you add CAPM Beta as a requirement in the view definition. You’ll need to have price history (PX_LAST) for the stocks in question so the PnL series can be calculated though.

There are various optional parameters that you can set as constraints on the CAPM Beta requirement too. I’ve included the default values after the constraint names

SamplingPeriod=P2Y (2 years)
ScheduleCalculator=Daily
SamplingFunction=PreviousAndFirstValuePadding
ReturnCalculator=SimpleNetReturnStrict

look at the CAPMFunction functions and DemoStandardFunctionConfiguration.java in OG-Financial to see more details.