public void CanSearchWithRequest() { var request = new SecuritySearchRequest(PagingRequest.First(20), "*", "FUTURE"); var searchResult = Context.SecurityMaster.Search(request); Assert.NotEmpty(searchResult.Documents); var securitytoFind = searchResult.Documents.First(); var identifierBundle = securitytoFind.Security.Identifiers; { var identifierSearch = new ExternalIdSearch(identifierBundle.Identifiers, ExternalIdSearchType.All); request = new SecuritySearchRequest(PagingRequest.All, "*", "FUTURE", identifierSearch); var singleSearchResult = Context.SecurityMaster.Search(request); Assert.NotEmpty(singleSearchResult.Documents); Assert.Single(singleSearchResult.Documents); Assert.Equal(singleSearchResult.Documents.Single().Security.UniqueId, securitytoFind.UniqueId); } { var identifierSearch = new ExternalIdSearch(identifierBundle.Identifiers.Concat(Enumerable.Repeat(ExternalId.Create("XXX", "YYY"), 1)), ExternalIdSearchType.Any); request = new SecuritySearchRequest(PagingRequest.All, "*", "FUTURE", identifierSearch); var singleSearchResult = Context.SecurityMaster.Search(request); Assert.NotEmpty(singleSearchResult.Documents); Assert.Single(singleSearchResult.Documents); Assert.Equal(singleSearchResult.Documents.Single().Security.UniqueId, securitytoFind.UniqueId); } }
public void CanQueryMetadata() { var result = Context.SecurityMaster.MetaData(new SecurityMetaDataRequest()); Assert.NotNull(result); Assert.NotEmpty(result.SecurityTypes); Assert.Contains("FUTURE", result.SecurityTypes); foreach (var securityType in result.SecurityTypes) { var request = new SecuritySearchRequest(PagingRequest.One, "*", securityType, null); var searchResult = Context.SecurityMaster.Search(request); switch (securityType) { default: Assert.NotEqual(0, searchResult.Paging.TotalItems); Assert.Equal(securityType, searchResult.Documents.Single().Security.SecurityType); break; } } var request1 = new SecuritySearchRequest(PagingRequest.None, "*", null, null); Assert.Equal( Context.SecurityMaster.Search(request1).Paging.TotalItems, result.SecurityTypes.Sum(r => { var request = new SecuritySearchRequest(PagingRequest.None, "*", r, null); return Context.SecurityMaster.Search(request).Paging.TotalItems; }) ); }
public void CanSearchWithObjectId() { const string type = "FUTURE"; var request = new SecuritySearchRequest(PagingRequest.First(1), "*", type); var searchResult = Context.SecurityMaster.Search(request); Assert.NotEmpty(searchResult.Documents); var securitytoFind = searchResult.Documents.First(); request = new SecuritySearchRequest(PagingRequest.All, "*", type, null, new List<ObjectId> {securitytoFind.UniqueId.ObjectID}); var singleSearchResult = Context.SecurityMaster.Search(request); Assert.NotEmpty(singleSearchResult.Documents); //Assert.Single(singleSearchResult.Documents); foreach (var securityDocument in singleSearchResult.Documents) { Assert.Equal(securityDocument.Security.UniqueId.ObjectID, securitytoFind.UniqueId.ObjectID); } }
private static SearchResult<SecurityDocument> GetSomeEquities() { var remoteSecurityMaster = Context.SecurityMaster; var request = new SecuritySearchRequest(PagingRequest.First(3), "*", "EQUITY"); return remoteSecurityMaster.Search(request); }
private void Update() { var token = ++_cancellationToken; string type = (string) typeBox.SelectedItem; string name = nameBox.Text; if (type == string.Empty) { type = null; //Wildcard } int currentPage = CurrentPage; ThreadPool.QueueUserWorkItem(delegate { try { CancelIfCancelled(token); var request = new SecuritySearchRequest(PagingRequest.OfPage(currentPage, 20), name, type); var results = SecurityMaster.Search(request); CancelIfCancelled(token); Dispatcher.Invoke((Action)(() => { CancelIfCancelled(token); itemGrid.DataContext = results.Documents.Select(s => s.Security).ToList(); itemGrid.SelectedIndex = 0; pageCountLabel.DataContext = results.Paging; currentPageLabel.DataContext = results.Paging; outerGrid.UpdateLayout(); })); } catch (OperationCanceledException) { } }); }
public SearchResult<SecurityDocument> Search(SecuritySearchRequest request) { return _restTarget.Resolve("securitySearches").Post<SearchResult<SecurityDocument>>(request); }
public void PagingBehavesAsExpected() { const int initialDocs = 10; var request = new SecuritySearchRequest(PagingRequest.First(initialDocs), "*", "FUTURE", null); var intialResult = Context.SecurityMaster.Search(request); Assert.Equal(initialDocs, intialResult.Documents.Count); Assert.InRange(intialResult.Paging.TotalItems, initialDocs, int.MaxValue); request = new SecuritySearchRequest(PagingRequest.OfIndex(0, 1), "*", "FUTURE", null); var searchResult = Context.SecurityMaster.Search(request); Assert.Equal(1, searchResult.Documents.Count); Assert.Equal(intialResult.Documents[0].UniqueId, searchResult.Documents.Single().UniqueId); request = new SecuritySearchRequest(PagingRequest.OfPage(1, 1), "*", "FUTURE", null); searchResult = Context.SecurityMaster.Search(request); Assert.Equal(1, searchResult.Documents.Count); Assert.Equal(intialResult.Documents[0].UniqueId, searchResult.Documents.Single().UniqueId); request = new SecuritySearchRequest(PagingRequest.OfIndex(2, 1), "*", "FUTURE", null); searchResult = Context.SecurityMaster.Search(request); Assert.Equal(1, searchResult.Documents.Count); Assert.Equal(intialResult.Documents[2].UniqueId, searchResult.Documents.Single().UniqueId); request = new SecuritySearchRequest(PagingRequest.OfIndex(intialResult.Paging.TotalItems, 1), "*", "FUTURE", null); searchResult = Context.SecurityMaster.Search(request); Assert.Empty(searchResult.Documents); }
public void GetsMatchSearch() { var request = new SecuritySearchRequest(PagingRequest.One, "*", "FUTURE", null); var searchResult = Context.SecurityMaster.Search(request); foreach (var securityDocument in searchResult.Documents) { var security = Context.SecurityMaster.GetSecurity(securityDocument.UniqueId); Assert.NotNull(security); Assert.Equal(securityDocument.Security.Name, security.Name); } }