/// <summary> /// <p>Looks up the security data for the specified security ID details. The returned /// <c>SecurityData</c> contains the company name and an array of cross referenced IDs. </p> /// </summary> /// /// <exception cref="ArgumentNullException">if the argument is null</exception> /// <exception cref="ServiceNotAvailableException">if the lookup service is not available</exception> /// <exception cref="SecurityLookupException">if any error occurs when looking up the security data</exception> /// <param name='securityIdDetails'>the security id details used to lookup security data.</param> /// /// <returns>the security data</returns> public SecurityData Lookup(SecurityIdDetails securityIdDetails) { if (securityIdDetails.Id == "A") { // security id A references B & C return(new SecurityData("A", "company1", new string[] { "B", "C" })); } else if (securityIdDetails.Id == "B") { // security id B references D return(new SecurityData("B", "company1", new string[] { "D" })); } else if (securityIdDetails.Id == "C") { // security id C has no direct references. return(new SecurityData("C", "company1")); } else if (securityIdDetails.Id == "D") { // security id D references B return(new SecurityData("D", "company1", new string[] { "B" })); } else { // never go here. return(null); } }
public void DefaultSecurityIdParser_CUSIP_Number2() { SecurityIdDetails details = test.Parse("931142103"); // get the property to test the method. Assert.AreEqual("931142103", details.Id, "The Id property should be set to '931142103'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); }
public void DefaultSecurityIdParser_CUSIP_Letters2() { SecurityIdDetails details = test.Parse("G4770P115"); // get the property to test the method. Assert.AreEqual("G4770P115", details.Id, "The Id property should be set to 'G4770P115'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); }
public void DefaultSecurityIdParser_CUSIP_Letters1_LowerCase() { SecurityIdDetails details = test.Parse("j0176k103"); // get the property to test the method. Assert.AreEqual("J0176K103", details.Id, "The Id property should be set to 'J0176K103'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); }
public void DefaultSecurityIdParser_SEDOL_Number() { SecurityIdDetails details = test.Parse("0263494"); // get the property to test the method. Assert.AreEqual("0263494", details.Id, "The Id property should be set to '0263494'."); Assert.AreEqual(SecurityIdType.SEDOL, details.Type, "The Type property should be set to 'SEDOL'."); }
public void DefaultSecurityIdParser_ISIN_Number() { SecurityIdDetails details = test.Parse("US0378331005"); // get the property to test the method. Assert.AreEqual("US0378331005", details.Id, "The Id property should be set to 'US0378331005'."); Assert.AreEqual(SecurityIdType.ISIN, details.Type, "The Type property should be set to 'ISIN'."); }
public void TestParseTickerAccuracy1() { SecurityIdDetails sid = dsip.Parse("A"); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets.Length, 1, "FinancialMarkets array must contain only 1 entry."); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[0], FinancialMarket.NYSE, "Wrong parsing of NYSE symbol."); }
public void FinancialSecurityManager_Ctor2() { Assert.IsNotNull(test, "The ctor should work well."); SecurityIdDetails details = test.Parse("037833100"); // get the property to test the method. Assert.AreEqual("037833100", details.Id, "The Id property should be set to '037833100'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); }
public void TestParseTickerAccuracy2() { SecurityIdDetails sid = dsip.Parse("AB"); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets.Length, 2, "FinancialMarkets array must contain 2 entries."); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[0], FinancialMarket.NYSE, "Wrong parsing of NYSE symbol."); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[1], FinancialMarket.AMEX, "Wrong parsing of AMEX symbol."); }
public void FinancialSecurityManager_Ctor1() { test = new FinancialSecurityManager(lookupServices, combiner, true, false, cache); Assert.IsNotNull(test, "The ctor should work well."); SecurityIdDetails details = test.Parse("037833100"); // get the property to test the method. Assert.AreEqual("037833100", details.Id, "The Id property should be set to '037833100'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); }
public void BenchmarkParsePerformance() { IList <string> keys = new List <string>(securityIds.Keys); Start(); for (int i = 0; i < ITERATION; i++) { string key = keys[i % keys.Count]; SecurityIdDetails detail = parser.Parse(key); Assert.IsNotNull(detail, "the Parse() is wrong."); Assert.AreEqual(detail.Type, securityIds[key], "the Parse() is wrong."); } Stop("Run DefaultSecurityIdParser.Parse() "); }
public void BuildFinancialSecurityManager_FullConfig() { IConfiguration config = AccuracyTestsTestHelper.GetConfigObject(); FinancialSecurityManager manager = FinancialSecurityManagerBuilder.BuildFinancialSecurityManager(config); Assert.IsNotNull(manager, "The ctor should work well."); // 1 get the idParser to test the builder. ISecurityIdParser idParser = (ISecurityIdParser)AccuracyTestsTestHelper.getPrivateField(manager, "securityIdParser"); // this idParser should be DefaultSecurityIdParser. SecurityIdDetails details = idParser.Parse("J0176K103"); // get the property to test the method. Assert.AreEqual("J0176K103", details.Id, "The Id property should be set to 'J0176K103'."); Assert.AreEqual(SecurityIdType.CUSIP, details.Type, "The Type property should be set to 'CUSIP'."); // 2 get the lookupServices to test the builder. IDictionary <string, ISecurityLookupService> lookupServices = (IDictionary <string, ISecurityLookupService>) AccuracyTestsTestHelper.getPrivateField(manager, "securityLookupServices"); Assert.AreEqual(2, lookupServices.Count, "Should have 2 element"); Assert.IsTrue(lookupServices.ContainsKey(SecurityIdType.CUSIP), "Should have this lookupService name"); Assert.IsTrue(lookupServices.ContainsKey(SecurityIdType.ISIN), "Should have this lookupService name"); // 3 get the recursive to test the builder. bool recursive = (bool)AccuracyTestsTestHelper.getPrivateField(manager, "recursiveLookup"); Assert.IsFalse(recursive, "Should set to false"); // 4 get the recursive to test the builder. bool reference = (bool)AccuracyTestsTestHelper.getPrivateField(manager, "referenceLookup"); Assert.IsTrue(reference, "Should set to true"); // 5 get the combiner to test the builder. ISecurityDataCombiner combiner = (ISecurityDataCombiner) AccuracyTestsTestHelper.getPrivateField(manager, "securityDataCombiner"); SecurityData data1 = new SecurityData("1", "TopCoder", new string[] { "1", "2", "3" }); SecurityData data2 = new SecurityData("2", "IBM", new string[] { "4", "2", "3" }); SecurityData result = combiner.Combine(data1, data2); // get the property to test the method. Assert.AreEqual("1", result.Id, "The Id property should be set to '1'."); Assert.AreEqual("TopCoder", result.CompanyName, "The CompanyName property should be set to 'TopCoder'."); }
public void TestParseTickerAccuracy3() { SecurityIdDetails sid = dsip.Parse("ABCDX"); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets.Length, 2, "FinancialMarkets array must contain 2 entries."); //A valid NYSE symbol Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[0], FinancialMarket.NYSE, "Wrong parsing of NYSE symbol."); //A valid NASDAQ symbol with special code as Mutual Fund Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[1], FinancialMarket.NASDAQ, "Wrong parsing of NASDAQ symbol."); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).SpecialCode, "Mutual fund", "Wrong parsing of NASDAQ symbol."); }
public void TestParseTickerAccuracy4() { SecurityIdDetails sid = dsip.Parse("ABC.X"); Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets.Length, 2, "FinancialMarkets array must contain 2 entries."); //A valid NYSE symbol Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[0], FinancialMarket.NYSE, "Wrong parsing of NYSE symbol."); //A valid AMEX symbol Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).FinancialMarkets[1], FinancialMarket.AMEX, "Wrong parsing of AMEX symbol."); //Special code must be Mutual fund Assert.AreEqual((sid as SymbolTickerSecurityIdDetails).SpecialCode, "Mutual fund", "Wrong parsing of special code."); }
/// <summary> /// Mocks the lookup behavior. Returns data according to the Id of securityIdDetails. /// </summary> /// <param name="securityIdDetails">The securityId details</param> /// <returns>Returns data according to the Id of securityIdDetails.</returns> public SecurityData Lookup(SecurityIdDetails securityIdDetails) { if (securityIdDetails.Id == "A") { // security id A references B & C return(new SecurityData("A", "company1", new string[] { "B", "C" })); } else if (securityIdDetails.Id == "B") { // security id B references D return(new SecurityData("B", "company1", new string[] { "D" })); } else if (securityIdDetails.Id == "C") { // security id C has no direct references. return(new SecurityData("C", "company1")); } else if (securityIdDetails.Id == "D") { // security id D references B return(new SecurityData("D", "company1", new string[] { "B" })); } else if (securityIdDetails.Id == "X") { // security id X references Y and X return(new SecurityData("X", "company1", new string[] { "Y", "X" })); } else if (securityIdDetails.Id == "Y") { // security id Y references X return(new SecurityData("Y", "company1", new string[] { "X" })); } else if (securityIdDetails.Id == "ZZZ") { throw new ServiceNotAvailableException("Service is down."); } throw new SecurityLookupException("No such company found"); }
/// <summary> /// Implements a basic lookup function. /// </summary> /// <param name="securityIdDetails">The security id details.</param> /// <returns>Security data that matches the details.</returns> public SecurityData Lookup(SecurityIdDetails securityIdDetails) { if (securityIdDetails.Id.Equals("A")) { // security id A references B & C return(new SecurityData("A", "companyA", new string[] { "B", "C" })); } else if (securityIdDetails.Id.Equals("B")) { // security id B references D return(new SecurityData("B", "companyB", new string[] { "D" })); } else if (securityIdDetails.Id.Equals("C")) { // security id C has no direct references. return(new SecurityData("C", "companyC")); } else if (securityIdDetails.Id.Equals("D")) { // security id D references B return(new SecurityData("D", "companyD", new string[] { "B" })); } return(null); }
/// <summary> /// <para>Lookup the security data by the given security id details. /// The returned SecurityData contains the company name for now and an array of cross referenced ids. /// </para> /// </summary> /// /// <param name="securityIdDetails">the security id details used to lookup security data.</param> /// <returns>the security data to return.</returns> /// <exception cref="ArgumentNullException">if the argument is null.</exception> /// <exception cref="ServiceNotAvailableException">if the lookup service is not available.</exception> /// <exception cref="SecurityLookupException">if any error occurs when looking up the security data.</exception> public SecurityData Lookup(SecurityIdDetails securityIdDetails) { if (securityIdDetails.Id == "A") { // security id A references B & C return(new SecurityData("A", "company1", new string[] { "B", "C" })); } else if (securityIdDetails.Id == "B") { // security id B references D return(new SecurityData("B", "company1", new string[] { "D" })); } else if (securityIdDetails.Id == "C") { // security id C has no direct references. return(new SecurityData("C", "company1")); } else if (securityIdDetails.Id == "D") { // security id D references B return(new SecurityData("D", "company1", new string[] { "B" })); } throw new SecurityLookupException("Error occurs"); }
public void TestLookup_invalid_securityIdDetails() { SecurityIdDetails detail = new SecurityIdDetails("id", "type"); SecurityData result = instance.Lookup(detail); }
public void TearDown() { test = null; }
public void SetUp() { test = new SecurityIdDetails("123", "type"); }
public void TestParseSedolAccuracy1() { SecurityIdDetails sid = dsip.Parse("B1F3M59"); Assert.AreEqual(sid.Type, SecurityIdType.SEDOL, "Wrong parsing of SEDOL."); }
public void TestParseIsinAccuracy3() { SecurityIdDetails sid = dsip.Parse("US459056DG91"); Assert.AreEqual(sid.Type, SecurityIdType.ISIN, "Wrong parsing of ISIN."); }
public void TestParseIsinAccuracy2() { SecurityIdDetails sid = dsip.Parse("us3838831051"); Assert.AreEqual(sid.Type, SecurityIdType.ISIN, "Wrong parsing of ISIN."); }
public void TestParseCusipAccuracy3() { SecurityIdDetails sid = dsip.Parse("g4770p115"); Assert.AreEqual(sid.Type, SecurityIdType.CUSIP, "Wrong parsing of CUSIP."); }