Skip to content

Commit 1602415

Browse files
committed
Merge pull request tradingtechnologies#2 from tradingtechnologies/feature/DEB-22310
Fixed OrderFilter Sample
2 parents c378fd0 + fd228e8 commit 1602415

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

CodeSamples_TTAPI_CSharp.suo

-553 KB
Binary file not shown.

TTAPI/C#/7.17.x/OrderFilter/frmOrderFilter.cs

+16-9
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,6 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
247247
this.txtProductType.Text = e.Instrument.Product.Type.ToString();
248248
this.txtContract.Text = e.Instrument.GetFormattedName(InstrumentNameFormat.User);
249249

250-
if (m_instrumentTradeSubscription != null)
251-
{
252-
m_instrumentTradeSubscription.Dispose();
253-
m_instrumentTradeSubscription = null;
254-
}
255-
256250
// populate the order feed dropdown
257251
this.cboOrderFeed.Items.Clear();
258252
foreach (OrderFeed orderFeed in e.Instrument.GetValidOrderFeeds())
@@ -261,9 +255,7 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
261255
this.cboOrderFeed.SelectedIndex = 0;
262256

263257
// This sample will monitor new orders and deleting working orders
264-
m_instrumentTradeSubscription = new InstrumentTradeSubscription(m_TTAPI.Session, Dispatcher.Current, e.Instrument);
265-
m_instrumentTradeSubscription.OrderAdded += new EventHandler<OrderAddedEventArgs>(instrumentTradeSubscription_OrderAdded);
266-
m_instrumentTradeSubscription.OrderDeleted += new EventHandler<OrderDeletedEventArgs>(instrumentTradeSubscription_OrderDeleted);
258+
CreateInstrumentTradeSubscription(e.Instrument);
267259
m_instrumentTradeSubscription.Start();
268260
}
269261
catch (Exception err)
@@ -281,6 +273,19 @@ void instrRequest_Completed(object sender, InstrumentLookupSubscriptionEventArgs
281273
}
282274
}
283275

276+
private void CreateInstrumentTradeSubscription(Instrument instrument)
277+
{
278+
if (m_instrumentTradeSubscription != null)
279+
{
280+
m_instrumentTradeSubscription.Dispose();
281+
m_instrumentTradeSubscription = null;
282+
}
283+
284+
m_instrumentTradeSubscription = new InstrumentTradeSubscription(m_TTAPI.Session, Dispatcher.Current, instrument);
285+
m_instrumentTradeSubscription.OrderAdded += new EventHandler<OrderAddedEventArgs>(instrumentTradeSubscription_OrderAdded);
286+
m_instrumentTradeSubscription.OrderDeleted += new EventHandler<OrderDeletedEventArgs>(instrumentTradeSubscription_OrderDeleted);
287+
}
288+
284289
#endregion
285290

286291
#region InstrumentTradeSubscription Updates
@@ -393,6 +398,8 @@ private void btnApplyOrderFilter_Click(object sender, EventArgs e)
393398
if (m_instrumentTradeSubscription == null)
394399
return;
395400

401+
CreateInstrumentTradeSubscription(m_instrumentTradeSubscription.Instrument);
402+
396403
// no filter to set, return
397404
if (this.cboFilter1.SelectedIndex < 0)
398405
return;

0 commit comments

Comments
 (0)