Hi,
I am attempting to validate a set of instruments prior to executing a TickHIstoryTimeAndSalesRequest. I've ran into an issue whereby in one of my tests which includes a long invalid RIC, the validation appears not to be working.
The list of RICs I am testing with is: ["BARC.L", "$3SK\"&", "ASFASDVFAECTGEDGFDFGHRTSY5RETGDFBVGCDVGDFSFGDFSJKTYURETAERT", "VOD.L"] where I expect only BT.L and VOD.L to be deemed as valid.
I use the following code:
var context = new ExtractionsContext(new Uri(uri), sessionToken);
DataTable instrumentsTable = GetInstrumentListFromDatabase();
var identifierList = new List<InstrumentIdentifier>();
foreach (DataRow row in instrumentsTable.Rows)
{
identifierList.Add(new InstrumentIdentifier()
{
Identifier = (string)row["Identifier"],
IdentifierType = IdentifierType.Ric
});
}
var validatedIdentifiers = context.InstrumentListOperations.ValidateIdentifiers(identifierList, false);
var validIds = validatedIdentifiers.ValidatedInstruments.Select(i => i.Identifier).ToList();
var jsonValidInstruments = JsonConvert.SerializeObject(validIds);
LogInfo("Valid Identifiers found", $"Number of valid instruments: {validIds.Count}, List of valid Instruments {jsonValidInstruments}");
The log message i see is:
Number of valid instruments: 3, List of valid Instruments ["BARC.L","ASFASDVFAECTGEDGFDFGHRTSY5RETGDFBVGCDVGD","VOD.L"]
So the long RIC to be returned as VALID from the ValidateIdentifiers() API call and it has also been trimmed to 40 characters.
I then continue with this code:
var ids = identifierList.Select(i => i.Identifier).ToList();
var invalidIds = ids.Except(validIds).ToList();
if (invalidIds.Any())
{
var jsonInalidInstruments = JsonConvert.SerializeObject(invalidIds);
LogInfo("Invalid Identifiers found", $"Number of invalid identifiers: {invalidIds.Count()}, List of invalid instruments {jsonInalidInstruments}");
}
Which results in the following log entry:
Number of invalid identifiers: 2, List of invalid identifiers: ["$3SK\"&","ASFASDVFAECTGEDGFDFGHRTSY5RETGDFBVGCDVGDFSFGDFSJKTYURETAERT"]
The problem here is because the long RIC before and after is different, the Except() operation fails to match on RIC.
So in summary 2 issues:
- The clearly invalid RIC is being returned as VALID
- The RIC returned does not match the RIC that was sent i.e. appears to be truncated to 40 chars