/// <summary> /// This method checks whether the two instrument keys are equal. /// </summary> /// <param name="key1"></param> /// <param name="key2"></param> /// <returns></returns> public static bool IsTwoInstrumentEqual(TradingTechnologies.TTAPI.InstrumentKey key1, TradingTechnologies.TTAPI.InstrumentKey key2) { string keyString1 = TTConvert.ToString(key1); string keyString2 = TTConvert.ToString(key2); return(keyString1.Equals(keyString2)); }
// // // // // 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()
public void SetAttributes(Dictionary <string, string> attributes) { this.Fill = new UV.Lib.OrderHubs.Fill(); ((IStringifiable)this.Fill).SetAttributes(attributes); FillType type; TradingTechnologies.TTAPI.InstrumentKey ttInstrumentKey; foreach (string key in attributes.Keys) { if (key == "Type" && Enum.TryParse <FillType>(attributes[key], out type)) { this.Type = type; } else if (key == "InstrumentKey" && TTConvert.TryCreateInstrumentKey(attributes[key], out ttInstrumentKey)) { this.TTInstrumentKey = ttInstrumentKey; } else if (key == "FillKey") { this.FillKey = attributes[key]; } } }
public FillEventArgs(TradingTechnologies.TTAPI.InstrumentKey ttKey, FillType fillType, UV.Lib.OrderHubs.Fill theFill) { this.TTInstrumentKey = ttKey; this.Type = fillType; this.Fill = theFill; }
/// <summary> /// Check whether the instrument key already exist. /// </summary> /// <param name="instrumentKey"></param> /// <returns></returns> public static bool CheckExistenceOfInstrumentKey(List <TradingTechnologies.TTAPI.InstrumentKey> keyList, TradingTechnologies.TTAPI.InstrumentKey instrumentKey) { foreach (TradingTechnologies.TTAPI.InstrumentKey key in keyList) { if (IsTwoInstrumentEqual(key, instrumentKey)) { return(true); } } return(false); }
}//TryCreateInstrumentKey() // // // public static string ToString(TradingTechnologies.TTAPI.InstrumentKey ttKey) { return(string.Format("{0} ({1}) {2}", ttKey.ProductKey.Name, ttKey.ProductKey.Type, ttKey.SeriesKey)); }