Beispiel #1
0
        /// <summary>
        /// Creates a proposed order record.
        /// </summary>
        /// <param name="allocationRow">A proposed order record from the primary ADO database.</param>
        /// <returns>A Allocation record based on the ADO record.</returns>
        internal static Allocation Make(ClientMarketData.AllocationRow allocationRow)
        {
            // Initialize the object
            DataRowVersion dataRowVersion = allocationRow.RowState == DataRowState.Deleted ? DataRowVersion.Original : DataRowVersion.Current;

            // Extract the data from the ADO record.
            int             allocationId     = (int)allocationRow[ClientMarketData.Allocation.AllocationIdColumn, dataRowVersion];
            TransactionType transactionType  = (TransactionType)allocationRow[ClientMarketData.Allocation.TransactionTypeCodeColumn, dataRowVersion];
            int             accountId        = (int)allocationRow[ClientMarketData.Allocation.AccountIdColumn, dataRowVersion];
            int             securityId       = (int)allocationRow[ClientMarketData.Allocation.SecurityIdColumn, dataRowVersion];
            int             positionTypeCode = Common.TransactionType.GetPosition((int)transactionType);
            Position        position         = Position.Make(accountId, securityId, positionTypeCode);
            decimal         quantity         = (decimal)allocationRow[ClientMarketData.Allocation.QuantityColumn, dataRowVersion];
            decimal         price            = (decimal)allocationRow[ClientMarketData.Allocation.PriceColumn, dataRowVersion];
            decimal         commission       = (decimal)allocationRow[ClientMarketData.Allocation.CommissionColumn, dataRowVersion];
            decimal         accruedInterest  = (decimal)allocationRow[ClientMarketData.Allocation.AccruedInterestColumn, dataRowVersion];
            decimal         userFee0         = (decimal)allocationRow[ClientMarketData.Allocation.UserFee0Column, dataRowVersion];
            decimal         userFee1         = (decimal)allocationRow[ClientMarketData.Allocation.UserFee1Column, dataRowVersion];
            decimal         userFee2         = (decimal)allocationRow[ClientMarketData.Allocation.UserFee2Column, dataRowVersion];
            decimal         userFee3         = (decimal)allocationRow[ClientMarketData.Allocation.UserFee3Column, dataRowVersion];

            // Create a new record based on the data extracted from the ADO database.
            return(new Allocation(allocationId, position, quantity, price, commission, accruedInterest, userFee0, userFee1,
                                  userFee2, userFee3));
        }
Beispiel #2
0
        /// <summary>
        /// Handles the primary Market Data events and passes the events along to the Langauge Primitives.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="allocationRowChangeEvent">The record change event argument.</param>
        public static void AllocationHandler(object sender, ClientMarketData.AllocationRowChangeEvent allocationRowChangeEvent)
        {
            // Extract the record from the event argument.
            ClientMarketData.AllocationRow allocationRow = allocationRowChangeEvent.Row;

            // Translate the ADO.NET row states into a record state used by the Rules Engine.
            Action action = Action.Nothing;

            switch (allocationRowChangeEvent.Action)
            {
            case DataRowAction.Add: action = Action.Add; break;

            case DataRowAction.Delete: action = Action.Delete; break;

            case DataRowAction.Change: action = Action.Change; break;

            case DataRowAction.Commit: return;
            }

            // Place the event into a list that will be processed when the tables are no longer locked.
            Allocation.allocationEventArgList.Add(new AllocationEventArgs(action, Allocation.Make(allocationRow)));
        }
Beispiel #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());
        }