Exemple #1
0
        }//TryConvert()

        //
        //
        //
        public static bool TryCreateInstrumentKey(string keyString, out TradingTechnologies.TTAPI.InstrumentKey key)
        {
            key = new TradingTechnologies.TTAPI.InstrumentKey();
            // Assume key has form:   "XXXX PP PPPPP (TYPE) SSSSSSS"
            // Where:
            //  exchange name "XXXX" has NO embedded spaces;
            //  product name "PP PPPPP" CAN have embedded spaces (like "IPE e-Gas Oil");
            //  there are NO extra parentheses, apart from those wrapping the instrument "TYPE"
            string[] parts = keyString.Split(new char[] { ')', '(' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 3)
            {
                return(false);
            }
            // Now we should have something like:  ["ICE_IPE IPE e-Gas Oil ","FUTURE"," 198755"]
            // Extract instrument type and series name from the last two terms.
            string typeStr    = parts[1].Trim();
            string seriesName = parts[2].Trim();
            // Extract product and exchange.
            int n = parts[0].IndexOf(' ');                      // locate the FIRST space, assumed to be after the exchange name.

            if (n < 0 || n >= parts[0].Length)
            {
                return(false);
            }
            string exchange    = parts[0].Substring(0, n).Trim();
            string productName = parts[0].Substring(n + 1, parts[0].Length - (n + 1)).Trim();

            key = new TradingTechnologies.TTAPI.InstrumentKey(exchange, typeStr, productName, seriesName);
            return(true);
        }//TryCreateInstrumentKey()
Exemple #2
0
        public void FindInstrument(TT.InstrumentKey key)
        {
            IList <TT.InstrumentKey> keys = new List <TT.InstrumentKey> {
                key
            };

            FindInstrument(keys);
        }
Exemple #3
0
        }//TryCreateInstrumentKey()

        //
        //
        //
        public static string ToString(TradingTechnologies.TTAPI.InstrumentKey ttKey)
        {
            return(string.Format("{0} ({1}) {2}", ttKey.ProductKey.Name, ttKey.ProductKey.Type, ttKey.SeriesKey));
        }