Gets the array sorted by name, with names of all available Instrument.


SYNTAX


public string[] GetSortedInstrumentNames (bool onlyTradable)


PARAMETERS


onlyTradable — bool
true if you want return array with only currently tradable instruments.


RETURN


string[] returns an array of available Instrument name.


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);
         }
     }
 }