Beispiel #1
0
        public static MdpMessage GetMessage(byte[] data)
        {
            MessageType type = GetType(data);

            MdpMessage mes = null;

            if (type == MessageType.SecurityDefinition)
            {
                mes = new SecurityDefinition();
            }
            else if (type == MessageType.SecurityStatus)
            {
                mes = new StatusUpdate();
            }
            else if (type == MessageType.MarketDataSnapshotFullRefresh)
            {
                mes = new SnapshotUpdate();
            }
            else if (type == MessageType.MarketDataIncrementalRefresh)
            {
                mes = new IncrementalUpdate();
            }

            mes.Decode(data);

            return(mes);
        }
        public static List <Security> Load(string file)
        {
            var securities = new List <Security>();

            using (var streamReader = new StreamReader(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                string line;
                while ((line = streamReader.ReadLine()) != null)
                {
                    var x = new SecurityDefinition();
                    x.Decode(Encoding.UTF8.GetBytes(line));
                    securities.Add(x.ToSecurity());
                }
            }

            return(securities);
        }
        public static Security Load(string file, string contract)
        {
            using (var streamReader = new StreamReader(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                string line;
                while ((line = streamReader.ReadLine()) != null)
                {
                    var x = new SecurityDefinition();
                    x.Decode(Encoding.UTF8.GetBytes(line));
                    var sec = x.ToSecurity();
                    if (sec.Contract == contract)
                    {
                        return(sec);
                    }
                }
            }

            return(null);
        }