private void GetIDNOthers(string item, Dictionary <string, List <string> > dicList) { try { string pattern = @"(?<RIC>[0-9A-Z]+\.OS)\s+PROV_SYMB\s+(?<PROV_SYMB>[0-9\-]+)"; string fids = "PROV_SYMB"; GatsUtil gats = new GatsUtil(); //string response = gats.GetGatsResponse(item, "PROD_PERM"); string response = gats.GetGatsResponse(item, fids); Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); string ric = string.Empty; foreach (Match match in matches) { ric = match.Groups["RIC"].Value.ToString().Trim(); List <string> list = new List <string>(); list.Add(ric); list.Add(match.Groups["PROV_SYMB"].Value.ToString().Trim()); dicList.Add(ric, list); } } catch (Exception ex) { string msg = string.Format("get exist ric in the gats error.:{0}", ex.ToString()); Logger.Log(msg, Logger.LogType.Error); return; } }
/// <summary> /// /// </summary> /// <param name="rics"></param> /// <returns></returns> private List <string> FindOpint(string rics) { GatsUtil gats = new GatsUtil(); List <string> gatsValues = new List <string>(); Regex rgxSpace = new Regex(@"\s+"); try { string[] stringSeparators = { "\r\n" }; char[] stringSeparators2 = { ' ' }; string test = gats.GetGatsResponse(rics, "OPINT_1"); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); gatsValues.AddRange(from line in lines select rgxSpace.Replace(line, " ") into formattedLine select formattedLine.Split(stringSeparators2) into lineTab where lineTab.Length > 2 && lineTab[2] == "0" select lineTab[0]); return(gatsValues); } catch (Exception ex) { throw new Exception("Error While using Gats: " + ex.Message); } }
private void GetRicFromGATS(string strQuery, string pattern, List <string> list) { try { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strQuery, "PROD_PERM");//******************* Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); string tmp = string.Empty; foreach (Match match in matches) { if (list.Contains(match.Groups["RIC"].Value.ToString().Trim())) { continue; } list.Add(match.Groups["RIC"].Value.ToString().Trim()); } } catch (Exception ex) { string msg = string.Format("get exist ric in the gats error.:{0}", ex.ToString()); Logger.Log(msg, Logger.LogType.Error); return; } }
/// <summary> /// GetDataFromEIKONToEIKONEntity /// </summary> /// <param name="par">GATS param</param> /// <param name="listEIKON"></param> private void GetDataFromEIKONToEIKONEntity(string par, List <EIKONEntity> listEIKON) { try { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(par, null); const string startStr = "ROW80_3"; response = response.Substring(response.IndexOf(startStr)); const string pattern = "ROW80_.*?<(?<RIC>[A-Z.]+)> +(?<DisplayName>[A-Z0-9-.& ]+) +.*?(?<Ratio>\\d+:\\d+).*?\\r\\n"; Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); foreach (Match match in matches) { EIKONEntity ei = new EIKONEntity(); string tmpRIC = match.Groups["RIC"].Value; ei.ADRRIC = tmpRIC.Substring(0, tmpRIC.IndexOf(".")); string tmpDis = match.Groups["DisplayName"].Value; ei.DISPLAYNAME = tmpDis.Substring(0, tmpDis.IndexOf(" ")); ei.RatioFromEIKON = match.Groups["Ratio"].Value; listEIKON.Add(ei); } } catch (Exception ex) { Logger.Log(string.Format("Error found during task: {0}. Exception message: {1}", "Error generated by GetDataFromEIKONToEIKONEntity", ex.Message)); } }
private void GetIDNIFFM(string item, Dictionary <string, string> dicLot, Dictionary <string, List <string> > dicList) { try { string pattern = @"(?<RIC>[0-9A-Z]+\.OS)\s+EXPIR_DATE\s+(?<EXPIR_DATE>[0-9]{1,2}\s*[A-Z]+\s*[0-9]{2,4})\r\n[0-9A-Z]+\.OS\s+PROV_SYMB\s+(?<PROV_SYMB>[0-9\-]+)"; string fids = "EXPIR_DATE,PROV_SYMB"; GatsUtil gats = new GatsUtil(); //string response = gats.GetGatsResponse(item, "PROD_PERM"); string response = gats.GetGatsResponse(item, fids); Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); string ric = string.Empty; foreach (Match match in matches) { ric = match.Groups["RIC"].Value.ToString().Trim(); List <string> list = new List <string>(); list.Add(ric); list.Add(FormatExpirDate(match.Groups["EXPIR_DATE"].Value.ToString().Trim())); list.Add(dicLot.ContainsKey(ric) ? dicLot[ric].Replace(".00", "").Replace(".0", "") : " "); list.Add(match.Groups["PROV_SYMB"].Value.ToString().Trim()); dicList.Add(ric, list); } } catch (Exception ex) { string msg = string.Format("get exist ric in the gats error.:{0}", ex.ToString()); Logger.Log(msg, Logger.LogType.Error); return; } }
private List <string> QueryGatsByGroup(string rics) { GatsUtil gats = new GatsUtil(); List <string> gatsValues = new List <string>(); Regex rgxSpace = new Regex(@"\s+"); Regex rgxLongLink = new Regex(@"^LONGLINK", RegexOptions.IgnoreCase); try { string[] stringSeparators = { "\r\n" }; char[] stringSeparators2 = { ' ' }; string test = gats.GetGatsResponse(rics, ""); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); gatsValues.AddRange(from line in lines select rgxSpace.Replace(line, " ") into formattedLine select formattedLine.Split(stringSeparators2) into lineTab where lineTab.Length > 2 && rgxLongLink.IsMatch(lineTab[1]) && lineTab[2] != "" && !lineTab[2].EndsWith(".TW") && !lineTab[2].EndsWith("sp.TM") select lineTab[2]); return(gatsValues); } catch (Exception ex) { LogMessage("Error in QueryGatsByGroup", Logger.LogType.Error); throw new Exception("Error While using Gats: " + ex.Message); } }
private void GetDataFromGATS(string strQuery, List <List <string> > listListRic, string strPatternGATS) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strQuery, "PROV_SYMB,OFFCL_CODE"); if (!string.IsNullOrEmpty(response)) { Regex regex = new Regex(strPatternGATS); MatchCollection matches = regex.Matches(response); string ric = string.Empty; string prov = string.Empty; string off = string.Empty; foreach (Match match in matches) { ric = match.Groups["RIC"].Value; prov = match.Groups["PROV_SYMB"].Value; off = match.Groups["OFFCL_CODE"].Value; List <string> li = new List <string>(); li.Add(ric); li.Add(prov); li.Add(off); listListRic.Add(li); } } else { Logger.Log("Too many ric"); throw new Exception("Input too many RICs a time,GATS dead. "); } }
/// <summary> /// Find TAX_ELIGBL fids in GATS from given Rics /// </summary> /// <param name="rics"></param> /// <returns></returns> private Dictionary <string, string> QueryGats(string rics) { var gats = new GatsUtil(GatsUtil.Server.Elektron); var gatsValues = new Dictionary <string, string>(); var rgxSpace = new Regex(@"\s+"); try { string[] stringSeparators = { "\r\n" }; char[] stringSeparators2 = { ' ' }; string test = gats.GetGatsResponse(rics, "TAX_ELIGBL"); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); foreach (string[] lineTab in lines.Select(line => rgxSpace.Replace(line, " ")) .Select(formattedLine => formattedLine.Split(stringSeparators2)) .Where(lineTab => lineTab.Length > 2 && lineTab[2] != "").Where(lineTab => !gatsValues.ContainsKey(lineTab[0].Trim()))) { gatsValues.Add(lineTab[0].Trim(), lineTab[2].Trim()); } return(gatsValues); } catch (Exception ex) { LogMessage("Error in QueryGats", Logger.LogType.Error); throw new Exception("Error While using Gats: " + ex.Message); } }
private void GetGatsData() { idnDic = new Dictionary <string, ReutersIdnInfo>(); string rics = string.Join(",", (from p in ipos select p.RIC).ToArray()); string fids = "OFFCL_CODE,BCAST_REF,DSPLY_NAME"; GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(rics, fids); if (string.IsNullOrEmpty(response)) { //No result from gats. return; } foreach (var ipo in ipos) { if (!response.Contains(ipo.RIC)) { continue; } ReutersIdnInfo idn = new ReutersIdnInfo(); string offclPattern = string.Format("{0} +OFFCL_CODE +(?<OfficalCode>.*?)\r\n", ipo.RIC); string bcastPattern = string.Format("{0} +BCAST_REF +(?<BcastRef>.*?)\r\n", ipo.RIC); string diaplayPattern = string.Format("{0} +DSPLY_NAME +(?<DisplayName>.*?)\r\n", ipo.RIC); Regex r = new Regex(offclPattern); Match m = r.Match(response); if (m.Success) { idn.OffclCode = m.Groups["OfficalCode"].Value.Trim(); } r = new Regex(bcastPattern); m = r.Match(response); if (m.Success) { idn.BcastRef = m.Groups["BcastRef"].Value.Trim(); } r = new Regex(diaplayPattern); m = r.Match(response); if (m.Success) { idn.DsplyName = m.Groups["DisplayName"].Value.Trim(); } idnDic.Add(ipo.Ticker, idn); } }
private void GetDataFromGATSToExistDic(string strGats, Dictionary <string, string> dicExist) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strGats, null); Regex regex = new Regex(strPatternValue); MatchCollection matches = regex.Matches(response); foreach (Match match in matches.Cast <Match>().Where(match => !dicExist.ContainsKey(match.Groups["RIC"].Value))) { dicExist.Add(match.Groups["RIC"].Value, match.Groups["Value"].Value); } }
private void GetDataFromGATSToList(string strGats, List <string> list) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strGats, null); Regex regex = new Regex(strPatternRIC); MatchCollection matches = regex.Matches(response); foreach (Match match in matches.Cast <Match>().Where(match => !list.Contains(match.Groups["RIC"].Value))) { list.Add(match.Groups["RIC"].Value); } }
/// <summary> /// GetDataFromGATSToExistList /// </summary> /// <param name="pattern">Regex</param> /// <param name="rics">Parms</param> /// <param name="fids">Parms</param> /// <param name="listExist">Store Data From GATS</param> private void GetDataFromGATSToExistList(string pattern, string rics, string fids, List <string> listExist) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(rics, fids); Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); foreach (Match match in matches) { listExist.Add(match.Groups["RIC"].Value); } }
/// <summary> /// GetDataFromGATSToExistDic /// </summary> /// <param name="pattern">Regex</param> /// <param name="rics">Parms</param> /// <param name="fids">Parms</param> /// <param name="dicExist">Store Data From GATS</param> private void GetDataFromGATSToExistDic(string pattern, string rics, string fids, Dictionary <string, string> dicExist) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(rics, fids); Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); foreach (Match match in matches) { if (!dicExist.ContainsKey(match.Groups["RIC"].Value)) { dicExist.Add(match.Groups["RIC"].Value, match.Groups["Value"].Value); } } }
private string GetIssueQuantity(string str, string qua) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(str + ".HK", "AMT_ISSUE"); Regex regex = new Regex(@"AMT_ISSUE\s+(?<value>\d+)"); MatchCollection matches = regex.Matches(response); if (matches.Count > 0) { return((Convert.ToInt32(qua) + Convert.ToInt32(matches[0].Groups["value"].Value)).ToString()); } else { return(str + "+No Issue In IDN"); } }
private string GetISIN(string str) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(str + ".HK", "ISIN_CODE"); Regex regex = new Regex(@"ISIN_CODE\s+(?<value>[0-9A-Z]+)"); MatchCollection matches = regex.Matches(response); if (matches.Count > 0) { return(matches[0].Groups["value"].Value); } else { return("No ISIN In IDN"); } }
/// <summary> /// GetDataToDicFromGATS /// </summary> /// <param name="strQuery">input ric chain to gats</param> /// <param name="dicFromGATS">dic</param> /// <param name="strPatternGATS">pattern</param> private void GetDataFromGATSToExistDic(string strQuery, Dictionary <string, string> dicFromGATS, string strPatternGATS) { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strQuery, "PROD_PERM"); Regex regex = new Regex(strPatternGATS); MatchCollection matches = regex.Matches(response); string tmp = string.Empty; foreach (Match match in matches) { tmp = match.Groups["Ric"].Value; if (!dicFromGATS.ContainsKey(tmp)) { dicFromGATS.Add(match.Groups["Ric"].Value, match.Groups["Value"].Value); } } }
/// <summary> /// Query GATS to find DSPLY_NAME fids from rics /// </summary> /// <param name="rics"></param> /// <returns></returns> private Dictionary <string, string> QueryGats(string rics) { GatsUtil gats = new GatsUtil(GatsUtil.Server.Idn); Dictionary <string, string> gatsValues = new Dictionary <string, string>(); Regex rgxSpace = new Regex(@"\s+"); Regex rgxPre = new Regex(@"^DSPLY_NAME", RegexOptions.IgnoreCase); try { string[] stringSeparators = new string[] { "\r\n" }; char[] stringSeparators2 = new char[] { ' ' }; string test = gats.GetGatsResponse(rics, "DSPLY_NAME"); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); foreach (string line in lines) { string formattedLine = rgxSpace.Replace(line, " "); string[] lineTab = formattedLine.Split(stringSeparators2); if (lineTab.Length > 2 && rgxPre.IsMatch(lineTab[1]) && lineTab[2] != "") { if (!gatsValues.ContainsKey(lineTab[0].Trim())) { string tmpName = ""; for (int i = 0; i < lineTab.Count(); i++) { if (i >= 2) { tmpName += lineTab[i] + " "; } } gatsValues.Add(lineTab[0].Trim(), tmpName.Trim()); } } } return(gatsValues); } catch (Exception ex) { Logger.Log("Error in QueryGats", Logger.LogType.Error); throw new Exception("Error While using Gats: " + ex.Message); } }
private Dictionary <string, string> GetDbList(Dictionary <string, string> sectors) { string gatsRics = String.Empty; foreach (var indice in from sector in sectors from indice in sector.Value.Split(new[] { ',' }, StringSplitOptions.None) where !gatsRics.Contains(indice.Trim()) select indice) { for (int index = 0; index < 80; index++) { gatsRics += String.Format("{0}#{1},", index, indice.Trim()); } } var gats = new GatsUtil(GatsUtil.Server.Idn); var gatsValues = new Dictionary <string, string>(); var rgxSpace = new Regex(@"\s+"); var rgxPre = new Regex(@"^LINK_", RegexOptions.IgnoreCase); string[] stringSeparators = { "\r\n" }; char[] stringSeparators2 = { ' ' }; string test = gats.GetGatsResponse(gatsRics, "LINK_1,LINK_2,LINK_3,LINK_4,LINK_5,LINK_6,LINK_7,LINK_8,LINK_9,LINK_10,LINK_11,LINK_12,LINK_13,LINK_14"); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); foreach (string[] lineTab in lines.Select(line => rgxSpace.Replace(line, " ")) .Select(formattedLine => formattedLine.Split(stringSeparators2)) .Where(lineTab => lineTab.Length > 2 && rgxPre.IsMatch(lineTab[1]) && lineTab[2] != "" && !lineTab[2].StartsWith("."))) { if (!gatsValues.ContainsKey(lineTab[2].Trim())) { gatsValues.Add(lineTab[2].Trim(), lineTab[0].Trim().Substring(lineTab[0].Trim().IndexOf("#") + 1)); } else { gatsValues[lineTab[2].Trim()] += "," + lineTab[0].Trim().Substring(lineTab[0].Trim().IndexOf("#") + 1); } } return(gatsValues); }
private void GetIFFMLotFromIDN(string item, Dictionary <string, string> dic) { try { string pattern = @"(?<RIC>[0-9A-Z]+\.OS)\s+LOT_SIZE_A\s+(?<LOT>[0-9\.]+)"; string fids = "LOT_SIZE_A"; GatsUtil gats = new GatsUtil(); //string response = gats.GetGatsResponse(item, "PROD_PERM"); string response = gats.GetGatsResponse(item, fids); Regex regex = new Regex(pattern); MatchCollection matches = regex.Matches(response); string ric = string.Empty; string lot = string.Empty; string ricL = string.Empty; foreach (Match match in matches) { ric = match.Groups["RIC"].Value.ToString().Trim(); lot = match.Groups["LOT"].Value.ToString().Trim(); if (!dic.ContainsKey(ric)) { dic.Add(ric, lot); } ricL = ric.Insert(4, "L"); if (!dic.ContainsKey(ricL)) { dic.Add(ricL, lot); } } } catch (Exception ex) { string msg = string.Format("get exist ric in the gats error.:{0}", ex.ToString()); Logger.Log(msg, Logger.LogType.Error); return; } }
/// <summary> /// /// </summary> /// <param name="rics"></param> /// <returns></returns> private Dictionary <string, List <string> > QueryGatsDisplayName(string rics) { GatsUtil gats = new GatsUtil(); Dictionary <string, List <string> > gatsValues = new Dictionary <string, List <string> >(); Regex rgxSpace = new Regex(@"\s+"); try { string[] stringSeparators = { "\r\n" }; char[] stringSeparators2 = { ' ' }; string test = gats.GetGatsResponse(rics, "DSPLY_NAME,OPINT_1"); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); foreach (string[] lineTab in lines .Select(line => rgxSpace.Replace(line, " ")) .Select(formattedLine => formattedLine.Split(stringSeparators2)) .Where(lineTab => lineTab.Length > 2 && lineTab[2] != "")) { if (!gatsValues.ContainsKey(lineTab[0])) { gatsValues.Add(lineTab[0], new List <string>()); } string toAdd = ""; for (int count = 2; count < lineTab.Length; count++) { toAdd += lineTab[count] + " "; } gatsValues[lineTab[0]].Add(toAdd.TrimEnd()); } return(gatsValues); } catch (Exception ex) { LogMessage("Error while using Gats", Logger.LogType.Error); throw new Exception("Error While using Gats: " + ex.Message); } }
private void GetDataFromGATSTolistIDNTGOBulTGTM(string strTGTM, string patternTGTM, Dictionary <string, IDNTGOBulk> dicIDNTGOBulkTGTM) { try { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strTGTM, null); IDNTGOBulk idntgobulk = null; Regex regex = new Regex(patternTGTM); MatchCollection matches = regex.Matches(response); foreach (Match match in matches) { idntgobulk = new IDNTGOBulk(); idntgobulk.RIC = match.Groups["RIC"].Value; if (!dicIDNTGOBulkTGTM.ContainsKey(idntgobulk.RIC)) { dicIDNTGOBulkTGTM.Add(idntgobulk.RIC, idntgobulk); } } } catch (Exception e) { LogMessage("error happened : " + e.Message, Logger.LogType.Error); } }
private List <HolidayInfo> GetHolidayInfoFromGats() { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(configObj.QueryCommand.ToUpper(), ""); if (string.IsNullOrEmpty(response)) { string msg = "Can't get holiday information, please check your command."; Logger.Log(msg, Logger.LogType.Error); throw new Exception(msg); } Logger.Log("Get holiday information by GATS. OK!"); //TaskResultList.Add(new TaskResultEntry("Holiday Infomation", "Holiday Infomation", outputPath)); List <HolidayInfo> holiday = new List <HolidayInfo>(); //string[] content = File.ReadAllLines(outputPath); string[] content = response.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string year = string.Empty; int startLine = 0; for (int i = 0; i < content.Length; i++) { string row = content[i]; if (row.Contains("DATES") && row.Contains("MARKET HOLIDAY")) { year = Regex.Match(row, @"\d{4}").Value; startLine = i + 1; break; } } for (int i = startLine; i < content.Length; i++) { List <string> dateList = FindHolidayInfo(content[i]);//content[i].Substring(42, 6).Trim(); if (dateList == null || dateList.Count == 0) { continue; } foreach (string dateStr in dateList) { string date = dateStr.Replace(" ", "-"); string month = date.Split('-')[1]; date = date + "-" + year; DateTime dt; if (!DateTime.TryParse(date, out dt)) { break; } string comment = content[i].Substring(content[i].IndexOf(month) + month.Length).TrimStart(); int blankIndex = comment.IndexOf(" "); if (blankIndex != -1) { comment = comment.Substring(0, blankIndex); } HolidayInfo item = new HolidayInfo(); item.HolidayDate = date; item.MarketId = (int)configObj.MarketId; item.Comment = comment; if (item.Comment.ToLower().Contains("half day") && configObj.MarketId.Equals(MarketIdEnum.Japan)) { continue; } holiday.Add(item); } } return(holiday); }
private void GetTodaySETTLEFromGATSTolistIDNTGOBulkTGFc1(string strTGFc1, string patternTGFc1, Dictionary <string, IDNTGOBulk> dicIDNTGOBulkTGFc1, List <string> listMonthAndYearFromIDNTGOBulkTGTM, List <IDNTGOBulk> listIDNTGOBulkTGFc1ROLLOV) { try { GatsUtil gats = new GatsUtil(); string response = gats.GetGatsResponse(strTGFc1, null); Regex regex = new Regex(patternTGFc1); MatchCollection matches = regex.Matches(response); string price = string.Empty; List <int> listPrice = new List <int>(); int high = 0; if (matches.Count == 1) { int settle = Convert.ToInt32(matches[0].Groups["SETTLE"].Value); if (settle > 0) { IDNTGOBulk idntgobulk = null; IDNTGOBulk idntgobulkROLLOV = null; high = settle - settle % 100; listPrice.Add(high); int reduce = high; int add = high; for (int i = 0; i < 5; i++) { if (reduce <= 2000) { reduce -= 25; } else if (reduce > 2000 && reduce <= 4000) { reduce -= 50; } else { reduce -= 100; } listPrice.Add(reduce); } for (int i = 0; i < 5; i++) { if (add <= 2000) { add += 25; } else if (add > 2000 && add <= 4000) { add += 50; } else { add += 100; } listPrice.Add(add); } foreach (int item in listPrice) { price = item.ToString(); Dictionary <string, string> .KeyCollection dicCallsKeys = dicCalls.Keys; Dictionary <string, string> .KeyCollection dicPutsKeys = dicPuts.Keys; foreach (string monthAndYear in listMonthAndYearFromIDNTGOBulkTGTM) { idntgobulk = new IDNTGOBulk(); idntgobulk.SYMBOL = "TGO" + (price.Length == 4 ? ("0" + price + monthAndYear) : price + monthAndYear); idntgobulk.DSPLY_NAME = "TG " + (dicCalls.ContainsKey(monthAndYear.Substring(0, 1)) ? dicCalls[monthAndYear.Substring(0, 1)].ToUpper() + monthAndYear.Substring(1, 1) + " " + price + " C" : dicPuts[monthAndYear.Substring(0, 1)].ToUpper() + monthAndYear.Substring(1, 1) + " " + price + " P"); idntgobulk.RIC = "TG" + price + monthAndYear + ".TM"; idntgobulk.OFFCL_CODE = idntgobulk.SYMBOL; idntgobulk.EX_SYMBOL = idntgobulk.SYMBOL; idntgobulk.EXPIR_DATE = " "; idntgobulk.CONTR_MNTH = dicCalls.ContainsKey(monthAndYear.Substring(0, 1)) ? dicCalls[monthAndYear.Substring(0, 1)].ToUpper() + monthAndYear.Substring(1, 1) : dicPuts[monthAndYear.Substring(0, 1)].ToUpper() + monthAndYear.Substring(1, 1); idntgobulk.CONTR_SIZE = "187.5"; idntgobulk.STRIKE_PRC = price; idntgobulk.PUTCALLIND = (dicCalls.ContainsKey(monthAndYear.Substring(0, 1)) ? "CA_CALL" : "PU_PUT"); idntgobulk.BCKGRNDPAG = "TM01"; idntgobulk.DSPLY_NMLL = idntgobulk.DSPLY_NAME; idntgobulk.X_INST_TITLE = "I"; idntgobulk.X_80CHAR = "1"; idntgobulk.INSTMOD_PUT_CALL = (dicCalls.ContainsKey(monthAndYear.Substring(0, 1)) ? "C" : "P") + "_EU"; idntgobulk.EXL_NAME = "TAIFO_OPT_TG"; idntgobulk.BCU = "TAIFO_OPT_TG,TAIFO_OPT_TG_" + (dicCalls.ContainsKey(monthAndYear.Substring(0, 1)) ? "C" : "P"); idntgobulk.INSTMOD_PROV_SYMB = idntgobulk.SYMBOL; dicIDNTGOBulkTGFc1.Add(idntgobulk.RIC, idntgobulk); } if (!string.IsNullOrEmpty(expirDateFormed)) { List <string> keysFromPutAndCall = new List <string>(); keysFromPutAndCall.Add(dicCalls.FirstOrDefault(q => q.Value.ToUpper() == monthYear.Substring(0, 3)).Key.ToString()); keysFromPutAndCall.Add(dicPuts.FirstOrDefault(q => q.Value.ToUpper() == monthYear.Substring(0, 3)).Key.ToString()); string cORp = "C"; foreach (string keyMonth in keysFromPutAndCall) { idntgobulkROLLOV = new IDNTGOBulk(); idntgobulkROLLOV.SYMBOL = "TGO" + (price.Length == 4 ? ("0" + price + keyMonth + monthYear.Substring(3, 1)) : price + keyMonth + monthYear.Substring(3, 1)); idntgobulkROLLOV.DSPLY_NAME = "TG " + monthYear + " " + price + " " + cORp; idntgobulkROLLOV.RIC = "TG" + price + keyMonth + monthYear.Substring(3, 1) + ".TM"; idntgobulkROLLOV.OFFCL_CODE = idntgobulkROLLOV.SYMBOL; idntgobulkROLLOV.EX_SYMBOL = idntgobulkROLLOV.SYMBOL; idntgobulkROLLOV.EXPIR_DATE = expirDateFormed; idntgobulkROLLOV.CONTR_MNTH = monthYear; idntgobulkROLLOV.CONTR_SIZE = "187.5"; idntgobulkROLLOV.STRIKE_PRC = price; idntgobulkROLLOV.PUTCALLIND = cORp.Equals("C") ? "CA_CALL" : "PU_PUT"; idntgobulkROLLOV.BCKGRNDPAG = "TM01"; idntgobulkROLLOV.DSPLY_NMLL = idntgobulkROLLOV.DSPLY_NAME; idntgobulkROLLOV.X_INST_TITLE = "I"; idntgobulkROLLOV.X_80CHAR = "1"; idntgobulkROLLOV.INSTMOD_PUT_CALL = cORp + "_EU"; idntgobulkROLLOV.EXL_NAME = "TAIFO_OPT_TG"; idntgobulkROLLOV.BCU = "TAIFO_OPT_TG,TAIFO_OPT_TG_" + cORp; idntgobulkROLLOV.INSTMOD_PROV_SYMB = idntgobulkROLLOV.SYMBOL; listIDNTGOBulkTGFc1ROLLOV.Add(idntgobulkROLLOV); cORp = "P"; } } } } else { MessageBox.Show("No Value of SETTLE is 0 ! "); } } } catch (Exception e) { LogMessage("error has happened when running GetTodaySETTLEFromGATS() : " + e.Message, Logger.LogType.Error); } }
private Dictionary <string, List <string> > CallGats() { GatsUtil gats = new GatsUtil(GatsUtil.Server.Elektron); Dictionary <string, List <string> > gatsValues = new Dictionary <string, List <string> >(); Regex rgxSpace = new Regex(@"\s+"); Regex rgxLongLink = new Regex(@"^LONGLINK", RegexOptions.IgnoreCase); try { string rics = CreateRicListForGats(); string[] stringSeparators = new string[] { "\r\n" }; char[] stringSeparators2 = new char[] { ' ' }; for (int i = 0; i < newValues.Count; i += 3000) { StringBuilder sb = new StringBuilder(); int tmpi = 0; foreach (KeyValuePair <string, List <string> > value in newValues) { string tmpRic = value.Key.Substring(1); int pagesToSeek = (value.Value.Count / 14) + 1; for (int j = 0; j < pagesToSeek; j++) { if (tmpi >= i && tmpi <= (i + 3000)) { sb.Append(string.Format("{0}{1},", j.ToString(), tmpRic)); } } tmpi++; } string test = gats.GetGatsResponse(rics, ""); string[] lines = test.Split(stringSeparators, StringSplitOptions.None); foreach (string line in lines) { string formattedLine = rgxSpace.Replace(line, " "); string[] lineTab = formattedLine.Split(stringSeparators2); if (lineTab.Length > 2 && rgxLongLink.IsMatch(lineTab[1])) { string tmpRic = "0" + lineTab[0].Substring(lineTab[0].IndexOf("#")); if (gatsValues.ContainsKey(tmpRic)) { if (lineTab[2] != "" && !lineTab[2].StartsWith(".")) { gatsValues[tmpRic].Add(lineTab[2]); } } else { gatsValues.Add(tmpRic, new List <string>()); gatsValues[tmpRic].Add(lineTab[2]); } } } } foreach (KeyValuePair <string, List <string> > value in gatsValues) { value.Value.Sort(); } return(gatsValues); } catch (Exception ex) { throw new Exception("Error While using Gats: " + ex.Message); } }