protected override ReutersDSS.Service.ValidatedInstrument[] getValidatedInstruments(Data.SymmetryEntities dc_, ReutersDSS.Service.ExtractionServiceClient dsClient_, ReutersDSS.Service.CredentialsHeader credentials_) { // get the config document var config = BondDiscoveryConfig.GetInstance(); if (config == null || config.Countries == null) { Symmetry.Core.SLog.log.Fatal("Could not load BondDiscoveryConfig instance"); return null; } var isinToValidatedInstrument = new Dictionary<string, ValidatedInstrument>(); foreach(var countryItem in config.Countries) { foreach(var subGroupItem in countryItem.Items) { // build up request var request = new SearchInstrumentsRequest { CredentialsHeader = credentials_, request = new InstrumentSearchRequestGovCorp { IdentifierType = "ISN", IdentifierSearchValue = subGroupItem.SearchString ?? "*", PreferredIdentifierType = "ISN", IsGovernmentGroup = true, CountryType=countryItem.CountryCode, IssueDatePrimaryValue = DateTime.Today.Add(-m_lookBackPeriodForSearch), IssueDateSecondaryValue = DateTime.Today.Add(m_lookBackPeriodForSearch), IssueDateComparisonOperator = "FROM", SubGroupType = subGroupItem.AssetSubGroup } }; SearchInstrumentsResponse response; // do it try { response = dsClient_.SearchInstruments(request); } catch { response = null; } if (response == null || response.SearchInstrumentsResult == null || response.SearchInstrumentsResult.Instruments == null) continue; // go through each ValidatedInstrument pulling out ISINs, // as there are multiple brokers, isin may appear more than once foreach (var validatedInstrument in response.SearchInstrumentsResult.Instruments) { var isin = validatedInstrument.IdentifierValue; if (isinToValidatedInstrument.ContainsKey(isin)) { // even if we know about it already, prefer tradeweb as a source if(validatedInstrument.Source.Equals("TWB")) isinToValidatedInstrument[isin]=validatedInstrument; continue; } // do we know about it already? var fi = FIHelpers.GetFIBySymmetryCode(isin,dc_,ThrowBehavior.DontThrow); // if we don't then want to include it in our list of bonds to add to the database if (fi == null) { SLog.log.Debug(string.Format("New bond to add: ISIN = {0}", isin)); isinToValidatedInstrument.Add(isin, validatedInstrument); } } } } return isinToValidatedInstrument.Select(x => x.Value).ToArray(); }
protected override ReutersDSS.Service.ValidatedInstrument[] getValidatedInstruments(Data.SymmetryEntities dc_, ReutersDSS.Service.ExtractionServiceClient dsClient_, ReutersDSS.Service.CredentialsHeader credentials_) { var isinToValidatedInstrument = new Dictionary<string, ValidatedInstrument>(); foreach (var isn in m_isins) { // do we know about it already? var fi = FIHelpers.GetFIBySymmetryCode(isn, dc_, ThrowBehavior.DontThrow); if (fi != null) { SLog.log.Debug(string.Format("Bond with Isin={0} already exists in database", isn)); continue; } var request = new SearchInstrumentsRequest { CredentialsHeader = credentials_, request = new InstrumentSearchRequestGovCorp { IdentifierType = "ISN", IdentifierSearchValue = string.Format("{0}", isn), PreferredIdentifierType = "ISN", } }; SearchInstrumentsResponse response; // do it try { response = dsClient_.SearchInstruments(request); } catch { response = null; } if (response == null || response.SearchInstrumentsResult == null || response.SearchInstrumentsResult.Instruments == null) continue; // go through each ValidatedInstrument pulling out ISINs, // as there are multiple brokers, isin may appear more than once foreach (var validatedInstrument in response.SearchInstrumentsResult.Instruments) { var isin = validatedInstrument.IdentifierValue; if (isinToValidatedInstrument.ContainsKey(isin)) { // even if we know about it already, prefer tradeweb as a source if (validatedInstrument.Source.Equals("TWB")) isinToValidatedInstrument[isin] = validatedInstrument; continue; } SLog.log.Debug(string.Format("New bond to add: ISIN = {0}", isin)); isinToValidatedInstrument.Add(isin, validatedInstrument); } } return isinToValidatedInstrument.Select(x => x.Value).ToArray(); }