public SecurityDefinitionViewItem(FIXSecurityDefinition securityDefinition, byte providerId)
            : base(new string[5])
        {
            this.securityDefinition = securityDefinition;
            this.SubItems[0].Text   = SecurityDefinitionHelper.GetSymbol(securityDefinition, providerId);
            this.SubItems[1].Text   = ((object)APITypeConverter.InstrumentType.Convert(securityDefinition.SecurityType)).ToString();
            this.SubItems[2].Text   = securityDefinition.SecurityExchange;
            this.SubItems[3].Text   = securityDefinition.Currency;
            DateTime?nullable;

            if (((FIXGroup)securityDefinition).ContainsField(541))
            {
                nullable = new DateTime?(securityDefinition.MaturityDate);
            }
            else if (((FIXGroup)securityDefinition).ContainsField(200))
            {
                try
                {
                    nullable = new DateTime?(new DateTime(int.Parse(securityDefinition.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture), int.Parse(securityDefinition.MaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture), 1));
                }
                catch
                {
                    nullable = new DateTime?();
                }
            }
            else
            {
                nullable = new DateTime?();
            }
            this.SubItems[4].Text = !nullable.HasValue ? "" : nullable.Value.ToShortDateString();
        }
Esempio n. 2
0
        private bool AddInstrument(FIXSecurityDefinition securityDefinition)
        {
            string symbol = SecurityDefinitionHelper.GetSymbol(securityDefinition, ((IProvider)this.provider).Id);

            if (InstrumentManager.Instruments.Contains(symbol))
            {
                return(false);
            }
            Instrument instrument = new Instrument(symbol, securityDefinition.SecurityType);

            foreach (FIXField fixField in ((FIXGroup)securityDefinition).Fields)
            {
                switch ((int)fixField.Tag)
                {
                case 320:
                case 322:
                case 323:
                case 393:
                case 55:
                case 167:
                    goto case 320;

                default:
                    ((FIXGroup)instrument).AddField(fixField);
                    goto case 320;
                }
            }
            for (int index = 0; index < securityDefinition.NoSecurityAltID; ++index)
            {
                ((FIXInstrument)instrument).AddGroup(securityDefinition.GetSecurityAltIDGroup(index));
            }
            switch (((IProvider)this.provider).Id)
            {
            case (byte)4:
                if (((FIXInstrument)instrument).Symbol != securityDefinition.Symbol)
                {
                    instrument.AddSymbol(securityDefinition.Symbol, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name);
                }
                ((FIXGroup)instrument).RemoveField(48);
                break;

            case (byte)10:
                instrument.AddSymbol(string.Format("{0}|{1}|1.0", (object)securityDefinition.Symbol, securityDefinition.SecurityID), securityDefinition.SecurityExchange, ((IProvider)this.provider).Name);
                ((FIXGroup)instrument).RemoveField(48);
                instrument.AddSymbol(securityDefinition.Symbol, securityDefinition.SecurityExchange, "TT API");
                break;

            case (byte)21:
                instrument.AddSymbol(securityDefinition.SecurityID, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name);
                break;

            case (byte)22:
                if (((FIXInstrument)instrument).Symbol != securityDefinition.Symbol)
                {
                    instrument.AddSymbol(securityDefinition.SecurityID, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name);
                    ((FIXGroup)instrument).RemoveField(48);
                    break;
                }
                else
                {
                    break;
                }
            }
            if ((((FIXInstrument)instrument).SecurityType == "FUT" || ((FIXInstrument)instrument).SecurityType == "OPT" || ((FIXInstrument)instrument).SecurityType == "MLEG") && (!((FIXGroup)instrument).ContainsField(541) && ((FIXGroup)instrument).ContainsField(200)))
            {
                int year  = int.Parse(securityDefinition.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture);
                int month = int.Parse(securityDefinition.MaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture);
                ((FIXInstrument)instrument).MaturityDate = new DateTime(year, month, 1);
            }
            instrument.Save();
            return(true);
        }