/// <summary> /// Event notification for AutospreaderInstrument creation /// </summary> public void m_casReq_Completed(object sender, CreateAutospreaderInstrumentRequestEventArgs e) { if (e.Error == null) { if (e.Instrument != null) { // In this example, the AutospreaderInstrument is launched to ASE-A. // You should use the order feed that is appropriate for your purposes. OrderFeed oFeed = this.GetOrderFeedByName(e.Instrument, m_ASEGateway); if (oFeed.IsTradingEnabled) { // deploy the Autospreader Instrument to the specified ASE e.Instrument.TradableStatusChanged += new EventHandler <TradableStatusChangedEventArgs>(Instrument_TradableStatusChanged); LaunchReturnCode lrc = e.Instrument.LaunchToOrderFeed(oFeed); if (lrc != LaunchReturnCode.Success) { Console.WriteLine("Launch request was unsuccessful"); } } } } else { // AutospreaderInstrument creation failed Console.WriteLine("AutospreaderInstrument creation failed: " + e.Error.Message); } }
/// <summary> /// Once the instrument is found launch it to the selected order feed. /// </summary> void instrumentLookupSubscription_Update(object sender, InstrumentLookupSubscriptionEventArgs e) { if (e.IsFinal == true && e.Instrument != null) { if (e.Instrument is AutospreaderInstrument) { string messageString = String.Empty; LaunchReturnCode result = (e.Instrument as AutospreaderInstrument).LaunchToOrderFeed(m_feedDictionary[(string)comboBoxServerList.SelectedItem]); if (result == LaunchReturnCode.Success) { messageString = String.Format("Instrument '{0}' Successfully launched to server.", e.Instrument.Name); } else { messageString = String.Format("Instrument '{0}' could not be launched to server because {1}.", e.Instrument.Name, result.ToString()); } MessageBox.Show(messageString); } } else if (e.IsFinal) { MessageBox.Show(String.Format("Instrument '{0}' could not be found.", e.Instrument.Name)); } }
// // // #endregion//Public Methods #region no Private Methods // ***************************************************************** // **** Private Methods **** // ***************************************************************** // // #endregion//Private Methods #region Event Handlers // ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // private void AutoSpreaderInstrumentRequest_Completed(object sender, CreateAutospreaderInstrumentRequestEventArgs autoSpreaderEventArgs) { if (autoSpreaderEventArgs.Instrument != null) { AutospreaderInstrument m_AutoSpreader = (AutospreaderInstrument)autoSpreaderEventArgs.Instrument; LaunchReturnCode launchReturnCode = m_AutoSpreader.LaunchToOrderFeed(m_AutoSpreader.GetValidOrderFeeds()[0]); // launch to whatever orderfeed we find first if (launchReturnCode == LaunchReturnCode.Success) { m_AutoSpreader.TradableStatusChanged += new EventHandler <TradableStatusChangedEventArgs>(AutoSpreaderInstrument_TradeableStatusChanged); } } }
private void SendLimitOrder(BuySell buySell, int qty, double price) { OrderFeed feed = GetOrderFeed(); LaunchReturnCode lrc = SpreadInstrument.LaunchToOrderFeed(feed); if (lrc == LaunchReturnCode.Success) { AutospreaderSyntheticOrderProfile prof = new AutospreaderSyntheticOrderProfile(feed, SpreadInstrument); prof.BuySell = buySell; prof.OrderQuantity = Quantity.FromInt(SpreadInstrument, qty); prof.OrderType = OrderType.Limit; prof.LimitPrice = Price.FromDouble(SpreadInstrument, price); if (!SpreadInstrument.Session.SendOrder(prof)) { Console.WriteLine("send order failed: {0}", prof.RoutingStatus.Message); } } }