コード例 #1
0
ファイル: BindEngine.cs プロジェクト: INGMMV01/EccGenerator
        internal BindEngine(string name, FieldArray fields, IDictionary extendedProperties) : base(extendedProperties)
        {
            this.fields = fields;

            _name = name;

            ParsePattern();
        }
コード例 #2
0
        private FieldArray RecuperaCampos()
        {
            FieldArray ret = new FieldArray();

            foreach (ListViewItem lvi in lvCampos.Items)
            {
                ret.Add((Field)lvi.Tag);
            }

            return(ret);
        }
コード例 #3
0
 protected static Field FindFieldByTableName(FieldArray fields, string name)
 {
     foreach (Field field in fields)
     {
         if (field.Name == name)
         {
             return(field);
         }
     }
     return(null);
 }
コード例 #4
0
        private void Parse(FieldArray fields)
        {
            foreach (Field field in fields)
            {
                BindDeclaration decl = new BindDeclaration(field, this.ExtendedInfo);
                declarations.Add(decl);

                BindInstance inst = new BindInstance(field, this.ExtendedInfo);
                instances.Add(inst);

                BindProperty prop = new BindProperty(field, this.ExtendedInfo);
                properties.Add(prop);
            }
        }
コード例 #5
0
        internal BindClass(FieldArray fields, string name, IDictionary extendedProperties) : base(extendedProperties)
        {
            this.fields = fields;

            declarations = new BindArray();
            instances    = new BindArray();
            properties   = new BindArray();

            _name = name;

            Parse(fields);

            ParsePattern();
        }
コード例 #6
0
        private static uint ReadFieldArray(ref ReadOnlySequence <byte> data, out FieldArray <object> values)
        {
            int length = Read <int>(ref data, BinaryPrimitives.ReadInt32BigEndian);

            var  readValues = new List <FieldValue <object> >(32);
            uint readSoFar  = 0;

            while (length > readSoFar)
            {
                readSoFar += ReadFieldValuePair(ref data, out var value);
                readValues.Add(new FieldValue <object>(value));
            }

            values = new FieldArray <object>(readValues.ToArray());
            return(sizeof(int) + (uint)length);
        }
コード例 #7
0
        private void CargaCampos(string tabla)
        {
            lvCampos.Items.Clear();

            FieldArray fields = SqlExtractor.GetTableFields(tabla);

            foreach (Field field in fields)
            {
                string[] items = new string[] { "", field.Name, field.Type.Name };

                ListViewItem lvi = new ListViewItem(items);
                lvi.Tag = field;

                lvCampos.Items.Add(lvi);
            }
        }
コード例 #8
0
ファイル: SqlExtractor.cs プロジェクト: INGMMV01/EccGenerator
        public static FieldArray GetTableFields(string tablename)
        {
            using (OleDbConnection cnn = new OleDbConnection("Provider=SQLOLEDB;" + connectionString))
            {
                string[] strcnn  = connectionString.Split(';');
                string   catalog = null;

                foreach (string str in strcnn)
                {
                    string[] subs = str.Split('=');
                    if (subs[0].ToLower() == "initial catalog")
                    {
                        catalog = subs[1];
                        break;
                    }
                }

                FieldArray ret = new FieldArray();

                cnn.Open();
                DataTable tbl = cnn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { catalog, "dbo", tablename });

                foreach (DataRow row in tbl.Rows)
                {
                    Field fld = new Field();

                    SetOledbType(fld, row.ItemArray);

                    if (fld.Type != null)
                    {
                        fld.Name     = (string)row.ItemArray[SCHEMA_COLUMN_NAME];
                        fld.Nullable = (bool)row.ItemArray[SCHEMA_IS_NULLABLE];

                        ret.Add(fld);
                    }
                }
                cnn.Close();

                return(ret);
            }
        }
コード例 #9
0
ファイル: SqlExtractor.cs プロジェクト: INGMMV01/EccGenerator
        public static FieldArray GetTableFields_old(string tablename)
        {
            using (SqlConnection cnn = new SqlConnection(connectionString))
            {
                SqlCommand comm = new SqlCommand();
                DataTable  dtt;

                comm.CommandText = "SELECT TOP 0 * FROM " + tablename + " FOR XML AUTO, XMLDATA";
                comm.Connection  = cnn;
                comm.CommandType = CommandType.Text;

                cnn.Open();

                XmlReader xr = comm.ExecuteXmlReader();

                DataSet ds = new DataSet();
                ds.ReadXml(xr);
                dtt = ds.Tables[0];

                FieldArray ret = new FieldArray();

                foreach (DataColumn dtc in dtt.Columns)
                {
                    TypeEntry te = Pattern.GetBaseType(dtc.DataType.Name);

                    if (te != null)
                    {
                        Field fld = new Field();
                        fld.Name = dtc.ColumnName;
                        fld.Type = te;

                        ret.Add(fld);
                    }
                }

                cnn.Close();

                return(ret);
            }
        }
コード例 #10
0
        public SourceOrderElement(SourceOrderDocument sourceOrderDocument, ClientMarketData.SourceOrderRow sourceOrderRow, FieldArray fields) :
            base("SourceOrder", sourceOrderDocument)
        {
            // SourceOrderId - Primary Key for this report.
            AddAttribute("SourceOrderId", sourceOrderRow.SourceOrderId);

            // Status - Note that the status code is always provided to the DOM for color coding of the fields.
            AddAttribute("StatusCode", sourceOrderRow.StatusCode);
            if (fields[Field.Status])
            {
                AddAttribute("StatusName", sourceOrderRow.StatusRow.Mnemonic);
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", sourceOrderRow.WorkingOrderRow.BlotterId);
                AddAttribute("BlotterName", sourceOrderRow.WorkingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // OrderType
            if (fields[Field.OrderType])
            {
                AddAttribute("OrderTypeCode", sourceOrderRow.WorkingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeMnemonic", sourceOrderRow.WorkingOrderRow.OrderTypeRow.Mnemonic);
                AddAttribute("CashSign", sourceOrderRow.WorkingOrderRow.OrderTypeRow.CashSign);
                AddAttribute("QuantitySign", sourceOrderRow.WorkingOrderRow.OrderTypeRow.QuantitySign);
            }

            // TimeInForce
            if (fields[Field.TimeInForce])
            {
                AddAttribute("TimeInForceCode", sourceOrderRow.WorkingOrderRow.TimeInForceRow.TimeInForceCode);
                AddAttribute("TimeInForceName", sourceOrderRow.WorkingOrderRow.TimeInForceRow.Mnemonic);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", sourceOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", sourceOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", sourceOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
            }

            //  Source Order Total Quantity
            if (fields[Field.OrderedQuantity])
            {
                AddAttribute("SourceOrderQuantity", sourceOrderRow.OrderedQuantity);
            }

            // Source
            if (fields[Field.Destination])
            {
                if (!sourceOrderRow.WorkingOrderRow.IsDestinationIdNull())
                {
                    AddAttribute("DestinationId", sourceOrderRow.WorkingOrderRow.DestinationRow.DestinationId);
                    AddAttribute("DestinationName", sourceOrderRow.WorkingOrderRow.DestinationRow.Name);
                    AddAttribute("DestinationShortName", sourceOrderRow.WorkingOrderRow.DestinationRow.ShortName);
                }
            }

            // The Direction of this order (buy, sell, buy cover, etc.)
            if (fields[Field.PriceType])
            {
                AddAttribute("PriceTypeCode", sourceOrderRow.WorkingOrderRow.PriceTypeRow.PriceTypeCode);
                AddAttribute("PriceTypeMnemonic", sourceOrderRow.WorkingOrderRow.PriceTypeRow.Mnemonic);
            }

            // The remaining Source Order Fields
            if (fields[Field.SourceOrder])
            {
                // Created
                AddAttribute("CreatedName", sourceOrderRow.WorkingOrderRow.UserRowByUserWorkingOrderCreatedUserId.ObjectRow.Name);
                AddAttribute("CreatedTime", sourceOrderRow.WorkingOrderRow.CreatedTime.ToString("s"));

                // Limit Price
                if (!sourceOrderRow.WorkingOrderRow.IsLimitPriceNull())
                {
                    AddAttribute("LimitPrice", (decimal)sourceOrderRow.WorkingOrderRow.LimitPrice);
                }

                // Stop Price
                if (!sourceOrderRow.WorkingOrderRow.IsStopPriceNull())
                {
                    AddAttribute("StopPrice", (decimal)sourceOrderRow.WorkingOrderRow.StopPrice);
                }
            }
        }
コード例 #11
0
        public void GetEnumeratorTest()
        {
            FieldArray <UInt32> array = new FieldArray <UInt32>(null);

            (array as IEnumerable).GetEnumerator();
        }
コード例 #12
0
ファイル: BindEngine.cs プロジェクト: INGMMV01/EccGenerator
 internal BindEngine(string name, FieldArray fields) : this(name, fields, null)
 {
 }
コード例 #13
0
        public ExecutionElement(ExecutionDocument executionDocument, ClientMarketData.ExecutionRow executionRow, FieldArray fields) :
            base("Execution", executionDocument)
        {
            // ExecutionId - Primary Key for this report.
            AddAttribute("ExecutionId", executionRow.ExecutionId);

            // State - Note that the status code is always provided to the DOM for color coding of the fields.
            AddAttribute("SourceStateCode", executionRow.SourceStateCode);
            AddAttribute("DestinationStateCode", executionRow.DestinationStateCode);
            if (fields[Field.SourceState])
            {
                AddAttribute("SourceStateMnemonic", executionRow.StateRowByStateExecutionSourceStateCode.Mnemonic);
            }
            if (fields[Field.DestinationState])
            {
                AddAttribute("DestinationStateMnemonic", executionRow.StateRowByStateExecutionDestinationStateCode.Mnemonic);
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", executionRow.DestinationOrderRow.WorkingOrderRow.BlotterId);
                AddAttribute("BlotterName", executionRow.DestinationOrderRow.WorkingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // OrderType
            if (fields[Field.OrderType])
            {
                AddAttribute("OrderTypeCode", executionRow.DestinationOrderRow.WorkingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeMnemonic", executionRow.DestinationOrderRow.WorkingOrderRow.OrderTypeRow.Mnemonic);
                AddAttribute("CashSign", executionRow.DestinationOrderRow.WorkingOrderRow.OrderTypeRow.CashSign);
                AddAttribute("QuantitySign", executionRow.DestinationOrderRow.WorkingOrderRow.OrderTypeRow.QuantitySign);
            }

            // TimeInForce
            if (fields[Field.TimeInForce])
            {
                AddAttribute("TimeInForceCode", executionRow.DestinationOrderRow.WorkingOrderRow.TimeInForceRow.TimeInForceCode);
                AddAttribute("TimeInForceName", executionRow.DestinationOrderRow.WorkingOrderRow.TimeInForceRow.Mnemonic);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", executionRow.DestinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", executionRow.DestinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", executionRow.DestinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
            }

            //  Source Order Total Quantity
            if (fields[Field.ExecutionQuantity])
            {
                AddAttribute("ExecutionQuantity", executionRow.ExecutionQuantity);
            }

            // Execution Price
            if (fields[Field.ExecutionPrice])
            {
                AddAttribute("ExecutionPrice", executionRow.ExecutionPrice);
            }

            // Market Value
            if (fields[Field.ExecutionPrice] || fields[Field.ExecutionQuantity])
            {
                AddAttribute("GrossValue", executionRow.ExecutionQuantity * executionRow.ExecutionPrice);
            }

            // Commission
            if (fields[Field.Commission])
            {
                AddAttribute("Commission", executionRow.Commission);
            }

            // Execution Net
            if (fields[Field.ExecutionPrice] || fields[Field.ExecutionQuantity] || fields[Field.Commission])
            {
                AddAttribute("NetValue", (executionRow.ExecutionQuantity * executionRow.DestinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.QuantityFactor) *
                             (executionRow.ExecutionPrice * executionRow.DestinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.PriceFactor) +
                             (executionRow.Commission * executionRow.DestinationOrderRow.WorkingOrderRow.OrderTypeRow.QuantitySign));
            }

            // Destination
            if (fields[Field.Destination])
            {
                if (!executionRow.DestinationOrderRow.WorkingOrderRow.IsDestinationIdNull())
                {
                    AddAttribute("DestinationId", executionRow.DestinationOrderRow.WorkingOrderRow.DestinationRow.DestinationId);
                    AddAttribute("DestinationName", executionRow.DestinationOrderRow.WorkingOrderRow.DestinationRow.Name);
                    AddAttribute("DestinationShortName", executionRow.DestinationOrderRow.WorkingOrderRow.DestinationRow.ShortName);
                }
            }

            // The Direction of this order (buy, sell, buy cover, etc.)
            if (fields[Field.PriceType])
            {
                AddAttribute("PriceTypeCode", executionRow.DestinationOrderRow.WorkingOrderRow.PriceTypeRow.PriceTypeCode);
                AddAttribute("PriceTypeMnemonic", executionRow.DestinationOrderRow.WorkingOrderRow.PriceTypeRow.Mnemonic);
            }

            // The clearing broker.
            if (fields[Field.Broker])
            {
                if (!executionRow.IsBrokerIdNull())
                {
                    AddAttribute("BrokerId", executionRow.BrokerRow.BrokerId);
                    AddAttribute("BrokerName", executionRow.BrokerRow.SourceRow.BlotterRow.ObjectRow.Name);
                    AddAttribute("BrokerSymbol", executionRow.BrokerRow.Symbol);
                }
            }

            // The account for clearing this execution.
            if (fields[Field.BrokerAccount])
            {
                if (!executionRow.IsBrokerAccountIdNull())
                {
                    AddAttribute("BrokerAccountId", executionRow.BrokerAccountRow.BrokerAccountId);
                    AddAttribute("BrokerAccountMnemonic", executionRow.BrokerAccountRow.Mnemonic);
                    AddAttribute("BrokerAccountDescription", executionRow.BrokerAccountRow.Description);
                }
            }

            // The remaining Source Order Fields
            if (fields[Field.Execution])
            {
                // Created
                AddAttribute("CreatedName", executionRow.DestinationOrderRow.WorkingOrderRow.UserRowByUserWorkingOrderCreatedUserId.ObjectRow.Name);
                AddAttribute("CreatedTime", executionRow.DestinationOrderRow.WorkingOrderRow.CreatedTime.ToString("s"));

                // Limit Price
                if (!executionRow.DestinationOrderRow.WorkingOrderRow.IsLimitPriceNull())
                {
                    AddAttribute("LimitPrice", (decimal)executionRow.DestinationOrderRow.WorkingOrderRow.LimitPrice);
                }

                // Stop Price
                if (!executionRow.DestinationOrderRow.WorkingOrderRow.IsStopPriceNull())
                {
                    AddAttribute("StopPrice", (decimal)executionRow.DestinationOrderRow.WorkingOrderRow.StopPrice);
                }
            }
        }
コード例 #14
0
        public DestinationOrderElement(DestinationOrderDocument destinationOrderDocument, ClientMarketData.DestinationOrderRow destinationOrderRow, FieldArray fields) :
            base("DestinationOrder", destinationOrderDocument)
        {
            // Aggregate all the data related to this staged order.  This will work out the aggregates and distinct column
            // operations.
            if (fields[Field.OrderedQuantity] || fields[Field.ExecutedQuantity])
            {
                AggregateFields(destinationOrderRow);
            }

            // DestinationOrderId - Primary Key for this report.
            AddAttribute("DestinationOrderId", destinationOrderRow.DestinationOrderId);

            // Status - Note that the status code is always provided to the DOM for color coding of the fields.
            AddAttribute("StatusCode", destinationOrderRow.StatusCode);
            if (fields[Field.Status])
            {
                AddAttribute("StatusName", destinationOrderRow.StatusRow.Mnemonic);
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", destinationOrderRow.WorkingOrderRow.BlotterId);
                AddAttribute("BlotterName", destinationOrderRow.WorkingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // OrderType
            if (fields[Field.OrderType])
            {
                AddAttribute("OrderTypeCode", destinationOrderRow.WorkingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeMnemonic", destinationOrderRow.WorkingOrderRow.OrderTypeRow.Mnemonic);
                AddAttribute("CashSign", destinationOrderRow.WorkingOrderRow.OrderTypeRow.CashSign);
                AddAttribute("QuantitySign", destinationOrderRow.WorkingOrderRow.OrderTypeRow.QuantitySign);
            }

            // TimeInForce
            if (fields[Field.TimeInForce])
            {
                AddAttribute("TimeInForceCode", destinationOrderRow.WorkingOrderRow.TimeInForceRow.TimeInForceCode);
                AddAttribute("TimeInForceName", destinationOrderRow.WorkingOrderRow.TimeInForceRow.Mnemonic);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", destinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", destinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", destinationOrderRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
            }

            //  Destination Order Total Quantity
            if (fields[Field.OrderedQuantity])
            {
                AddAttribute("DestinationOrderQuantity", destinationOrderRow.OrderedQuantity);
            }

            // Total Executed Quantity and Average Price
            if (fields[Field.ExecutedQuantity])
            {
                AddAttribute("ExecutedQuantity", this.totalExecutedQuantity);
                AddAttribute("AveragePrice", this.averagePriceExecuted);
            }

            //  Destination Order Leaves (Total Source Quantity - Total Destination Quantity)
            if (fields[Field.OrderedQuantity] || fields[Field.ExecutedQuantity])
            {
                AddAttribute("LeavesQuantity", this.totalLeavesQuantity);
            }

            // Destination
            if (fields[Field.Destination])
            {
                if (!destinationOrderRow.WorkingOrderRow.IsDestinationIdNull())
                {
                    AddAttribute("DestinationId", destinationOrderRow.WorkingOrderRow.DestinationRow.DestinationId);
                    AddAttribute("DestinationName", destinationOrderRow.WorkingOrderRow.DestinationRow.Name);
                    AddAttribute("DestinationShortName", destinationOrderRow.WorkingOrderRow.DestinationRow.ShortName);
                }
            }

            // The Direction of this order (buy, sell, buy cover, etc.)
            if (fields[Field.PriceType])
            {
                AddAttribute("PriceTypeCode", destinationOrderRow.WorkingOrderRow.PriceTypeRow.PriceTypeCode);
                AddAttribute("PriceTypeMnemonic", destinationOrderRow.WorkingOrderRow.PriceTypeRow.Mnemonic);
            }

            // The remaining Destination Order Fields
            if (fields[Field.DestinationOrder])
            {
                // Created
                AddAttribute("CreatedName", destinationOrderRow.WorkingOrderRow.UserRowByUserWorkingOrderCreatedUserId.ObjectRow.Name);
                AddAttribute("CreatedTime", destinationOrderRow.WorkingOrderRow.CreatedTime.ToString("s"));

                // Commission
                AddAttribute("Commission", this.totalCommission);

                // FilledNet
                AddAttribute("NetMarketValue", this.totalMarketValue - destinationOrderRow.WorkingOrderRow.OrderTypeRow.CashSign * this.totalCommission);

                // Market
                //			AddAttribute("MarketId", destinationOrderRow.WorkingOrderRow.SecurityRowByFKSecurityDestinationOrderSecurityId.MarketRow.MarketId);
                //			AddAttribute("MarketName", destinationOrderRow.WorkingOrderRow.SecurityRowByFKSecurityDestinationOrderSecurityId.MarketRow.Name);
                //			AddAttribute("MarketShortName", destinationOrderRow.WorkingOrderRow.SecurityRowByFKSecurityDestinationOrderSecurityId.MarketRow.ShortName);

                // Limit Price
                if (!destinationOrderRow.WorkingOrderRow.IsLimitPriceNull())
                {
                    AddAttribute("LimitPrice", (decimal)destinationOrderRow.WorkingOrderRow.LimitPrice);
                }

                // Stop Price
                if (!destinationOrderRow.WorkingOrderRow.IsStopPriceNull())
                {
                    AddAttribute("StopPrice", (decimal)destinationOrderRow.WorkingOrderRow.StopPrice);
                }

                // TradeDate
                AddAttribute("TradeDate", destinationOrderRow.WorkingOrderRow.CreatedTime.ToString("s"));

                // CommissionType
                //				if (destinationOrderRow != null)
                //				{
                //				ClientMarketData.CommissionRateTypeRow commissionRateTypeRow =
                //					ClientMarketData.CommissionRateType.FindByCommissionRateTypeCode((int)this.commissionRateTypeCode);
                //				AddAttribute("CommissionRateTypeCode", commissionRateTypeRow.CommissionRateTypeCode);
                //				AddAttribute("CommissionRateTypeName", commissionRateTypeRow.Name);
                //					AddAttribute("CommissionRate", this.averageCommissionRate);
                //				}

                // Filled Gross
                AddAttribute("MarketValue", this.totalMarketValue);
            }

            // Find the pricing record.
            if (!destinationOrderRow.WorkingOrderRow.IsSettlementIdNull())
            {
                ClientMarketData.PriceRow priceRow = ClientMarketData.Price.FindBySecurityId(destinationOrderRow.WorkingOrderRow.SecurityId);
                if (priceRow != null)
                {
                    if (fields[Field.LastPrice])
                    {
                        AddAttribute("LastPrice", priceRow.LastPrice);
                    }
                    if (fields[Field.BidPrice])
                    {
                        AddAttribute("BidPrice", priceRow.BidPrice);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskPrice", priceRow.AskPrice);
                    }
                    if (fields[Field.LastSize])
                    {
                        AddAttribute("LastSize", priceRow.LastSize);
                    }
                    if (fields[Field.BidSize])
                    {
                        AddAttribute("BidSize", priceRow.BidSize);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskSize", priceRow.AskSize);
                    }
                }
            }
        }
コード例 #15
0
        public QuoteElement(QuoteDocument quoteDocument, ClientMarketData.PriceRow priceRow, FieldArray fields)
            : base("Quote", quoteDocument)
        {
            // try to add the data elements from the security row
            if (priceRow.SecurityRow != null)
            {
                // security name
                if (fields[Field.SecurityName])
                {
                    AddAttribute("SecurityName", priceRow.SecurityRow.ObjectRow.Name);
                }

                // symbol
                if (fields[Field.Symbol])
                {
                    AddAttribute("Symbol", priceRow.SecurityRow.Symbol);
                }
            }

            // try to add the data elements from the price row
            if (priceRow != null)
            {
                // SecurityId
                AddAttribute("SecurityId", priceRow.SecurityId);

                // last trade
                if (fields[Field.LastPrice])
                {
                    AddAttribute("LastPrice", priceRow.LastPrice);

                    decimal dayPriceDiff = priceRow.LastPrice - priceRow.OpenPrice;
                    AddAttribute("DayPriceDifference", priceRow.LastPrice - priceRow.OpenPrice);

                    AddAttribute("DayPricePercentageDifference", priceRow.OpenPrice == 0.0M ? 0.0M :
                                 (priceRow.LastPrice - priceRow.OpenPrice) / priceRow.OpenPrice);
                }

                if (fields[Field.PreviousClosePrice])
                {
                    AddAttribute("PreviousClosePrice", priceRow.ClosePrice);
                }

                if (fields[Field.OpenPrice])
                {
                    AddAttribute("OpenPrice", priceRow.OpenPrice);
                }

                if (fields[Field.LastSize])
                {
                    AddAttribute("LastSize", priceRow.LastSize);
                }

                // price
                if (fields[Field.BidPrice])
                {
                    AddAttribute("BidPrice", priceRow.BidPrice);
                }
                if (fields[Field.AskPrice])
                {
                    AddAttribute("AskPrice", priceRow.AskPrice);
                }

                // size
                if (fields[Field.AskSize])
                {
                    AddAttribute("AskSize", priceRow.AskSize);
                }
                if (fields[Field.BidSize])
                {
                    AddAttribute("BidSize", priceRow.BidSize);
                }

                // volume
                if (fields[Field.Volume])
                {
                    AddAttribute("Volume", priceRow.Volume);
                }
                if (fields[Field.AverageDailyVolume])
                {
                    AddAttribute("AverageDailyVolume", priceRow.SecurityRow.AverageDailyVolume);
                }

                if (fields[Field.DayLowPrice])
                {
                    AddAttribute("DayLowPrice", priceRow.LowPrice);
                }
                if (fields[Field.DayHighPrice])
                {
                    AddAttribute("DayHighPrice", priceRow.HighPrice);
                }

                /* LOGO ???
                 * MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Logo));
                 * Bitmap bitmap = new Bitmap(memoryStream);
                 * Bitmap halfBitmap = new Bitmap(bitmap, new Size(bitmap.Width / 2, bitmap.Height / 2));
                 * MemoryStream halfStream = new MemoryStream();
                 * halfBitmap.Save(halfStream, System.Drawing.Imaging.ImageFormat.Png);
                 * AddAttribute("SecurityImage", Convert.ToBase64String(halfStream.GetBuffer()));
                 * */
            }
        }
コード例 #16
0
        public static string BindEngine(string entidad, FieldArray fields, IDictionary extendedProperties)
        {
            BindEngine bindengine = new BindEngine(entidad, fields, extendedProperties);

            return(bindengine.ToString());
        }
コード例 #17
0
        public MatchElement(MatchHistoryDocument matchDocument, ClientMarketData.MatchRow matchRow, FieldArray fields) :
            base("Match", matchDocument)
        {
            // WorkingOrderId
            AddAttribute("MatchId", matchRow.MatchId);
            AddAttribute("WorkingOrderId", matchRow.WorkingOrderId);
            AddAttribute("ContraOrderId", matchRow.ContraOrderId);

            // Status
            if (fields[Field.Status])
            {
                AddAttribute("StatusCode", matchRow.StatusCode);
                AddAttribute("StatusName", matchRow.StatusRow.Mnemonic);
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", matchRow.WorkingOrderRow.BlotterRow.BlotterId);
                AddAttribute("BlotterName", matchRow.WorkingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
                if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsAverageDailyVolumeNull())
                {
                    AddAttribute("AverageDailyVolume", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume / 1000);
                }
                if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsMarketCapitalizationNull())
                {
                    AddAttribute("MarketCapitalization", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.MarketCapitalization / 1000000);
                }

                MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Logo));
                Bitmap       bitmap       = new Bitmap(memoryStream);
                Bitmap       halfBitmap   = new Bitmap(bitmap, new Size(bitmap.Width / 2, bitmap.Height / 2));
                MemoryStream halfStream   = new MemoryStream();
                halfBitmap.Save(halfStream, System.Drawing.Imaging.ImageFormat.Png);
                AddAttribute("SecurityImage", Convert.ToBase64String(halfStream.GetBuffer()));
            }

            // Submitted Quantity
            if (fields[Field.SubmittedQuantity])
            {
                AddAttribute("SubmittedQuantity", matchRow.WorkingOrderRow.SubmittedQuantity);
            }

            // Quantity Executed
            if (fields[Field.Execution])
            {
                decimal executedQuantity = decimal.Zero;
                decimal marketValue      = decimal.Zero;

                foreach (ClientMarketData.NegotiationRow negotiationRow in matchRow.GetNegotiationRows())
                {
                    if (negotiationRow.ExecutionRow != null)
                    {
                        executedQuantity = negotiationRow.ExecutionRow.ExecutionQuantity;
                        marketValue      = negotiationRow.ExecutionRow.ExecutionPrice * negotiationRow.ExecutionRow.ExecutionQuantity;
                    }
                }

                if (executedQuantity != decimal.Zero)
                {
                    AddAttribute("ExecutedQuantity", executedQuantity);
                    AddAttribute("AveragePrice", marketValue / executedQuantity);
                }
            }

            // Direction (OrderType)
            if (fields[Field.OrderTypeCode])
            {
                AddAttribute("OrderTypeCode", matchRow.WorkingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeMnemonic", matchRow.WorkingOrderRow.OrderTypeRow.Mnemonic);
                AddAttribute("OrderTypeDescription", matchRow.WorkingOrderRow.OrderTypeRow.Description);
            }

            // Created Time.
            if (fields[Field.CreatedTime])
            {
                AddAttribute("CreatedTime", matchRow.CreatedTime.ToString("s"));
            }

            // Find the pricing record.
            if (!matchRow.WorkingOrderRow.IsSettlementIdNull())
            {
                ClientMarketData.PriceRow priceRow = ClientMarketData.Price.FindBySecurityId(matchRow.WorkingOrderRow.SecurityId);
                if (priceRow != null)
                {
                    if (fields[Field.LastPrice])
                    {
                        AddAttribute("LastPrice", priceRow.LastPrice);
                    }
                    if (fields[Field.BidPrice])
                    {
                        AddAttribute("BidPrice", priceRow.BidPrice);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskPrice", priceRow.AskPrice);
                    }
                    if (fields[Field.LastSize])
                    {
                        AddAttribute("LastSize", priceRow.LastSize);
                    }
                    if (fields[Field.BidSize])
                    {
                        AddAttribute("BidSize", priceRow.BidSize);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskSize", priceRow.AskSize);
                    }
                    if (fields[Field.Volume])
                    {
                        AddAttribute("Volume", priceRow.Volume);
                    }
                    if (fields[Field.VolumeWeightedAveragePrice])
                    {
                        AddAttribute("VolumeWeightedAveragePrice", priceRow.VolumeWeightedAveragePrice);
                    }
                }
            }
        }
コード例 #18
0
        public MatchElement(MatchDocument matchDocument, ClientMarketData.MatchRow matchRow, FieldArray fields) :
            base("Match", matchDocument)
        {
            // WorkingOrderId
            AddAttribute("MatchId", matchRow.MatchId);
            AddAttribute("WorkingOrderId", matchRow.WorkingOrderId);
            AddAttribute("ContraOrderId", matchRow.ContraOrderId);

            // Status
            if (fields[Field.Status])
            {
                AddAttribute("StatusCode", matchRow.StatusCode);
                AddAttribute("StatusName", matchRow.StatusRow.Mnemonic);
                TimeSpan timeLeft = matchRow.TimerRow.StopTime.Subtract(matchRow.TimerRow.CurrentTime);
                AddAttribute("TimeLeft", string.Format("{0:0}:{1:00}", timeLeft.Minutes, timeLeft.Seconds));
                AddAttribute("SecondsLeft", Convert.ToInt32(timeLeft.TotalSeconds));
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", matchRow.WorkingOrderRow.BlotterRow.BlotterId);
                AddAttribute("BlotterName", matchRow.WorkingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
                if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsAverageDailyVolumeNull())
                {
                    AddAttribute("AverageDailyVolume", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume / 1000);
                }
                if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsMarketCapitalizationNull())
                {
                    AddAttribute("MarketCapitalization", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.MarketCapitalization / 1000000);
                }
                AddAttribute("VolumeCategoryMnemonic", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.VolumeCategoryRow.Mnemonic);
                MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Logo));
                Bitmap       bitmap       = new Bitmap(memoryStream);
                Bitmap       halfBitmap   = new Bitmap(bitmap, new Size(bitmap.Width / 2, bitmap.Height / 2));
                MemoryStream halfStream   = new MemoryStream();
                halfBitmap.Save(halfStream, System.Drawing.Imaging.ImageFormat.Png);
                AddAttribute("SecurityImage", Convert.ToBase64String(halfStream.GetBuffer()));
            }

            // Submitted Quantity
            if (fields[Field.SubmittedQuantity])
            {
                AddAttribute("SubmittedQuantity", matchRow.WorkingOrderRow.SubmittedQuantity);
            }

            // Direction (OrderType)
            if (fields[Field.OrderTypeCode])
            {
                AddAttribute("OrderTypeCode", matchRow.WorkingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeMnemonic", matchRow.WorkingOrderRow.OrderTypeRow.Mnemonic);
            }


            // Find the pricing record.
            if (!matchRow.WorkingOrderRow.IsSettlementIdNull())
            {
                ClientMarketData.PriceRow priceRow = ClientMarketData.Price.FindBySecurityId(matchRow.WorkingOrderRow.SecurityId);
                if (priceRow != null)
                {
                    if (fields[Field.LastPrice])
                    {
                        AddAttribute("LastPrice", priceRow.LastPrice);
                    }
                    if (fields[Field.BidPrice])
                    {
                        AddAttribute("BidPrice", priceRow.BidPrice);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskPrice", priceRow.AskPrice);
                    }
                    if (fields[Field.LastSize])
                    {
                        AddAttribute("LastSize", priceRow.LastSize);
                    }
                    if (fields[Field.BidSize])
                    {
                        AddAttribute("BidSize", priceRow.BidSize);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskSize", priceRow.AskSize);
                    }
                    if (fields[Field.Volume])
                    {
                        AddAttribute("Volume", priceRow.Volume);
                    }
                    if (fields[Field.InterpolatedVolume])
                    {
                        AddAttribute("InterpolatedVolume", VolumeHelper.CurrentVolumePercentage(DateTime.Now,
                                                                                                matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume,
                                                                                                priceRow.Volume));
                    }
                    if (fields[Field.VolumeWeightedAveragePrice])
                    {
                        AddAttribute("VolumeWeightedAveragePrice", priceRow.VolumeWeightedAveragePrice);
                    }
                }
            }
        }
コード例 #19
0
ファイル: QuoteViewer.cs プロジェクト: DonaldAirey/quasar
        /// <summary>
        /// This handler is called when prices have changed.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="priceRowChangingEvent">Event argument.</param>
        private void ChangePriceRow(object sender, ClientMarketData.PriceRowChangeEvent priceRowChangeEvent)
        {
            if (priceRowChangeEvent.Action == DataRowAction.Commit)
            {
                // Extract the price row from the event argumetns.
                ClientMarketData.PriceRow priceRow = priceRowChangeEvent.Row;

                // The code below will compare the current values to the original ones and set an indicator for which values have
                // changed.  This set of indicators will determine which values are included in the incremental XML fragment that
                // is created to update the viewer.
                FieldArray fields = FieldArray.Set;
                //FieldArray.Set;

                // There will only be 'Current' rows after the first batch of data is read from the server into the data model.
                // This check is needed to prevent exceptions when comparing the current row to the original one.
                if (!priceRow.HasVersion(DataRowVersion.Original))
                {
                    return;
                }

                // don't perform update if the securityId is not the security being displayed
                if (!priceRow.SecurityId.Equals(this.Tag))
                {
                    return;
                }

                // Set an indicator if the Last Price has changed.
                if (!priceRow[ClientMarketData.Price.LastPriceColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.LastPriceColumn, DataRowVersion.Current]))
                {
                    fields[Field.LastPrice] = true;
                }

                // Set an indicator if the Ask Price has changed.
                if (!priceRow[ClientMarketData.Price.AskPriceColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.AskPriceColumn, DataRowVersion.Current]))
                {
                    fields[Field.AskPrice] = true;
                }

                // Set an indicator if the Bid Price has changed.
                if (!priceRow[ClientMarketData.Price.BidPriceColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.BidPriceColumn, DataRowVersion.Current]))
                {
                    fields[Field.BidPrice] = true;
                }

                // Set an indicator if the Last Size has changed.
                if (!priceRow[ClientMarketData.Price.LastSizeColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.LastSizeColumn, DataRowVersion.Current]))
                {
                    fields[Field.LastSize] = true;
                }

                // Set an indicator if the Ask Size has changed.
                if (!priceRow[ClientMarketData.Price.AskSizeColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.AskSizeColumn, DataRowVersion.Current]))
                {
                    fields[Field.AskSize] = true;
                }

                // Set an indicator if the Bid Size has changed.
                if (!priceRow[ClientMarketData.Price.BidSizeColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.BidSizeColumn, DataRowVersion.Current]))
                {
                    fields[Field.BidSize] = true;
                }

                // Set an indiator if the Volume has changed.
                if (!priceRow[ClientMarketData.Price.VolumeColumn, DataRowVersion.Original].Equals(
                        priceRow[ClientMarketData.Price.VolumeColumn, DataRowVersion.Current]))
                {
                    fields[Field.Volume] = true;
                }

                if (fields)
                {
                    this.fragmentList.Add(DataAction.Update, priceRow, fields);
                }
            }
        }
コード例 #20
0
 internal BindClass(FieldArray fields, string name) : this(fields, name, null)
 {
 }
コード例 #21
0
ファイル: SqlExtractor.cs プロジェクト: INGMMV01/EccGenerator
        public static string CreateDeleteProcedure(string aplicacion, string tablename, FieldArray fields, string entidad)
        {
            /*
             * CREATE PROCEDURE [dbo].[RPOSXXX_entidad_I]
             *      @alias1 AS dbotype,
             *      @alias2 AS dbotype
             * AS
             * BEGIN
             *      DELETE FROM tablename
             *      WHERE  field1 = @alias1
             * END
             */
            const string PARAM_FORMAT = "\n\t@{0} AS {1},";
            const string WHERE_FORMAT = "{0} = @{1}\n\t\t\t  AND ";

            string spName = GetSPName(aplicacion, entidad, SPType.Delete);

            string SP_FORMAT =
                "CREATE PROCEDURE [dbo].[" + spName + "] \n" +
                "\t{0}\n" +
                "AS\n" +
                "BEGIN\n" +
                "\tDELETE FROM " + tablename + " \n" +
                "\tWHERE {1} \n" +
                "END;";

            string paramPart = "";
            string wherePart = "";

            foreach (Field fld in fields)
            {
                if (fld.Alias == null || fld.Alias == "")
                {
                    fld.Alias = fld.Name;
                }
            }

            string[] pks = GetPrimaryKeys(tablename);

            foreach (string pk in pks)
            {
                Field field = null;
                foreach (Field fld in fields)
                {
                    if (fld.Name == pk)
                    {
                        field = fld;
                        break;
                    }
                }

                if (field != null)
                {
                    string nParam = string.Format(PARAM_FORMAT, field.Alias, field.DBDefinition);
                    paramPart += nParam;
                    string nWhere = string.Format(WHERE_FORMAT, field.Name, field.Alias);
                    wherePart += nWhere;
                }
            }

            paramPart = CleanSPPart(paramPart);
            wherePart = CleanSPPart(wherePart);

            if (wherePart.Length > 0)
            {
                wherePart = wherePart.Remove(wherePart.Length - 4, 4);
            }

            return(string.Format(SP_FORMAT, paramPart, wherePart));
        }
コード例 #22
0
 public ComplexFrame()
 {
     SomeBytes  = new FieldArray <byte>(() => Number.Value);
     Structures = new FieldStructureArray <ComplexStructure>(() => Number.Value);
 }
コード例 #23
0
ファイル: SqlExtractor.cs プロジェクト: INGMMV01/EccGenerator
        public static string CreateInsertProcedure(string aplicacion, string tablename, FieldArray fields, string entidad)
        {
            /*
             * CREATE PROCEDURE [dbo].[RPOSXXX_entidad_I]
             *      @alias1 AS dbotype,
             *      @alias2 AS dbotype
             * AS
             * BEGIN
             *      INSERT INTO tablename
             *                      (field1,field2,field3)
             *      VALUES	(@alias1,@alias2,@alias3)
             * END
             */
            const string PARAM_FORMAT = "\n\t@{0} AS {1},";
            const string FIELD_FORMAT = "\n\t\t\t{0},";
            const string VALUE_FORMAT = "\n\t\t\t@{0},";

            string spName = GetSPName(aplicacion, entidad, SPType.Insert);

            string SP_FORMAT =
                "CREATE PROCEDURE [dbo].[" + spName + "] \n" +
                "{0}\n" +
                "AS\n" +
                "BEGIN\n" +
                "\tINSERT INTO " + tablename + " \n" +
                "\t\t\t({1})\n" +
                "\t\t\tVALUES({2}) \n" +
                "END;";

            string paramPart  = "";
            string fieldsPart = "";
            string valuesPart = "";

            foreach (Field fld in fields)
            {
                if (fld.Alias == null || fld.Alias == "")
                {
                    fld.Alias = fld.Name;
                }

                paramPart  += string.Format(PARAM_FORMAT, fld.Alias, fld.DBDefinition);
                fieldsPart += string.Format(FIELD_FORMAT, fld.Name);
                valuesPart += string.Format(VALUE_FORMAT, fld.Alias);
            }

            paramPart  = CleanSPPart(paramPart);
            fieldsPart = CleanSPPart(fieldsPart);
            valuesPart = CleanSPPart(valuesPart);

            return(string.Format(SP_FORMAT, paramPart, fieldsPart, valuesPart));
        }
コード例 #24
0
        public static string BindClass(string entidad, FieldArray fields, IDictionary extendedProperties)
        {
            BindClass bindclass = new BindClass(fields, entidad, extendedProperties);

            return(bindclass.ToString());
        }
コード例 #25
0
        private void bGenerar_Click(object sender, System.EventArgs e)
        {
            const string ENG_FNAME = "{0}\\Eng{1}.cs";
            const string CLS_FNAME = "{0}\\C{1}.cs";
            const string SP_FNAME  = "{0}\\{1}.sql";

            FieldArray fields     = RecuperaCampos();
            string     entidad    = tEntidad.Text,
                       aplicacion = tAplicacion.Text,
                       path       = tDirectorio.Text,
                       table      = lTabla.SelectedValue.ToString();

            string spnameselect = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Select),
                   spselect     = SqlExtractor.CreateSelectProcedure(aplicacion, table, fields, entidad),

                   spnameupdate = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Update),
                   spupdate     = SqlExtractor.CreateUpdateProcedure(aplicacion, table, fields, entidad),

                   spnameinsert = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Insert),
                   spinsert     = SqlExtractor.CreateInsertProcedure(aplicacion, table, fields, entidad),

                   spnamedelete = SqlExtractor.GetSPName(aplicacion, entidad, SPType.Delete),
                   spdelete     = SqlExtractor.CreateDeleteProcedure(aplicacion, table, fields, entidad);

            Hashtable extInfo = new Hashtable();

            extInfo.Add("aplicacion", aplicacion);
            extInfo.Add("spselect", spnameselect);
            extInfo.Add("spupdate", spnameupdate);
            extInfo.Add("spinsert", spnameinsert);
            extInfo.Add("spdelete", spnamedelete);
            extInfo.Add("primarykeys", SqlExtractor.GetPrimaryKeys(table));

            string strclass  = Binder.BindClass(entidad, fields, extInfo);
            string strengine = Binder.BindEngine(entidad, fields, extInfo);

            StreamWriter sw = new StreamWriter(string.Format(CLS_FNAME, path, entidad), false);

            sw.Write(strclass);
            sw.Close();


            sw = new StreamWriter(string.Format(ENG_FNAME, path, entidad), false);
            sw.Write(strengine);
            sw.Close();

            sw = new StreamWriter(string.Format(SP_FNAME, path, spnameselect), false);
            sw.Write(spselect);
            sw.Close();

            sw = new StreamWriter(string.Format(SP_FNAME, path, spnameupdate), false);
            sw.Write(spupdate);
            sw.Close();

            sw = new StreamWriter(string.Format(SP_FNAME, path, spnameinsert), false);
            sw.Write(spinsert);
            sw.Close();

            sw = new StreamWriter(string.Format(SP_FNAME, path, spnamedelete), false);
            sw.Write(spdelete);
            sw.Close();

            MessageBox.Show("Archivos generados correctamente");

            // Preparo para generar nuevas entidades
            tEntidad.Text      = "";
            panEntidad.Enabled = false;
        }
コード例 #26
0
        public WorkingOrderElement(WorkingOrderDocument workingOrderDocument, ClientMarketData.WorkingOrderRow workingOrderRow, FieldArray fields) :
            base("WorkingOrder", workingOrderDocument)
        {
            // Aggregate all the data related to this staged order.  This will work out the aggregates and distinct column
            // operations.
            if (fields[Field.SourceOrder] || fields[Field.DestinationOrder] || fields[Field.Execution] || fields[Field.Allocation])
            {
                AggregateFields(workingOrderRow);
            }

            // WorkingOrderId - Primary Key for this report.
            AddAttribute("WorkingOrderId", workingOrderRow.WorkingOrderId);

            // Status - Note that the status code is always provided to the DOM for color coding of the fields.
            AddAttribute("StatusCode", workingOrderRow.StatusCode);
            if (fields[Field.Status])
            {
                AddAttribute("StatusName", workingOrderRow.StatusRow.Mnemonic);
            }

            // Select a green flag for submitted records, a red flag for unsubmitted.
            int imageIndex = -1;

            switch (workingOrderRow.StatusCode)
            {
            case Status.Error:
                imageIndex = ClientMarketData.Image.KeyImageExternalId0.Find("Error Small");
                break;

            case Status.Submitted:
                imageIndex = ClientMarketData.Image.KeyImageExternalId0.Find("Flag Green Small");
                break;

            default:
                imageIndex = ClientMarketData.Image.KeyImageExternalId0.Find("Flag Red Small");
                break;
            }
            if (imageIndex != -1)
            {
                ClientMarketData.ImageRow imageRow =
                    (ClientMarketData.ImageRow)ClientMarketData.Image.KeyImageExternalId0[imageIndex].Row;
                AddAttribute("StatusImage", imageRow.Image);
            }

            // Blotter
            if (fields[Field.Blotter])
            {
                AddAttribute("Blotter", workingOrderRow.BlotterId);
                AddAttribute("BlotterName", workingOrderRow.BlotterRow.ObjectRow.Name);
            }

            // SubmissionTypeCode
            if (fields[Field.SubmissionTypeCode])
            {
                AddAttribute("SubmissionTypeCode", workingOrderRow.SubmissionTypeCode);
            }

            // IsBrokerMatch
            if (fields[Field.IsBrokerMatch])
            {
                AddAttribute("IsBrokerMatch", workingOrderRow.IsBrokerMatch);
            }

            // IsInstitutionMatch
            if (fields[Field.IsInstitutionMatch])
            {
                AddAttribute("IsInstitutionMatch", workingOrderRow.IsInstitutionMatch);
            }

            // IsHedgeMatch
            if (fields[Field.IsHedgeMatch])
            {
                AddAttribute("IsHedgeMatch", workingOrderRow.IsHedgeMatch);
            }


            // Auto-Execute - we always send the isAutomatic flag and the quantity
            if (fields[Field.AutoExecute])
            {
                AddAttribute("IsAutomatic", workingOrderRow.IsAutomatic);

                if (!workingOrderRow.IsAutomaticQuantityNull())
                {
                    AddAttribute("AutomaticQuantity", workingOrderRow.AutomaticQuantity);
                }
                else
                {
                    AddAttribute("AutomaticQuantity", 0);
                }
            }

            // LimitPrice
            if (fields[Field.LimitPrice])
            {
                if (!workingOrderRow.IsLimitPriceNull())
                {
                    AddAttribute("LimitPrice", workingOrderRow.LimitPrice);
                }
                else
                {
                    AddAttribute("LimitPrice", 0);
                }
            }

            // OrderType
            if (fields[Field.OrderType])
            {
                AddAttribute("OrderTypeCode", workingOrderRow.OrderTypeCode);
                AddAttribute("OrderTypeDescription", workingOrderRow.OrderTypeRow.Description);
                AddAttribute("OrderTypeMnemonic", workingOrderRow.OrderTypeRow.Mnemonic);
                AddAttribute("CashSign", workingOrderRow.OrderTypeRow.CashSign);
                AddAttribute("QuantitySign", workingOrderRow.OrderTypeRow.QuantitySign);

                // Select a green flag for submitted records, a red flag for unsubmitted.
                int orderTypeImageIndex = -1;
                switch (workingOrderRow.OrderTypeCode)
                {
                case OrderType.Buy:
                    orderTypeImageIndex = ClientMarketData.Image.KeyImageExternalId0.Find("Navigate Plain Green Small");
                    break;

                case OrderType.Sell:
                    orderTypeImageIndex = ClientMarketData.Image.KeyImageExternalId0.Find("Navigate Plain Red Small");
                    break;
                }
                if (orderTypeImageIndex != -1)
                {
                    ClientMarketData.ImageRow imageRow =
                        (ClientMarketData.ImageRow)ClientMarketData.Image.KeyImageExternalId0[orderTypeImageIndex].Row;
                    AddAttribute("OrderTypeImage", imageRow.Image);
                }
            }

            // TimeInForce
            if (fields[Field.TimeInForce])
            {
                AddAttribute("TimeInForceCode", workingOrderRow.TimeInForceRow.TimeInForceCode);
                AddAttribute("TimeInForceName", workingOrderRow.TimeInForceRow.Mnemonic);
            }

            // Security
            if (fields[Field.Security])
            {
                AddAttribute("SecurityId", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId);
                AddAttribute("SecuritySymbol", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol);
                AddAttribute("SecurityName", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name);
                if (!workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsMarketCapitalizationNull())
                {
                    AddAttribute("MarketCapitalization", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.MarketCapitalization / 1000000.0m);
                }
                if (!workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsAverageDailyVolumeNull())
                {
                    AddAttribute("AverageDailyVolume", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume / 1000.0m);
                }
                AddAttribute("VolumeCategoryMnemonic", workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.VolumeCategoryRow.Mnemonic);
            }

            // Source Order Total Quantity
            if (fields[Field.SourceOrder])
            {
                AddAttribute("SourceOrderQuantity", this.totalSourceOrderedQuantity);
            }

            //  Destination Order Total Quantity
            if (fields[Field.DestinationOrder])
            {
                AddAttribute("DestinationOrderQuantity", this.totalDestinationOrderedQuantity);
            }

            // Total Executed Quantity and Average Price
            if (fields[Field.SubmittedQuantity])
            {
                AddAttribute("SubmittedQuantity", workingOrderRow.SubmittedQuantity);
            }

            // Total Executed Quantity and Average Price
            if (fields[Field.Execution])
            {
                AddAttribute("ExecutedQuantity", this.totalExecutedQuantity);
                AddAttribute("AveragePrice", this.averagePriceExecuted);
            }

            // Total Quantity Allocated
            if (fields[Field.Allocation])
            {
                AddAttribute("AllocatedQuantity", this.totalAllocatedQuantity);
            }

            //  Working Order Leaves (Total Source Quantity - Total Destination Quantity)
            if (fields[Field.SourceOrder] || fields[Field.DestinationOrder])
            {
                AddAttribute("LeavesQuantity", this.totalLeavesQuantity);
            }

            //  Working Order Working Quantity (Total Source Quantity - Total Executed Quantity)
            if (fields[Field.SourceOrder] || fields[Field.Execution])
            {
                AddAttribute("WorkingQuantity", this.totalWorkingQuantity);
            }

            // Start Time
            if (fields[Field.StartTime] && !workingOrderRow.IsStartTimeNull())
            {
                AddAttribute("StartTime", workingOrderRow.StartTime.ToString("s"));
            }

            // Stop Time
            if (fields[Field.StopTime] && !workingOrderRow.IsStopTimeNull())
            {
                AddAttribute("StopTime", workingOrderRow.StopTime.ToString("s"));
            }

            // Maxmimum Volatility
            if (fields[Field.MaximumVolatility] && !workingOrderRow.IsMaximumVolatilityNull())
            {
                AddAttribute("MaximumVolatility", workingOrderRow.MaximumVolatility);
            }

            // News Free Time
            if (fields[Field.NewsFreeTime] && !workingOrderRow.IsNewsFreeTimeNull())
            {
                AddAttribute("NewsFreeTime", workingOrderRow.NewsFreeTime);
            }

            // Timer Field
            if (fields[Field.Timer])
            {
                TimeSpan timeLeft = workingOrderRow.TimerRow.StopTime.Subtract(workingOrderRow.TimerRow.CurrentTime);
                AddAttribute("TimeLeft", string.Format("{0:0}:{1:00}", timeLeft.Minutes, timeLeft.Seconds));
            }

            // The Working Order Fields
            if (fields[Field.WorkingOrder])
            {
                // Created
                AddAttribute("CreatedName", workingOrderRow.UserRowByUserWorkingOrderCreatedUserId.ObjectRow.Name);
                AddAttribute("CreatedTime", workingOrderRow.CreatedTime.ToString("s"));

                // Destination
                if (!workingOrderRow.IsDestinationIdNull())
                {
                    AddAttribute("DestinationId", workingOrderRow.DestinationRow.DestinationId);
                    AddAttribute("DestinationName", workingOrderRow.DestinationRow.Name);
                    AddAttribute("DestinationShortName", workingOrderRow.DestinationRow.ShortName);
                }

                // The Direction of this order (buy, sell, buy cover, etc.)
                AddAttribute("PriceTypeCode", workingOrderRow.PriceTypeRow.PriceTypeCode);
                AddAttribute("PriceTypeMnemonic", workingOrderRow.PriceTypeRow.Mnemonic);

                // Commission
                AddAttribute("Commission", this.totalCommission);

                // FilledNet
                AddAttribute("NetMarketValue", this.totalMarketValue - workingOrderRow.OrderTypeRow.CashSign * this.totalCommission);

                // Market
                //			AddAttribute("MarketId", workingOrderRow.SecurityRowByFKSecurityWorkingOrderSecurityId.MarketRow.MarketId);
                //			AddAttribute("MarketName", workingOrderRow.SecurityRowByFKSecurityWorkingOrderSecurityId.MarketRow.Name);
                //			AddAttribute("MarketShortName", workingOrderRow.SecurityRowByFKSecurityWorkingOrderSecurityId.MarketRow.ShortName);

                // LimitPrice
                // NOTE: LimitPrice is not sent when the WorkingOrder flag is set.
                // LimitPrice has a separate bit set in the field arary

                // Stop Price
                if (!workingOrderRow.IsStopPriceNull())
                {
                    AddAttribute("StopPrice", (decimal)workingOrderRow.StopPrice);
                }

                // TradeDate
                AddAttribute("TradeDate", workingOrderRow.CreatedTime.ToString("s"));

                // UploadTime
                if (!workingOrderRow.IsUploadedTimeNull())
                {
                    AddAttribute("UploadTime", workingOrderRow.CreatedTime.ToString("s"));
                }

                // CommissionType
                //				if (workingOrderRow != null)
                //				{
                //				ClientMarketData.CommissionRateTypeRow commissionRateTypeRow =
                //					ClientMarketData.CommissionRateType.FindByCommissionRateTypeCode((int)this.commissionRateTypeCode);
                //				AddAttribute("CommissionRateTypeCode", commissionRateTypeRow.CommissionRateTypeCode);
                //				AddAttribute("CommissionRateTypeName", commissionRateTypeRow.Name);
                //					AddAttribute("CommissionRate", this.averageCommissionRate);
                //				}

                // Filled Gross
                AddAttribute("MarketValue", this.totalMarketValue);

                // Unfilled
                AddAttribute("Unfilled", this.totalSourceOrderedQuantity - this.totalExecutedQuantity);
            }

            // Find the pricing record.
            if (!workingOrderRow.IsSettlementIdNull())
            {
                ClientMarketData.PriceRow priceRow = ClientMarketData.Price.FindBySecurityId(workingOrderRow.SecurityId);
                if (priceRow != null)
                {
                    if (fields[Field.LastPrice])
                    {
                        AddAttribute("LastPrice", priceRow.LastPrice);
                    }
                    if (fields[Field.BidPrice])
                    {
                        AddAttribute("BidPrice", priceRow.BidPrice);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskPrice", priceRow.AskPrice);
                    }
                    if (fields[Field.LastSize])
                    {
                        AddAttribute("LastSize", priceRow.LastSize);
                    }
                    if (fields[Field.BidSize])
                    {
                        AddAttribute("BidSize", priceRow.BidSize);
                    }
                    if (fields[Field.AskPrice])
                    {
                        AddAttribute("AskSize", priceRow.AskSize);
                    }
                    if (fields[Field.Volume])
                    {
                        AddAttribute("Volume", priceRow.Volume);
                    }
                    if (fields[Field.InterpolatedVolume])
                    {
                        AddAttribute("InterpolatedVolume", VolumeHelper.CurrentVolumePercentage(DateTime.Now,
                                                                                                workingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume,
                                                                                                priceRow.Volume));
                    }
                    if (fields[Field.VolumeWeightedAveragePrice])
                    {
                        AddAttribute("VolumeWeightedAveragePrice", priceRow.VolumeWeightedAveragePrice);
                    }
                }
            }
        }