Exemplo n.º 1
0
        /// <summary>
        /// Handles a change to the WorkingOrder row.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="workingOrderRowChangeEventArgs">The event arguments.</param>
        protected override void OnWorkingOrderRowChanged(Object sender, DataModel.WorkingOrderRowChangeEventArgs workingOrderRowChangeEventArgs)
        {
            // Validate the parameters.
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (workingOrderRowChangeEventArgs == null)
            {
                throw new ArgumentNullException("workingOrderRowChangeEventArgs");
            }

            // If the new working order belongs to this blotter or one of its descendants, then add it in the proper place.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Add)
            {
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.BlotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    this.Insert(~index, this.CreateInstanceCore(workingOrderRowChangeEventArgs.Row));
                }
            }

            // This will copy the modified elements from the data model into the collection and commit the changes.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Change)
            {
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.BlotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    TType equityWorkingOrder = this[index];
                    this.View.EditItem(equityWorkingOrder);
                    equityWorkingOrder.IsActive           = workingOrderRow.StatusRow.StatusCode != StatusCode.Filled;
                    equityWorkingOrder.BlotterName        = workingOrderRow.BlotterRow.EntityRow.Name;
                    equityWorkingOrder.CreatedBy          = workingOrderRow.UserRowByFK_User_WorkingOrder_CreatedUserId.EntityRow.Name;
                    equityWorkingOrder.CreatedTime        = workingOrderRow.CreatedTime;
                    equityWorkingOrder.IsCrossing         = workingOrderRow.CrossingRow.CrossingCode == CrossingCode.AlwaysMatch;
                    equityWorkingOrder.IsBrokerMatch      = workingOrderRow.IsBrokerMatch;
                    equityWorkingOrder.IsHedgeMatch       = workingOrderRow.IsHedgeMatch;
                    equityWorkingOrder.IsInstitutionMatch = workingOrderRow.IsInstitutionMatch;
                    equityWorkingOrder.LimitPrice         = workingOrderRow.IsLimitPriceNull() ? 0.0M : workingOrderRow.LimitPrice;
                    equityWorkingOrder.ModifiedBy         = workingOrderRow.UserRowByFK_User_WorkingOrder_ModifiedUserId.EntityRow.Name;
                    equityWorkingOrder.ModifiedTime       = workingOrderRow.ModifiedTime;
                    equityWorkingOrder.RowVersion         = workingOrderRow.RowVersion;
                    equityWorkingOrder.OrderTypeMnemonic  = workingOrderRow.OrderTypeRow.Mnemonic;
                    equityWorkingOrder.OrderTypeCode      = workingOrderRow.OrderTypeRow.OrderTypeCode;
                    equityWorkingOrder.SecurityName       = workingOrderRow.SecurityRowByFK_Security_WorkingOrder_SecurityId.EntityRow.Name;
                    equityWorkingOrder.SettlementDate     = workingOrderRow.SettlementDate;
                    equityWorkingOrder.SideCode           = workingOrderRow.SideRow.SideCode;
                    equityWorkingOrder.SideMnemonic       = workingOrderRow.SideRow.Mnemonic;
                    equityWorkingOrder.StatusCode         = workingOrderRow.StatusRow.StatusCode;
                    equityWorkingOrder.StopPrice          = workingOrderRow.IsStopPriceNull() ? 0.0M : workingOrderRow.StopPrice;
                    equityWorkingOrder.Symbol             = workingOrderRow.SecurityRowByFK_Security_WorkingOrder_SecurityId.Symbol;
                    equityWorkingOrder.TimeInForceCode    = workingOrderRow.TimeInForceRow.TimeInForceCode;
                    equityWorkingOrder.TradeDate          = workingOrderRow.TradeDate;
                    equityWorkingOrder.WorkingOrderId     = workingOrderRow.WorkingOrderId;
                    this.View.CommitEdit();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles a change to the WorkingOrder row.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="workingOrderRowChangeEventArgs">The event arguments.</param>
        protected virtual void OnWorkingOrderRowChanged(Object sender, DataModel.WorkingOrderRowChangeEventArgs workingOrderRowChangeEventArgs)
        {
            // Validate the parameters.
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (workingOrderRowChangeEventArgs == null)
            {
                throw new ArgumentNullException("workingOrderRowChangeEventArgs");
            }

            // If the new working order belongs to this blotter or one of its descendants, then add it in the proper place.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Add)
            {
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    this.Insert(~index, this.CreateInstanceCore(workingOrderRowChangeEventArgs.Row));
                }
            }

            // This will copy the modified elements from the data model into the collection and commit the changes.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Change)
            {
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32        index        = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    WorkingOrder workingOrder = this[index];
                    this.workingOrderCollectionView.EditItem(workingOrder);
                    workingOrder.IsActive       = workingOrderRow.StatusRow.StatusCode != StatusCode.Filled;
                    workingOrder.BlotterName    = workingOrderRow.BlotterRow.EntityRow.Name;
                    workingOrder.CreatedBy      = workingOrderRow.UserRowByFK_User_WorkingOrder_CreatedUserId.EntityRow.Name;
                    workingOrder.CreatedTime    = workingOrderRow.CreatedTime;
                    workingOrder.ModifiedBy     = workingOrderRow.UserRowByFK_User_WorkingOrder_ModifiedUserId.EntityRow.Name;
                    workingOrder.ModifiedTime   = workingOrderRow.ModifiedTime;
                    workingOrder.RowVersion     = workingOrderRow.RowVersion;
                    workingOrder.SecurityName   = workingOrderRow.SecurityRowByFK_Security_WorkingOrder_SecurityId.EntityRow.Name;
                    workingOrder.SettlementDate = workingOrderRow.SettlementDate;
                    workingOrder.SideCode       = workingOrderRow.SideRow.SideCode;
                    workingOrder.SideMnemonic   = workingOrderRow.SideRow.Mnemonic;
                    workingOrder.StatusCode     = workingOrderRow.StatusRow.StatusCode;
                    workingOrder.Symbol         = workingOrderRow.SecurityRowByFK_Security_WorkingOrder_SecurityId.Symbol;
                    workingOrder.TradeDate      = workingOrderRow.TradeDate;
                    workingOrder.WorkingOrderId = workingOrderRow.WorkingOrderId;
                    this.workingOrderCollectionView.CommitEdit();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles a change to the WorkingOrder row.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="workingOrderRowChangeEventArgs">The event arguments.</param>
        void OnWorkingOrderRowChanged(Object sender, DataModel.WorkingOrderRowChangeEventArgs workingOrderRowChangeEventArgs)
        {
            // If the new working order belongs to this blotter or one of its descendants, then add it in the proper place.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Add)
            {
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    this.WorkingOrderCount++;
                }
            }

            // This will handle changes to the working order.
            if (workingOrderRowChangeEventArgs.Action == DataRowAction.Change)
            {
                // This is designed to filter out all events that don't pertain to this blotter.
                DataModel.WorkingOrderRow workingOrderRow = workingOrderRowChangeEventArgs.Row;
                if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    // In order to minimize the number of times we update a propertie that is bound to a visual control, we'll get copies of the current statistics
                    // and perform the updates on them.
                    Int32 filledOrderCount  = this.FilledOrderCount;
                    Int32 partialOrderCount = this.PartialOrderCount;
                    Int32 newOrderCount     = this.NewOrderCount;

                    // This will remove the previous status code (if there was a previous value) from the statistics.
                    if (workingOrderRow.HasVersion(DataRowVersion.Original))
                    {
                        StatusCode oldStatusCode = (StatusCode)workingOrderRow[DataModel.WorkingOrder.StatusCodeColumn, DataRowVersion.Original];
                        if (oldStatusCode == StatusCode.Filled)
                        {
                            filledOrderCount--;
                        }
                        if (oldStatusCode == StatusCode.PartiallyFilled)
                        {
                            partialOrderCount--;
                        }
                        if (oldStatusCode == StatusCode.New)
                        {
                            newOrderCount--;
                        }
                    }

                    // This will update the statistics with the current status of the working order.
                    StatusCode newStatusCode = workingOrderRow.StatusCode;
                    if (newStatusCode == StatusCode.Filled)
                    {
                        filledOrderCount++;
                    }
                    if (newStatusCode == StatusCode.PartiallyFilled)
                    {
                        partialOrderCount++;
                    }
                    if (newStatusCode == StatusCode.New)
                    {
                        newOrderCount++;
                    }

                    // We've updated all the statistics and can put them back into the properties tied to the metadata controls.
                    this.FilledOrderCount  = filledOrderCount;
                    this.PartialOrderCount = partialOrderCount;
                    this.NewOrderCount     = newOrderCount;
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handler for validating Source Order records.
 /// </summary>
 /// <param name="sender">The Object that originated the event.</param>
 /// <param name="e">The event arguments.</param>
 internal static void OnWorkingOrderRowValidate(Object sender, DataModel.WorkingOrderRowChangeEventArgs e)
 {
     // Use the map to call the proper handler for the action.
     WorkingOrderService.workingOrderHandlerMap[e.Action](e.Row);
 }