Gets an Instrument that represents the access to instrument objects specifiedby by instrument symbol, route and expiration date.


SYNTAX


public Instrument GetInstrument (string symbol,string route,DateTime expirationDate)


PARAMETERS


symbol — string
instrument symbol.


route — string
instrument route.


expirationDate — DateTime
time and the day that a particular delivery month of a derivative contract stops trading, as well as the final settlement price for that contract.


RETURN


Instrument an object that represents Instrument.


EXAMPLE


 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 using System.Drawing;
 using PTLRuntime.NETScript;

 namespace InstrumentsCollection_
 {
     public class InstrumentsCollection_ : NETStrategy
     {
         int QuoteCounter = 0,
         TradeCounter = 0,
         Level2Counter = 0,
         MaintCount = 0;

         Instrument instr;
         Instrument[] instrArray, instrSortArray;
         string[] instrNames;

         int index = 10;

         public override void Init()
         {
             Instruments.NewTrade += OnTrade; 
             Instruments.NewQuote += OnQuote2; 
             Instruments.NewLevel2 += OnLevel2; 

             Instruments.InstrumentAdded += OnInstrumentAdd;

             instr = Instruments.Current; 
             Alert("Current instrument is: " + instr.Name);

             Instruments.Subscribe(instr, QuoteTypes.Trade); 
             Instruments.Subscribe(instr, QuoteTypes.Quote);
             Instruments.Subscribe(instr, QuoteTypes.Level2);

             instrArray = Instruments.GetInstruments();
             instrSortArray = Instruments.GetSortedInstruments();
             instrNames = Instruments.GetSortedInstrumentNames();

             Print(index + " instrument name in unsorte instrument name array is " + Instruments.GetInstrument(instrNames[index]).Name);
             Print(index + " instrument name in unsorted instrument array is " + Instruments.GetInstrument(instrArray[index].Symbol, instrArray[index].Route).Name);
             Print(index + " instrument name in sorted instrument array is " + Instruments.GetInstrument(instrSortArray[index].Symbol, instrSortArray[index].Route).Name);

             foreach (Instrument i in instrArray)
             {
                 if (i.Type == InstrumentType.Future)
                 {
                     instr = Instruments.GetInstrument(i.Symbol, i.Route, i.GetDerivativeSettings().ContractMonthDate);
                     Alert(instr.Name);
                 }
             }
         }

         private void OnQuote2(Instrument instr, Quote quote)
         {
             QuoteCounter++;
         }

         private void OnLevel2(Instrument instr, Level2 level2)
         {
             Level2Counter++;
         }

         private void OnTrade(Instrument instr, Trade trade)
         {
             TradeCounter++;
         }

         private void OnInstrumentAdd(Instrument instr)
         {
             Print("Add new instrument on server");
         }

         public override void OnQuote()
         {
             MaintCount++;
             Comment("#LVL1: " + QuoteCounter + "\t#LVL2: " + Level2Counter + "\t#LVL3: " + TradeCounter + "\t#OnQuote: " + MaintCount);
         }

         public override void Complete()
         {
             Instruments.NewTrade -= OnTrade;
             Instruments.NewQuote -= OnQuote2;
             Instruments.NewLevel2 -= OnLevel2;

             Instruments.InstrumentAdded -= OnInstrumentAdd;

             Instruments.Unsubscribe(instr, QuoteTypes.Trade);
             Instruments.Unsubscribe(instr, QuoteTypes.Quote);
             Instruments.Unsubscribe(instr, QuoteTypes.Level2);
         }
     }
 }