Exemple #1
0
 def m_req_Update(self, sender, e):
     """ 
      <summary>
      Event notification for instrument lookup
      </summary>
     """
     if e.Instrument != None and e.Error == None:
         # Instrument was found
         print("Found: {0}".format(e.Instrument.Name))
         # Subscribe for Inside Market Data
         self.m_ps = ttapi.PriceSubscription(e.Instrument, ttapi.Dispatcher.Current)
         self.m_ps.Settings = ttapi.PriceSubscriptionSettings(ttapi.PriceSubscriptionType.InsideMarket)
         self.m_ps.FieldsUpdated += self.m_ps_FieldsUpdated
         self.m_ps.Start()
         # Create a TradeSubscription to listen for order / fill events only for orders submitted through it
         self.m_ts = tradebk.InstrumentTradeSubscription(self.m_apiInstance.Session, ttapi.Dispatcher.Current, e.Instrument, True, True, False, False)
         self.m_ts.OrderUpdated += self.m_ts_OrderUpdated
         self.m_ts.OrderAdded += self.m_ts_OrderAdded
         self.m_ts.OrderDeleted += self.m_ts_OrderDeleted
         self.m_ts.OrderFilled += self.m_ts_OrderFilled
         self.m_ts.OrderRejected += self.m_ts_OrderRejected
         self.m_ts.Start()
     elif e.IsFinal:
         # Instrument was not found and TT API has given up looking for it
         print("Cannot find instrument: {0}".format(e.Error.Message))
         self.Dispose()
    def m_req_Update(self, sender, e):
        """
        <summary>
		 Event notification for instrument lookup
		 </summary>
        """
        if e.Instrument != None and e.Error == None:
            # Instrument was found
            print("Found: {0}".format(e.Instrument.Name))
            self.statusbar.Text = "Found: {0}".format(e.Instrument.Name)
            # Subscribe for Inside Market Data
            self.m_ps = ttapi.PriceSubscription(e.Instrument,
                                                ttapi.Dispatcher.Current)
            self.m_ps.Settings = ttapi.PriceSubscriptionSettings(
                ttapi.PriceSubscriptionType.InsideMarket)
            self.m_ps.FieldsUpdated += self.m_ps_FieldsUpdated
            self.m_ps.Start()
        elif e.IsFinal:
            # Instrument was not found and TT API has given up looking for it
            print("Cannot find instrument: {0}".format(e.Error.Message))
            self.statusbar.Text = "Cannot find instrument: {0}".format(
                e.Error.Message)
            self.Dispose()
        else:
            print('Searching Instrument in progress...')
            self.statusbar.Text = 'Searching Instrument in progress...'