Esempio n. 1
0
        void CreateAutoSpreader(object sender, InstrumentLookupSubscriptionEventArgs e)
        {
            if (e.Instrument != null && e.Error == null)
            {
                // Instrument was found
                Console.WriteLine("Found: {0}", e.Instrument.Name);

                InstrumentDictionary.Add(e.Instrument.Key, e.Instrument);

                // Update the dictionary to indicate that the instrument was found.
                InstrumentLookupSubscription instrLookupSub = sender as InstrumentLookupSubscription;

                if (SpreadLegKeys.ContainsKey((int)instrLookupSub.Tag))
                {
                    SpreadLegKeys[(int)instrLookupSub.Tag] = e.Instrument;
                }
            }
            else if (e.IsFinal)
            {
                // Instrument was not found and TT API has given up looking for it
                Console.WriteLine("Cannot find instrument: {0}", e.Error.Message);
                Subs.Dispose();
            }

            // If we have found all of the leg instruments, proceed with the creation of the spread.
            if (HaveWeFoundAllLegs())
            {
                Console.WriteLine("All leg instruments have been found.  Creating the spread...");

                // SpreadDetails related properties
                SpreadDetails spreadDetails = new SpreadDetails();
                spreadDetails.Name = AutoSpreaderName;

                for (int i = 0; i < DbTickerList.Count; i++)
                {
                    Instrument instrument = SpreadLegKeys[i + 1];

                    var ValidOrderFeeds = instrument.GetValidOrderFeeds();

                    while (ValidOrderFeeds.Count == 0)
                    {
                        ValidOrderFeeds = instrument.GetValidOrderFeeds();
                        Console.WriteLine("Attempting to get valid forder feed for: " + DbTickerList[i]);
                    }

                    SpreadLegDetails spreadlegDetails = new SpreadLegDetails(instrument, ValidOrderFeeds[0].ConnectionKey);
                    spreadlegDetails.SpreadRatio     = (int)RatioAndMultiplier["Ratio"][i];
                    spreadlegDetails.PriceMultiplier = RatioAndMultiplier["Multiplier"][i];
                    spreadlegDetails.CustomerName    = "<DEFAULT>";
                    spreadlegDetails.PayupTicks      = PayUpTicks;
                    spreadDetails.Legs.Append(spreadlegDetails);
                }

                // Create an AutospreaderInstrument corresponding to the synthetic spread
                Air            = new CreateAutospreaderInstrumentRequest(m_apiInstance.Session, Dispatcher.Current, spreadDetails);
                Air.Completed += new EventHandler <CreateAutospreaderInstrumentRequestEventArgs>(m_casReq_Completed);
                Air.Submit();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Event notification for instrument lookup
        /// </summary>
        void m_req_Update(object sender, InstrumentLookupSubscriptionEventArgs e)
        {
            if (e.Instrument != null && e.Error == null)
            {
                // Instrument was found
                Console.WriteLine("Found: {0}", e.Instrument.Name);

                // Update the dictionary to indicate that the instrument was found.
                InstrumentLookupSubscription instrLookupSub = sender as InstrumentLookupSubscription;

                if (m_spreadLegKeys.ContainsKey((int)instrLookupSub.Tag))
                {
                    m_spreadLegKeys[(int)instrLookupSub.Tag] = e.Instrument;
                }
            }
            else if (e.IsFinal)
            {
                // Instrument was not found and TT API has given up looking for it
                Console.WriteLine("Cannot find instrument: {0}", e.Error.Message);
                Dispose();
            }

            // If we have found all of the leg instruments, proceed with the creation of the spread.
            if (HaveWeFoundAllLegs())
            {
                Console.WriteLine("All leg instruments have been found.  Creating the spread...");

                // SpreadDetails related properties
                SpreadDetails spreadDetails = new SpreadDetails();
                spreadDetails.Name = "My Spread";

                int i = 0;
                // Add the legs to the SpreadDetails
                foreach (Instrument instrument in m_spreadLegKeys.Values)
                {
                    // In this example, the order is routed to the first order feed in the list of valid order feeds.
                    // You should use the order feed that is appropriate for your purposes.
                    SpreadLegDetails spreadlegDetails = new SpreadLegDetails(instrument, instrument.GetValidOrderFeeds()[0].ConnectionKey);
                    spreadlegDetails.SpreadRatio     = (i % 2 == 0) ? 1 : -1;
                    spreadlegDetails.PriceMultiplier = (i % 2 == 0) ? 1 : -1;
                    spreadlegDetails.CustomerName    = "<Default>";

                    spreadDetails.Legs.Append(spreadlegDetails);
                    i++;
                }

                // Create an AutospreaderInstrument corresponding to the synthetic spread
                m_casReq            = new CreateAutospreaderInstrumentRequest(m_apiInstance.Session, Dispatcher.Current, spreadDetails);
                m_casReq.Completed += new EventHandler <CreateAutospreaderInstrumentRequestEventArgs>(m_casReq_Completed);
                m_casReq.Submit();
            }
        }
Esempio n. 3
0
        //
        //
        #endregion//Constructors


        #region no Properties
        // *****************************************************************
        // ****                     Properties                          ****
        // *****************************************************************
        //
        //
        #endregion//Properties


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        public bool TryCreateAutoSpreader(List <UVSpreaderLeg> quoteLegsList)
        {
            SpreadDetails spreadDetails = new SpreadDetails();
            StringBuilder spreadName    = new StringBuilder();

            m_UVSpreaderLegs = quoteLegsList;
            foreach (UVSpreaderLeg spreadLeg in quoteLegsList)
            {
                UVInstrName instrName = spreadLeg.InstrumentDetails.InstrumentName;
                spreadName.AppendFormat("{0}x{1}.", instrName, spreadLeg.m_PriceLeg.Weight);

                InstrumentKey     instrKey;
                FeedConnectionKey feedConnectionKey;
                if (!m_InstrumentNameToTTKey.TryGetValue(instrName, out instrKey))
                {
                    return(false); // we can't find the instrumentKey
                }
                if (!m_DefaultFeedKey.TryGetValue(instrKey, out feedConnectionKey))
                {
                    return(false); // we can't find the instrumentKey
                }
                // This needs to be fixed due to the newer API 7.17
                //SpreadLegDetails spreadLegDetails = new SpreadLegDetails(instrKey, feedConnectionKey);
                //spreadLegDetails.SpreadRatio = (int)spreadLeg.m_PriceLeg.Weight;
                //spreadLegDetails.PriceMultiplier = spreadLeg.m_PriceLeg.PriceMultiplier;
                //spreadLegDetails.CustomerName = instrName.ToString();

                //spreadDetails.Legs.Append(spreadLegDetails);
            }

            spreadDetails.Name = spreadName.ToString();

            CreateAutospreaderInstrumentRequest autoSpreaderRequest = new CreateAutospreaderInstrumentRequest(m_TTService.session, Dispatcher.Current, spreadDetails);

            autoSpreaderRequest.Completed += new EventHandler <CreateAutospreaderInstrumentRequestEventArgs>(AutoSpreaderInstrumentRequest_Completed);
            autoSpreaderRequest.Submit();

            return(true);
        }
        /// <summary>
        /// Event notification for instrument lookup
        /// </summary>
        void m_req_Update(object sender, InstrumentLookupSubscriptionEventArgs e)
        {
            if (e.Instrument != null && e.Error == null)
            {
                // Instrument was found
                Console.WriteLine("Found: {0}", e.Instrument.Name);

                // Update the dictionary to indicate that the instrument was found.
                InstrumentLookupSubscription instrLookupSub = sender as InstrumentLookupSubscription;

                if (m_spreadLegKeys.ContainsKey((int)instrLookupSub.Tag))
                {
                    m_spreadLegKeys[(int)instrLookupSub.Tag] = e.Instrument;
                }
            }
            else if (e.IsFinal)
            {
                // Instrument was not found and TT API has given up looking for it
                Console.WriteLine("Cannot find instrument: {0}", e.Error.Message);
                Dispose();
            }

            // If we have found all of the leg instruments, proceed with the creation of the spread.
            if (HaveWeFoundAllLegs())
            {
                Console.WriteLine("All leg instruments have been found.  Creating the spread...");

                // SpreadDetails related properties
                SpreadDetails spreadDetails = new SpreadDetails();
                spreadDetails.Name = "My Spread";

                int i = 0;
                // Add the legs to the SpreadDetails
                foreach (Instrument instrument in m_spreadLegKeys.Values)
                {
                    // In this example, the order is routed to the first order feed in the list of valid order feeds.
                    // You should use the order feed that is appropriate for your purposes.
                    SpreadLegDetails spreadlegDetails = new SpreadLegDetails(instrument, instrument.GetValidOrderFeeds()[0].ConnectionKey);
                    spreadlegDetails.SpreadRatio = (i % 2 == 0) ? 1 : -1;
                    spreadlegDetails.PriceMultiplier = (i % 2 == 0) ? 1 : -1;
                    spreadlegDetails.CustomerName = "<Default>";

                    spreadDetails.Legs.Append(spreadlegDetails);
                    i++;
                }

                // Create an AutospreaderInstrument corresponding to the synthetic spread
                m_casReq = new CreateAutospreaderInstrumentRequest(m_apiInstance.Session, Dispatcher.Current, spreadDetails);
                m_casReq.Completed += new EventHandler<CreateAutospreaderInstrumentRequestEventArgs>(m_casReq_Completed);
                m_casReq.Submit();
            }
        }
        private void CreateSpreadDetails()
        {
            Console.WriteLine("Creating the spread...");

            // SpreadDetails related properties
            SpreadDetails spreadDetails = new SpreadDetails();
            spreadDetails.Name = "My Spread";

            int i = 0;
            // Add the legs to the SpreadDetails
            foreach (Instrument instrument in spreadLegKeys.Values)
            {
                // In this example, the order is routed to the first order feed in the list of valid order feeds.
                // You should use the order feed that is appropriate for your purposes.
                SpreadLegDetails spreadlegDetails = new SpreadLegDetails(instrument.Key, instrument.GetValidOrderFeeds()[0].ConnectionKey);
                spreadlegDetails.SpreadRatio = (i % 2 == 0) ? 1 : -1;
                spreadlegDetails.PriceMultiplier = (i % 2 == 0) ? 1 : -1;
                spreadlegDetails.CustomerName = "<Default>";

                spreadDetails.Legs.Append(spreadlegDetails);
                i++;
            }

            // Create an Instrument corresponding to the synthetic spread
            casReq = new CreateAutospreaderInstrumentRequest(apiInstance.Session, Dispatcher.Current, spreadDetails);
            casReq.Completed += new EventHandler<CreateAutospreaderInstrumentRequestEventArgs>(casReq_Completed);
            casReq.Submit();
        }
        void CreateAutoSpreader(object sender, InstrumentLookupSubscriptionEventArgs e)
        {
            if (e.Instrument != null && e.Error == null)
            {
                // Instrument was found
                Console.WriteLine("Found: {0}", e.Instrument.Name);

                InstrumentDictionary.Add(e.Instrument.Key, e.Instrument);

                // Update the dictionary to indicate that the instrument was found.
                InstrumentLookupSubscription instrLookupSub = sender as InstrumentLookupSubscription;

                if (SpreadLegKeys.ContainsKey((int)instrLookupSub.Tag))
                {
                    SpreadLegKeys[(int)instrLookupSub.Tag] = e.Instrument;
                }
            }
            else if (e.IsFinal)
            {
                // Instrument was not found and TT API has given up looking for it
                Console.WriteLine("Cannot find instrument: {0}", e.Error.Message);
                Subs.Dispose();
            }

            // If we have found all of the leg instruments, proceed with the creation of the spread.
            if (HaveWeFoundAllLegs())
            {
                Console.WriteLine("All leg instruments have been found.  Creating the spread...");

                // SpreadDetails related properties
                SpreadDetails spreadDetails = new SpreadDetails();
                spreadDetails.Name = AutoSpreaderName;

                for (int i = 0; i < DbTickerList.Count; i++)
                {
                    Instrument instrument = SpreadLegKeys[i + 1];
                    SpreadLegDetails spreadlegDetails = new SpreadLegDetails(instrument, instrument.GetValidOrderFeeds()[0].ConnectionKey);
                    spreadlegDetails.SpreadRatio = (int)RatioAndMultiplier["Ratio"][i];
                    spreadlegDetails.PriceMultiplier = RatioAndMultiplier["Multiplier"][i];
                    spreadlegDetails.CustomerName = "<DEFAULT>";
                    spreadlegDetails.PayupTicks = PayUpTicks;
                    spreadDetails.Legs.Append(spreadlegDetails);
                }

                // Create an AutospreaderInstrument corresponding to the synthetic spread
                Air = new CreateAutospreaderInstrumentRequest(m_apiInstance.Session, Dispatcher.Current, spreadDetails);
                Air.Completed += new EventHandler<CreateAutospreaderInstrumentRequestEventArgs>(m_casReq_Completed);
                Air.Submit();
            }
        }