Esempio n. 1
0
        /// <summary>
        /// Installs an event driven industry concentration compliance check.
        /// </summary>
        static TelecomConcentration()
        {
            // This is a list of all the accounts targeted by this compliance check.
            TelecomConcentration.betaAccountList = new BetaAccountList();

            // This is the preset concentration limit.
            TelecomConcentration.sectorLimit = 0.1M;

            // Find the telecom sector based on the S&P GICS external codes.
            TelecomConcentration.telecomServices = new Sector("50");

            // Open up a restriction for the industry concentration rule.  The severity level of these errors is high and an
            // officer approval is needed to trade any positions.
            TelecomConcentration.restriction = Restriction.Find("TELECOMSECTOR");
            if (TelecomConcentration.restriction == null)
            {
                TelecomConcentration.restriction = new Restriction("TELECOMSECTOR", Severity.High, Approval.Officer,
                                                                   "{0} in account {1} exceeds {2:#0%} in {3}.");
            }

            // Cycle through each predefined account and synchronize the violations against the current state of the data model.
            // The method 'AccountHandler' will check the given account for an exceesive concentration in the Telecommunications
            // Sector.
            foreach (Account account in TelecomConcentration.betaAccountList)
            {
                ValidateAccount(account);
            }

            // Flush the command buffer.
            CommandBatch.Flush();

            // This list collects the positions that have been changed by the incoming events.
            TelecomConcentration.updateAccountList = new AccountList();

            // This compliance check is event driven.  When an event -- such as adding or deleting an order -- changes the state of
            // the data model, these tests will be called to insure that the new state doesn't violate this compliance rule.  In
            // the case of a simple list rule, the new position will be tested to see if adding or deleting a position results in a
            // violation.  These statements install the event handlers for tax lots, proposed orders, orders and allocations.  For
            // example, the method 'TaxLotHandler' will be called when the tax lot table changes.
            MarketData.BeginMerge += new EventHandler(BeginMerge);
            TaxLot.Changed        += new TaxLotEvent(TaxLotHandler);
            ProposedOrder.Changed += new ProposedOrderEvent(ProposedOrderHandler);
            Order.Changed         += new OrderEvent(OrderHandler);
            Allocation.Changed    += new AllocationEvent(AllocationHandler);
            MarketData.EndMerge   += new EventHandler(EndMerge);
        }
Esempio n. 2
0
        public PositionTable(AccountList accountList, SecurityList securityList)
        {
            Initialize();

            foreach (Account account in accountList)
            {
                foreach (Security security in securityList)
                {
                    foreach (int positionTypeCode in Position.GetPositionTypes())
                    {
                        DataRow dataRow = this.NewRow();
                        dataRow[this.accountIdColumn]        = account.AccountId;
                        dataRow[this.securityIdColumn]       = security.SecurityId;
                        dataRow[this.positionTypeCodeColumn] = positionTypeCode;
                        this.Rows.Add(dataRow);
                    }
                }
            }
        }