Search Security with id in history


#1

I have added a Security with ExternalId.of(“ticker”, “ticker1”). Later I changed the security id from “ticker1” to “ticker11” by the following code block.

ExternalIdBundle existingIdBundle = existingSecurity.getExternalIdBundle();
newIdBundle = existingIdBundle.withoutScheme(id.getScheme());
newIdBundle = newIdBundle.withExternalId(id);
existingSecurity.setExternalIdBundle(newIdBundle);

securityMaster.update(existingSecurity);

Now I could search the security with id “ticker11”. But can I search and find the same security with an id “ticker1” from history in some way?


#2

The SecuritySearchRequest class contains a versionCorrection property which allows this. By default, the versionCorrection is set to “latest-latest”, which will only find the latest stte. If you set the property to a different VersionCorrection object, with a date/time in the past, then you will find the “ticker1” instance.
http://docs.opengamma.com/display/DOC/Bi-temporal+versioning+using+versions+and+corrections


#3

Can I get clarification on the parameters provided when creating a versionCorrection object like versionAsOf, correctedTo…and How can I get a versionCorrection object from a LocalDate / a date string given?


#4

The instants represent two ways of slicing the data in the database. The correction instant is controlled by the underlying master class, and is always set to the database time when inserting or correcting a piece of information. The version instant can be controlled when making changes.

For example, in the case above, you have two versions of the security. As you are not working with corrections, you can ignore that dimension and set the correction instant to “LATEST”. For the two versions in the database, both will have an instant equal to the the moment when the add/update occurred (unless you take control of the clock or use other master methods). Call these two instants instant1 and instant2.

If your search version instant is before instant1, you get no matches.
If your search version instant is between instant1 and instant2, you get the old version of the security.
If your search version instant is after instant1, you get the latest version of the security.