예제 #1
0
        public CredentialsHeader GetCredentialsHeader(Credentials credentials)
        {
            var credentialsHeader = new CredentialsHeader()
            {
                Username  = credentials.Username,
                Password  = credentials.Password,
                Facility  = credentials.Facility,
                CultureId = "en"
            };

            return(credentialsHeader);
        }
예제 #2
0
        public void AddAccount_GivenValidCredentialsAndDto_ShouldAddTheAccountSuccessfully(int applicationId, string personNumber)
        {
            // ARRANGE
            var    app         = GetApplication(applicationId);
            var    applicant   = GetApplicant();
            var    addAccount  = GetAddAccount(personNumber);
            var    credentials = GetCredentials();
            string messageXml  = addAccount.Message?.SerializeToXmlString();

            var stubSoapClient = Substitute.For <CcmWebServiceSoap>();
            //var stubSoapClient = new CcmWebServiceSoapClient("CcmWebServiceSoap", "https://dna-ccmapp-ttd.uccu.com/ccm-Test-ws/ccmwebservice/ccmwebservice.asmx");

            var repo = new SoapRepository("ABC123", credentials, stubSoapClient);

            var credentialsHeader = new CredentialsHeader()
            {
                Username  = credentials.Username,
                Password  = credentials.Password,
                Facility  = credentials.Facility,
                CultureId = "en"
            };

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(messageXml, app.HostValues, addAccount.Message?.HostValueParentNode);
            messageXml = HostValueTranslator.UpdateRequestWithHostValues(messageXml, applicant.HostValues, addAccount.Message?.HostValueParentNode);

            var processMessageNodeRequest = new ProcessMessageNodeRequest();

            processMessageNodeRequest.CredentialsHeader = credentialsHeader;
            processMessageNodeRequest.request           = GetXmlNode(messageXml);
            repo.ProcessMessageNodeRequest = processMessageNodeRequest;

            var messageResponse = new MessageResponse()
            {
                TraceNumber   = applicationId.ToString(),
                ResponseCode  = "Success",
                AccountNumber = "2001158945704"
            };
            var messageResponseXml = messageResponse.SerializeToXmlString();

            var processMessageNodeResponse = new ProcessMessageNodeResponse()
            {
                ProcessMessageNodeResult = GetXmlNode(messageResponseXml)
            };

            repo.SoapClient.ProcessMessageNode(processMessageNodeRequest).Returns(processMessageNodeResponse);

            // ACT
            var messageNodeResponse = repo.ProcessMessage(messageXml);

            // ASSERT
            Assert.IsNotNull(repo.MessageResponse);
            Assert.AreEqual("Success", repo.MessageResponse.ResponseCode);
        }
		protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
		{
			var allEDs = dc_.FIs.Where(x =>
				x.InstrumentType == InstrumentType.IRFuture
				&& x.Maturity >= DateTime.Today
				&& x.SymmetryCode.StartsWith("ED"))
				.Where(x => x.Maturity.Value.Month % 3 == 0)
				.OrderBy(x => x.Maturity)
				.Take(12);

			var listOfInstruments = new List<InstrumentIdentifier>();

			// find the market snap to which 
			var marketSnap = QuoteHelpers.GetMarketSnap("CLOSE", m_markDate, dc_, ThrowBehavior.DontThrow);
			if (marketSnap == null) return null;

			var source = QuoteHelpers.GetQuoteSource("SYM", dc_, ThrowBehavior.DontThrow);
			if (source == null) return null;

			foreach (var ed in allEDs)
			{
				EDItem item = new EDItem(ed, dc_, marketSnap, source);

				if (item.CanRequestPrice)
				{
					m_items.Add(item);
					m_ricToOptionItem[item.OptionAbovePrice.ReutersTicker] = item.OptionAbovePrice;
					m_ricToOptionItem[item.OptionBelowPrice.ReutersTicker] = item.OptionBelowPrice;

					listOfInstruments.Add(new InstrumentIdentifier()
					{
						IdentifierValue = item.OptionBelowPrice.ReutersTicker,
						IdentifierType="RIC"
					});

					listOfInstruments.Add(new InstrumentIdentifier()
					{
						IdentifierValue = item.OptionAbovePrice.ReutersTicker,
						IdentifierType="RIC"
					});
				}
			}

			if (listOfInstruments.Count() > 0)
			{
				var v = ServiceHelpers.ValidateInstruments_FindUnValidated(listOfInstruments.ToArray(), dsClient_, ref credentials_);
				m_notValidatedIdentifiers = v.Item2;
				return v.Item1;
			}
			else
				return null;
		}
예제 #4
0
        public CredentialsHeader GetCredentialsHeader()
        {
            CredentialsHeader credentialsHeader = null;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.GetCredentialsHeader"))
            {
                credentialsHeader = new CredentialsHeader()
                {
                    Username  = _credentials.Username,
                    Password  = _credentials.Password,
                    Facility  = _credentials.Facility,
                    CultureId = "en"
                };
            }

            return(credentialsHeader);
        }
예제 #5
0
        public ProcessMessageNodeRequest GetProcessMessageNodeRequest(CredentialsHeader credentialsHeader, string request)
        {
            ProcessMessageNodeRequest processMessageNodeRequest = null;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.GetProcessMessageNodeRequest"))
            {
                var newNode = GetXmlNodeRequest(request);

                processMessageNodeRequest = new ProcessMessageNodeRequest()
                {
                    CredentialsHeader = credentialsHeader,
                    request           = newNode
                };
            }

            return(processMessageNodeRequest);
        }
예제 #6
0
        public MessageResponse ProcessMessage(string message)
        {
            ClearMessageResponse();

            MessageResponse messageResponse = null;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.ProcessMessage(string)"))
            {
                if (_credentialsHeader == null)
                {
                    _credentialsHeader = GetCredentialsHeader();
                }
                tr.LogObject(_credentialsHeader);

                var processMessageNodeRequest = GetProcessMessageNodeRequest(_credentialsHeader, message);
                tr.Log("CCM Message Request:");
                tr.LogObject(processMessageNodeRequest);

                try
                {
                    var processMessageNodeResponse = _soapClient.ProcessMessageNode(processMessageNodeRequest);
                    tr.Log("CCM Message Response:");
                    tr.LogObject(processMessageNodeResponse);

                    messageResponse = processMessageNodeResponse?.ProcessMessageNodeResult.Deserialize <MessageResponse>();
                    tr.LogObject(messageResponse);

                    _messageResponse = messageResponse;
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.ProcessMessage(string)");
                    throw;
                }

                return(messageResponse);
            }
        }
    protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
    {
      var allFixings = getAllSwaps(dc_);

      m_ric_to_FIs = new Dictionary<string, FI>();

      var listOfInstruments = new List<InstrumentIdentifier>();


      foreach (var fi in allFixings)
      {
        string[] rics = FIHelpers.GetFIIdentifiers(fi.SymmetryCode, IdentifierType.RIC, dc_, ThrowBehavior.DontThrow);

        if (rics == null || rics.Length==0)
        {
          SLog.log.WarnFormat("Cannot locate RIC for SymmetryCode:{0}", fi.SymmetryCode);
          continue;
        }
        Array.ForEach(rics, x =>  {
            m_ric_to_FIs.Add(x, fi);
            listOfInstruments.Add(new InstrumentIdentifier()
            {
              IdentifierType="RIC",
              IdentifierValue=x
            });
          }
          );
      }

      var t = ServiceHelpers.ValidateInstruments_FindUnValidated(listOfInstruments.ToArray(), dsClient_, ref credentials_);

      m_notValidatedIdentifiers = t.Item2;

      return t.Item1;

    }
    protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
    {
      m_ric_to_FIs = new Dictionary<string, FI>();

      var listOfInstruments = new List<InstrumentIdentifier>();

      foreach (var fi in getAllFixings(dc_))
      {
        string ric = FIHelpers.GetFIIdentifier(fi.SymmetryCode, IdentifierType.RIC, dc_, ThrowBehavior.DontThrow);

        if (ric == null)
        {
          SLog.log.WarnFormat("Cannot locate RIC for SymmetryCode:{0}", fi.SymmetryCode);
          continue;
        }
        m_ric_to_FIs.Add(ric, fi);

        listOfInstruments.Add(new InstrumentIdentifier()
          {
            IdentifierValue = ric,
            IdentifierType = "RIC"
          });

      }
      ValidatedInstrument[] ret = ServiceHelpers.ValidateInstruments(listOfInstruments.ToArray(), dsClient_, ref credentials_);

      return ret;
    }
예제 #9
0
 public abstract void MakeRequestsToDataScope(ExtractionServiceClient dsClient_, CredentialsHeader dsHeader_);
예제 #10
0
 public abstract void PrepareInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader dsHeader_);
    protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
    {
      var ints =
        getValidFuturesChains()
          .Select(
            x =>
              new InstrumentIdentifier {IdentifierValue = string.Format("0#{0}:}", x.RICStart), IdentifierType = "CHR"});

      if (!ints.Any())
        return null;

      // keep mapping for return from datascope
      m_ric_to_FIs = new Dictionary<string, FI>();

      var listOfInstruments = new List<InstrumentIdentifier>();

      var tp = ServiceHelpers.ValidateInstruments(ints.ToArray(), dsClient_, ref credentials_);

      return tp;
    }
    private void validateUsingMethod(
      Func<FI,string,SymmetryEntities,InstrumentIdentifier> identifierformer_, 
      int configIndex_,
      ICollection<FI> fromThese_, 
      ICollection<ValidatedInstrument> validated_, 
      ExtractionServiceClient dsClient_, 
      CredentialsHeader credentials_, 
      SymmetryEntities dc_
      )
    {
      var identifiers = new List<InstrumentIdentifier>();

      var dict = new Dictionary<string, FI>();

      foreach (var f in fromThese_)
      {
        var config = RICHelper.GetMappingForBond(f.SymmetryCode);

        string exch = null;

        switch (configIndex_)
        {
          case 0:
            {
              exch = config == null || config.ExchangeList == null || !config.ExchangeList.Any()
                ? PRIMARY_BOND_SOURCE
                : config.ExchangeList[0];
            }
            break;
          case 1:
          {
            exch = config == null || config.ExchangeList == null || config.ExchangeList.Count() < 2
              ? SECONDARY_BOND_SOURCE
              : config.ExchangeList[1];
          }
            break;
        }

        var identifer = identifierformer_(f, exch, dc_);

        if (identifer == null) continue;

        dict[identifer.IdentifierValue] = f;

        identifiers.Add(identifer);
      }

      if (!identifiers.Any()) return;

      var validated_unvalidated = ServiceHelpers.ValidateInstruments_FindUnValidated(identifiers.ToArray(), dsClient_, ref credentials_);

      foreach(var valid in validated_unvalidated.Item1)
      {
        validated_.Add(valid);
        fromThese_.Remove(dict[valid.IdentifierValue]);
      }

    }
    protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
    {
      var allBondsToValidate = getAllBondsToPrice(dc_);
      var validated = new List<ValidatedInstrument>();

      // first try cusip=TWEB
      validateUsingMethod(
        configIndex_: 0,
        fromThese_: allBondsToValidate,
        validated_: validated,
        dsClient_: dsClient_,
        credentials_: credentials_,
        dc_: dc_,
        identifierformer_: (bond, exch, dc) =>
        {
          if (String.Compare(exch, "TWB", StringComparison.OrdinalIgnoreCase) != 0)
            return null;

          bool canUseCusipEqTWEB = false;
          /*
           * We know that actually tweb starts using cusip=tweb  after auction date, but we don't always have the auction data for the bond
           * 
           * If we can get the auction date, and it's before that date, then we can use cusip=tweb
           * 
           */

          if (bond.FIBond == null) return null;

          {
            DateTime? auctionDate = bond.FIBond.AuctionDate;

            if (bond.FIBond.FIBondAuctions != null && bond.FIBond.FIBondAuctions.Count>0)
              auctionDate = bond.FIBond.FIBondAuctions.ToArray().Select(x => x.AuctionDate).Min();

            if (auctionDate.HasValue && auctionDate.Value < DateTime.Today)
              canUseCusipEqTWEB = true;
          }

          // if we haven't already been able to validate using auction date, then, as a second best,
          // see if 'today' is past or equal to issuedate
          if (!canUseCusipEqTWEB && bond.FIBond.IssueDate.HasValue)
            canUseCusipEqTWEB = bond.FIBond.IssueDate.Value <= DateTime.Today;


          if (!canUseCusipEqTWEB)
            return null;

          var cusip = FIHelpers.GetFIIdentifier(bond.SymmetryCode, IdentifierType.CUSIP, dc, ThrowBehavior.DontThrow);

          if (string.IsNullOrEmpty(cusip))
            return null;

          return new InstrumentIdentifier
          {
            IdentifierType = "RIC",
            IdentifierValue = string.Format("{0}=TWEB", cusip)
          };
        });


      // then try ISIN with source=TWEB (or first config item)
      validateUsingMethod(
        configIndex_: 0,
        fromThese_: allBondsToValidate,
        validated_: validated,
        dsClient_: dsClient_,
        credentials_: credentials_,
        dc_: dc_,
        identifierformer_: (bond, exch, dc) => new InstrumentIdentifier
        {
          IdentifierType = "ISN",
          Source=exch,
          IdentifierValue = bond.SymmetryCode
        });

      // then try ISIN with source=TWEB (or first config item)
      validateUsingMethod(
        configIndex_: 1,
        fromThese_: allBondsToValidate,
        validated_: validated,
        dsClient_: dsClient_,
        credentials_: credentials_,
        dc_: dc_,
        identifierformer_: (bond, exch, dc) => new InstrumentIdentifier
        {
          IdentifierType = "ISN",
          Source = exch,
          IdentifierValue = bond.SymmetryCode
        });


      // log anything we couldn't get a validated intstrument for
      foreach (var remainingBond in allBondsToValidate)
      {
        SLog.log.DebugFormat("Could not discover validated instrument for [{0}]", remainingBond.SymmetryCode);
      }

      SLog.log.InfoFormat("Validated {0} bonds.", validated.Count);

      return validated.ToArray();
    }