コード例 #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();
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructor for a new SpreadDetailsForm.
        /// </summary>
        /// <param name="session">Session</param>
        /// <param name="dispatcher">Dispatcher</param>
        public SpreadDetailsForm(Session session, Dispatcher dispatcher)
        {
            InitializeComponent();

            m_isNewSpread = true;
            m_session = session;
            m_dispatcher = dispatcher;
            m_spreadDetails = new SpreadDetails();
            initFields();
        }
コード例 #3
0
        /// <summary>
        /// Constructor for a new SpreadDetailsForm.
        /// </summary>
        /// <param name="session">Session</param>
        /// <param name="dispatcher">Dispatcher</param>
        public SpreadDetailsForm(Session session, Dispatcher dispatcher)
        {
            InitializeComponent();

            m_isNewSpread   = true;
            m_session       = session;
            m_dispatcher    = dispatcher;
            m_spreadDetails = new SpreadDetails();
            initFields();
        }
コード例 #4
0
        /// <summary>
        /// Constructor for a SpreadDetailsForm from an existing SpreadDetails definition.
        /// </summary>
        /// <param name="session">Session</param>
        /// <param name="dispatcher">Dispatcher</param>
        /// <param name="spreadDetails">SpreadDetails</param>
        public SpreadDetailsForm(Session session, Dispatcher dispatcher, SpreadDetails spreadDetails)
        {
            InitializeComponent();

            m_isNewSpread   = false;
            m_session       = session;
            m_dispatcher    = dispatcher;
            m_spreadDetails = spreadDetails;
            initFields();
        }
コード例 #5
0
        /// <summary>
        /// Constructor for a SpreadDetailsForm from an existing SpreadDetails definition.
        /// </summary>
        /// <param name="session">Session</param>
        /// <param name="dispatcher">Dispatcher</param>
        /// <param name="spreadDetails">SpreadDetails</param>
        public SpreadDetailsForm(Session session, Dispatcher dispatcher, SpreadDetails spreadDetails)
        {
            InitializeComponent();

            m_isNewSpread = false;
            m_session = session;
            m_dispatcher = dispatcher;
            m_spreadDetails = spreadDetails;
            initFields();
        }
コード例 #6
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();
            }
        }
コード例 #7
0
        /// <summary>
        /// Launch an autospreader instrument to a selected order server.
        /// First find the instrument then launch it to the selected order feed.
        /// </summary>
        private void buttonLaunch_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;

            if (selectedCells.Count > 0)
            {
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                InstrumentLookupSubscription instrumentLookupSubscription = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, currentSpreadDetails.InstrumentKey);
                instrumentLookupSubscription.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(instrumentLookupSubscription_Update);
                instrumentLookupSubscription.Start();
            }
        }
コード例 #8
0
        void DeleteSpread(Instrument instrument)
        {
            // delete
            ASReturnCodes rtnCode;

            Console.WriteLine("Delete the SPREAD");
            SpreadDetails spread = instrument.GetSpreadDetails();

            // Delete the spread from TT system.
            //  Parameter spreadReq: SpreadDetails object representing the spread to delete
            //  Return rtnCode: ASReturnCodes enum indicating the status of the request
            rtnCode = AutospreaderManager.DeleteSpreadDetails(spread);
            System.Diagnostics.Debug.Assert(rtnCode == ASReturnCodes.Success);
        }
コード例 #9
0
        /// <summary>
        /// Delete an existing spread.
        /// </summary>
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;

            if (selectedCells.Count > 0)
            {
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                ASReturnCodes returnCode = m_autospreaderManager.DeleteSpreadDetails(currentSpreadDetails);
                if (returnCode != ASReturnCodes.Success)
                {
                    MessageBox.Show("Delete spread definition failed: " + returnCode.ToString());
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Edit an existing spread.
        /// </summary>
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;

            if (selectedCells.Count > 1)
            {
                // First get the current spread details.
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                // Make a copy of the spread details so that it can be reverted if necessary.
                SpreadDetails copyOfSpreadDetails = m_autospreaderManager.GetSpreadDetails(currentSpreadDetails.InstrumentKey);

                // Create a new spread details form with the spread details copy.
                SpreadDetailsForm spreadDetailsForm = new SpreadDetailsForm(m_TTAPI.Session, Dispatcher.Current, copyOfSpreadDetails);
                spreadDetailsForm.ShowDialog();
            }
        }
コード例 #11
0
        Instrument CreateSpread()
        {
            string aseName = "ASE.Test." + DateTime.Now.ToString("yyyyMMddhhmmss");

            Console.WriteLine("Create a new SPREAD " + aseName);
            var spreadReq = new SpreadDetails(aseName)
            {
                Color        = Color.GreenYellow,
                PricingModel = PricingModel.NetChange
            };

            // first leg
            var inst1 = FindInstrument(m_product, m_alias1);
            var leg1  = new SpreadLegDetails(inst1, 5, 8.5M)
            {
                ActiveQuoting    = true,
                IsLeanIndicative = false,
                MinLeanQty       = "ThisLeg.DisclosedRemainingQuantity"
            };

            spreadReq.AppendLeg(leg1);

            // second leg
            var inst2 = FindInstrument(m_product, m_alias2);
            var leg2  = new SpreadLegDetails(inst2, -1, -2)
            {
                ActiveQuoting    = true,
                IsLeanIndicative = true,
                MinLeanQty       = "ThisLeg.DisclosedRemainingQuantity"
            };

            spreadReq.AppendLeg(leg2);

            // Add a spread to the spread manager and Save the ASE instrument in TT system.
            //  Parameter spreadReq: SpreadDetails object representing the spread to add
            //  Parameter rtnCode: ASReturnCodes enum indicating the status of the request
            ASReturnCodes rtnCode;
            Instrument    newInst = AutospreaderManager.AddSpreadDetails(spreadReq, out rtnCode);

            System.Diagnostics.Debug.Assert(rtnCode == ASReturnCodes.Success);
            Console.WriteLine($"   New ASE instrument is created {newInst.InstrumentDetails.Name}: {newInst.InstrumentDetails.Id}/{newInst.InstrumentDetails.Version}");
            return(newInst);
        }
コード例 #12
0
        /// <summary>
        /// Rename an existing spread.
        /// </summary>
        private void buttonRename_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection selectedCells = dataGridViewSpreadView.SelectedCells;

            if (selectedCells.Count > 0)
            {
                SpreadDetails currentSpreadDetails = ((MutableSpreadDetails)selectedCells[0].OwningRow.DataBoundItem).SpreadDetails;

                string newName = currentSpreadDetails.Name;
                if (InputDialog.InputDialogBox("Rename", "Please enter a new spread name.", ref newName) == System.Windows.Forms.DialogResult.OK)
                {
                    ASReturnCodes returnCode = m_autospreaderManager.RenameSpreadDetails(currentSpreadDetails, newName);
                    if (returnCode != ASReturnCodes.Success)
                    {
                        MessageBox.Show("Rename spread definition failed: " + returnCode.ToString());
                    }
                }
            }
        }
コード例 #13
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);
        }
コード例 #14
0
        Instrument UpdateSpread(Instrument instrument)
        {
            // update
            ASReturnCodes rtnCode;

            Console.WriteLine("Update the new created SPREAD");
            SpreadDetails spreadReq = instrument.GetSpreadDetails();

            spreadReq.UserDefinedDenominator = 20;
            spreadReq.UserDefinedNumerator   = 1;
            var legChange = spreadReq.GetLeg(1);

            legChange.PriceMultiplier = -3;
            spreadReq.Updateleg(1, legChange);

            // Update the spread to the spread manager and Save the ASE instrument in TT system.
            //  Parameter spreadReq: SpreadDetails object representing the spread to update
            //  Parameter rtnCode: ASReturnCodes enum indicating the status of the request
            var updatedInst = AutospreaderManager.UpdateSpreadDetails(spreadReq, out rtnCode);

            System.Diagnostics.Debug.Assert(rtnCode == ASReturnCodes.Success);

            return(updatedInst);
        }
コード例 #15
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];
                    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();
            }
        }
コード例 #16
0
        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();
        }
コード例 #17
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();
            }
        }
コード例 #18
0
 public MutableSpreadDetails(SpreadDetails details)
 {
     SpreadDetails = details;
     Name          = SpreadDetails.Name;
 }
コード例 #19
0
 public MutableSpreadDetails(SpreadDetails details)
 {
     SpreadDetails = details;
     Name = SpreadDetails.Name;
 }