Пример #1
0
        private static void DoFixRequest(IMarketDataProvider provider, Instrument instrument, MarketDataType type, char subCh, string suffix)
        {
            FIXMarketDataRequest request = new FIXMarketDataRequest();

            request.MDReqID = DataManager.GetRequestId();
            request.SubscriptionRequestType = subCh;
            switch (type)
            {
            case MarketDataType.Trade:
                request.AddGroup(new FIXMDEntryTypesGroup('2'));
                break;

            case MarketDataType.Quote:
                request.AddGroup(new FIXMDEntryTypesGroup('0'));
                request.AddGroup(new FIXMDEntryTypesGroup('1'));
                request.MarketDepth = 1;      // Top of Book
                break;

            case MarketDataType.MarketDepth:
                request.AddGroup(new FIXMDEntryTypesGroup('0'));
                request.AddGroup(new FIXMDEntryTypesGroup('1'));
                request.MarketDepth = 0;      // Full Book
                break;
            }
            if (!instrument.ContainsField(15))
            {
                instrument.Currency = Framework.Configuration.DefaultCurrency;
            }
            FIXRelatedSymGroup symGrp = new FIXRelatedSymGroup();

            request.AddGroup(symGrp);
            symGrp.Symbol            = instrument.Symbol;
            symGrp.SecurityType      = instrument.SecurityType;
            symGrp.SecurityExchange  = instrument.SecurityExchange;
            symGrp.Currency          = instrument.Currency;
            symGrp.SecurityID        = instrument.SecurityID;
            symGrp.SecurityIDSource  = instrument.SecurityIDSource;
            symGrp.MaturityDate      = instrument.MaturityDate;
            symGrp.MaturityMonthYear = instrument.MaturityMonthYear;
            symGrp.StrikePrice       = instrument.StrikePrice;
            symGrp.PutOrCall         = ((FIXInstrument)instrument).PutOrCall;
            foreach (FIXSecurityAltIDGroup group2 in instrument.SecurityAltIDGroup)
            {
                symGrp.AddGroup(group2);
            }
            symGrp.SetStringValue(10001, suffix);
            if (provider == ProviderManager.MarketDataSimulator)
            {
                provider.SendMarketDataRequest(request);
            }
            else
            {
                switch (subCh)
                {
                case MARKET_DATA_SUBSCRIBE:
                    bool flag1 = false;
                    lock (DataManager.providers)
                    {
                        Hashtable local_4 = DataManager.providers[provider] as Hashtable;
                        if (local_4 == null)
                        {
                            local_4 = new Hashtable();
                            DataManager.providers.Add(provider, local_4);
                        }
                        Hashtable local_5 = local_4[instrument] as Hashtable;
                        if (local_5 == null)
                        {
                            local_5 = new Hashtable();
                            local_4.Add(instrument, local_5);
                        }
                        RequestItem local_6 = local_5[type] as RequestItem;
                        if (local_6 == null)
                        {
                            local_6 = new RequestItem(request);
                            local_5.Add(type, local_6);
                            flag1 = true;
                        }
                        RequestItem temp_91 = local_6;
                        int         temp_94 = temp_91.GetRequestId() + 1;
                        temp_91.SetRequestId(temp_94);
                    }
                    if (!flag1)
                    {
                        break;
                    }
                    provider.SendMarketDataRequest(request);
                    break;

                case MARKET_DATA_UNSUBSCRIBE:
                    bool   canSend = false;
                    string msg     = null;
                    lock (DataManager.providers)
                    {
                        Hashtable local_10 = DataManager.providers[provider] as Hashtable;
                        if (local_10 != null)
                        {
                            Hashtable local_11 = local_10[instrument] as Hashtable;
                            if (local_11 != null)
                            {
                                RequestItem local_12 = local_11[type] as RequestItem;
                                if (local_12 != null)
                                {
                                    RequestItem temp_152 = local_12;
                                    int         temp_155 = temp_152.GetRequestId() - 1;
                                    temp_152.SetRequestId(temp_155);
                                    if (local_12.GetRequestId() == 0)
                                    {
                                        local_11.Remove(type);
                                        if (local_11.Count == 0)
                                        {
                                            local_10.Remove(instrument);
                                            if (local_10.Count == 0)
                                            {
                                                DataManager.providers.Remove(provider);
                                            }
                                        }
                                        canSend = true;
                                    }
                                }
                                else
                                {
                                    msg = "No this RequestItem";
                                }
                            }
                            else
                            {
                                msg = "No Request for this instrument";
                            }
                        }
                        else
                        {
                            msg = "No Request for this provider";
                        }
                    }
                    if (msg != null)
                    {
                        DataManager.LogRequestMessage(provider, instrument, type, msg);
                    }
                    if (!canSend)
                    {
                        break;
                    }
                    provider.SendMarketDataRequest(request);
                    break;
                }
            }
        }