Exemple #1
0
 public Violation(ClientMarketData.ViolationRow violationRow)
 {
     // Initialize the record.
     this.violationId = violationRow.ViolationId;
     this.restriction = Restriction.Make(violationRow.RestrictionRow);
     this.position    = Position.Make(violationRow.AccountId, violationRow.SecurityId, (int)violationRow.PositionTypeCode);
     this.description = description;
 }
Exemple #2
0
        public void Remove()
        {
            long rowVersion = long.MinValue;

            try
            {
                // Lock the tables.
                Debug.Assert(!ClientMarketData.AreLocksHeld);
                ClientMarketData.ViolationLock.AcquireReaderLock(CommonTimeout.LockWait);

                // Prevent duplicates.
                ClientMarketData.ViolationRow violationRow = ClientMarketData.Violation.FindByViolationId(this.violationId);
                if (violationRow == null)
                {
                    return;
                }

                rowVersion = violationRow.RowVersion;
            }
            finally
            {
                // Release the table locks.
                if (ClientMarketData.ViolationLock.IsReaderLockHeld)
                {
                    ClientMarketData.ViolationLock.ReleaseReaderLock();
                }
                Debug.Assert(!ClientMarketData.AreLocksHeld);
            }

            RemoteAssembly remoteAssembly = CommandBatch.Assemblies.Add("Service.Core");
            RemoteType     remoteType     = remoteAssembly.Types.Add("Shadows.WebService.Core.Violation");
            RemoteMethod   remoteMethod   = remoteType.Methods.Add("Delete");

            remoteMethod.Parameters.Add("violationId", this.violationId);
            remoteMethod.Parameters.Add("rowVersion", rowVersion);
        }
Exemple #3
0
        /// <summary>
        /// Creates an element in the Appraisal Document that represents a fund's or account's position.
        /// </summary>
        /// <param name="appraisalDocument">The parent document.</param>
        /// <param name="driverAccount">Identifies the individual position at the account/security/position level.</param>
        public AccountElement(AppraisalDocument appraisalDocument, AppraisalSet.AccountRow driverAccount) :
            base("Account", appraisalDocument)
        {
            // Get the account record from the account id.  This record drives most of the data that appears in this element.
            ClientMarketData.AccountRow accountRow =
                ClientMarketData.Account.FindByAccountId(driverAccount.AccountId);

            // Count up the compliance violations
            int violationCount = 0;

            foreach (DataRowView dataRowView in
                     ClientMarketData.Violation.UKViolationAccountIdSecurityIdPositionTypeCode.FindRows(
                         new object[] { driverAccount.AccountId, driverAccount.SecurityId, driverAccount.PositionTypeCode }))
            {
                ClientMarketData.ViolationRow violationRow = (ClientMarketData.ViolationRow)dataRowView.Row;
                if (violationRow.RestrictionRow.Severity > 0)
                {
                    violationCount++;
                }
            }
            AddAttribute("Violation", violationCount);

            // Add the essential attributes to the element.
            AddAttribute("AccountId", accountRow.AccountId.ToString());

            // Aggregate the tax lot positions and cost.
            decimal taxLotQuantity = 0.0M;
            decimal taxLotCost     = 0.0M;

            foreach (ClientMarketData.TaxLotRow taxLotRow in accountRow.GetTaxLotRows())
            {
                if (taxLotRow.SecurityId == driverAccount.SecurityId &&
                    taxLotRow.PositionTypeCode == driverAccount.PositionTypeCode)
                {
                    taxLotQuantity += taxLotRow.Quantity;
                    taxLotCost     += taxLotRow.Cost * taxLotRow.Quantity;
                }
            }
            AddAttribute("TaxLotQuantity", taxLotQuantity.ToString());
            AddAttribute("TaxLotCost", taxLotCost.ToString());

            // Aggregate the proposed orders positions.
            decimal proposedOrderQuantity = 0.0M;

            foreach (DataRowView dataRowView in
                     appraisalDocument.proposedOrderView.FindRows(new object[] { driverAccount.AccountId, driverAccount.SecurityId,
                                                                                 driverAccount.PositionTypeCode }))
            {
                ClientMarketData.ProposedOrderRow proposedOrderRow = (ClientMarketData.ProposedOrderRow)dataRowView.Row;
                proposedOrderQuantity += proposedOrderRow.Quantity *
                                         proposedOrderRow.TransactionTypeRow.QuantitySign;
            }
            AddAttribute("ProposedOrderQuantity", proposedOrderQuantity.ToString());

            // Aggregate the orders.
            decimal orderQuantity = 0.0M;

            foreach (DataRowView dataRowView in
                     appraisalDocument.orderView.FindRows(new object[] { driverAccount.AccountId, driverAccount.SecurityId,
                                                                         driverAccount.PositionTypeCode }))
            {
                ClientMarketData.OrderRow orderRow = (ClientMarketData.OrderRow)dataRowView.Row;
                orderQuantity += orderRow.Quantity *
                                 orderRow.TransactionTypeRow.QuantitySign;
            }
            AddAttribute("OrderQuantity", orderQuantity.ToString());

            // Aggregate the allocations.
            decimal allocationQuantity = 0.0M;

            foreach (DataRowView dataRowView in
                     appraisalDocument.allocationView.FindRows(new object[] { driverAccount.AccountId, driverAccount.SecurityId,
                                                                              driverAccount.PositionTypeCode }))
            {
                ClientMarketData.AllocationRow allocationRow = (ClientMarketData.AllocationRow)dataRowView.Row;
                allocationQuantity += allocationRow.Quantity *
                                      allocationRow.TransactionTypeRow.QuantitySign;
            }
            AddAttribute("AllocationQuantity", allocationQuantity.ToString());
        }