public static void ProcessSecUpdate(SecurityUpdate secUpd) { CommandClass command = new CommandClass(); int retVal = command.UpdateOptionExpDt(secUpd.Symbol, secUpd.MatDt.ToString("MM/dd/yyyy")); if (retVal == -2) { logger.LogError("Symbol not found: \"" + secUpd.Symbol + "\". Update failed for RptID " + secUpd.RptID); errFlag = true; } else if (retVal == 0) { updateCt += 1; } }
public static void ParseXML(XElement SecListUpd, string lineNumber) { // Required data DateTime MatDt_1, MatDt_2; XElement instrmt_1, instrmt_2; string Sym_1, CFI_1; Double StrkPx_1; SecurityUpdate secUpd = new SecurityUpdate(); // RptID if (String.IsNullOrEmpty(SecListUpd.Attribute("RptID")?.Value)) { logger.LogError("RptID is empty or missing. - Line " + lineNumber); return; } secUpd.RptID = SecListUpd.Attribute("RptID").Value; // Instrmt 1 instrmt_1 = (XElement)SecListUpd.FirstNode; instrmt_1 = (XElement)instrmt_1.FirstNode; if (instrmt_1 == null || instrmt_1.Name.LocalName != "Instrmt") { logger.LogError("Invalid SecListUpd format. Instrmt block missing. - Line " + lineNumber); return; } // Instrmt 2 instrmt_2 = (XElement)instrmt_1.NextNode; if (instrmt_2 == null || instrmt_2.Name.LocalName != "Instrmt") { logger.LogError("Invalid SecListUpd format. Instrmt block missing. - Line " + lineNumber); return; } // MatDt 1 (Old expiry date) if (!DateTime.TryParse(instrmt_1.Attribute("MatDt")?.Value, out MatDt_1)) { logger.LogError("Invalid MatDt in Instrmt block 1. - Line " + lineNumber); return; } // MatDt 2 (New expiry date) if (!DateTime.TryParse(instrmt_2.Attribute("MatDt")?.Value, out MatDt_2)) { logger.LogError("Invalid MatDt in Instrmt block 2. - Line " + lineNumber); return; } secUpd.MatDt = MatDt_2; if (MatDt_1 == MatDt_2) { return; } // Check if MatDt does not change after update // Sym 1 Sym_1 = (instrmt_1.Attribute("Sym")?.Value).PadRight(6); if (String.IsNullOrEmpty(Sym_1)) { logger.LogError("Missing Sym in Instrmt block 1. - Line " + lineNumber); return; } // StrkPx 1 if (!Double.TryParse(instrmt_1.Attribute("StrkPx")?.Value, out StrkPx_1)) { logger.LogError("Invalid StrkPx (\"" + instrmt_1.Attribute("StrkPx")?.Value + "\") in Instrmt block 1. - Line " + lineNumber); return; } // CFI 1 CFI_1 = instrmt_1.Attribute("CFI")?.Value; if (String.IsNullOrEmpty(CFI_1)) { logger.LogError("Missing CFI in Instrmt block 1. - Line " + lineNumber); return; } if (CFI_1[1] == 'C') { secUpd.Symbol = Sym_1 + MatDt_1.ToString("yyMMdd") + "C" + StrkPx_1.ToString("00000.000").Replace(".", ""); } else if (CFI_1[1] == 'P') { secUpd.Symbol = Sym_1 + MatDt_1.ToString("yyMMdd") + "P" + StrkPx_1.ToString("00000.000").Replace(".", ""); } else { logger.LogError("Invalid CFI in Instrmt block 1. - Line " + lineNumber); return; } ProcessSecUpdate(secUpd); }