예제 #1
0
        public List <InstrumentInfo> getInsrumetns(UserData _user)
        {
            List <InstrumentInfo> instrumentInfoList   = new List <InstrumentInfo>();
            LicenseServiceClient  licenseServiceClient = new LicenseServiceClient();

            foreach (InstrumentsContract instrumentsContract in ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader()
            {
                Account = _user.User,
                Signature = _user.Signature
            })).Where <InstrumentsContract>((Func <InstrumentsContract, bool>)(inst => inst.Enabled)))
            {
                InstrumentInfo instrumentInfo = new InstrumentInfo()
                {
                    ID         = instrumentsContract.DisplayId,
                    Name       = instrumentsContract.Description,
                    Parameters = new string[2]
                    {
                        instrumentsContract.Parametr1,
                        instrumentsContract.Parametr2
                    },
                    Providerid = instrumentsContract.ProviderId
                };
                instrumentInfoList.Add(instrumentInfo);
            }
            return(instrumentInfoList);
        }
예제 #2
0
        public void GetInstruments()
        {
            if (this.CQGInstruments != null)
            {
                this.CQGInstruments.Clear();
            }
            if (this.SaxoInstruments != null)
            {
                this.SaxoInstruments.Clear();
            }
            if (this.LmaxInstruments != null)
            {
                this.LmaxInstruments.Clear();
            }
            if (this.rithmicSubscriptions != null)
            {
                this.rithmicSubscriptions.Clear();
            }
            if (this.TWSInstruments != null)
            {
                this.TWSInstruments.Clear();
            }
            if (this.IQInstruments != null)
            {
                this.IQInstruments.Clear();
            }
            if (!new Security().connectToServer())
            {
                return;
            }
            LicenseServiceClient    licenseServiceClient = new LicenseServiceClient();
            List <ProviderContract> list1 = ((IEnumerable <ProviderContract>)licenseServiceClient.getProviders(new Trader()
            {
                Account = this.User,
                Signature = this.Config
            })).ToList <ProviderContract>();
            List <InstrumentsContract> list2 = ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader()
            {
                Account = this.User,
                Signature = this.Config
            })).ToList <InstrumentsContract>();

            licenseServiceClient.Close();
            if (list1 != null && list2 != null)
            {
                foreach (InstrumentsContract instrumentsContract in list2)
                {
                    InstrumentsContract            p      = instrumentsContract;
                    IEnumerable <ProviderContract> source = list1.Where <ProviderContract>((Func <ProviderContract, bool>)(pr => pr.Id == p.ProviderId));
                    if (source != null && source.Count <ProviderContract>() == 1)
                    {
                        string name = source.First <ProviderContract>().Name;
                        if (!(name == "Lmax"))
                        {
                            if (!(name == "CQG"))
                            {
                                if (!(name == "Saxo"))
                                {
                                    if (!(name == "Rithmic"))
                                    {
                                        if (!(name == "TWS"))
                                        {
                                            if (name == "IQFeed")
                                            {
                                                this.IQInstruments.Add(new Settings.IQFeedInstruments()
                                                {
                                                    Id      = p.Id,
                                                    Symbol  = p.DisplayId,
                                                    Name    = p.Description,
                                                    Enabled = p.Enabled
                                                });
                                            }
                                        }
                                        else
                                        {
                                            string[] strArray = p.DisplayId.Split('%');
                                            this.TWSInstruments.Add(new Settings.TWSSubscription()
                                            {
                                                InstumentId = p.Id,
                                                Symbol      = strArray[0],
                                                Currency    = strArray[1],
                                                SecType     = p.Parametr1,
                                                Exchange    = p.Parametr2,
                                                Enabled     = p.Enabled
                                            });
                                        }
                                    }
                                    else
                                    {
                                        this.rithmicSubscriptions.Add(new Settings.rithmicSubscription()
                                        {
                                            InstumentId = p.Id,
                                            symbol      = p.DisplayId,
                                            Description = p.Description,
                                            exchange    = p.Parametr1,
                                            Enabled     = p.Enabled
                                        });
                                    }
                                }
                                else
                                {
                                    this.SaxoInstruments.Add(new Settings.SaxoValues()
                                    {
                                        InstumentId    = p.Id,
                                        InstrumentType = p.DisplayId,
                                        Name           = p.Description,
                                        Enabled        = p.Enabled
                                    });
                                }
                            }
                            else
                            {
                                this.CQGInstruments.Add(new Settings.CQGInstrument()
                                {
                                    InstumentId = p.Id,
                                    Instrument  = p.DisplayId,
                                    Enabled     = p.Enabled
                                });
                            }
                        }
                        else
                        {
                            int result = 0;
                            if (int.TryParse(p.DisplayId, out result) && !this.LmaxInstruments.ContainsKey(result))
                            {
                                this.LmaxInstruments.Add(result, new Settings.LmaxValues()
                                {
                                    InstrumentId = p.Id,
                                    Name         = p.Description,
                                    Enabled      = p.Enabled
                                });
                            }
                        }
                    }
                }
            }
            Settings.LocalSetting.rithmicSubscriptions = this.rithmicSubscriptions;
        }