{"record":{"id":"ec1c651426d908c7","repo":"QuantConnect/Lean","slug":"one-or-more-custom-data-fields-open-high-low-c","errorCode":null,"errorMessage":"One or more custom data fields (Open, High, Low, Close, Price) are zero.","messagePattern":"One or more custom data fields \\(Open, High, Low, Close, Price\\) are zero\\.","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DescendingCustomDataObjectStoreRegressionAlgorithm.cs","lineNumber":85,"sourceCode":"            SetBenchmark(x => 0);\n\n            SortCustomData.CustomDataKey = CustomDataKey;\n\n            _customSymbol = AddData<SortCustomData>(\"SortCustomData\", Resolution.Daily).Symbol;\n\n            // Saving data here for demonstration and regression testing purposes.\n            // In real scenarios, data has to be saved to the object store before the algorithm starts.\n            ObjectStore.Save(CustomDataKey, string.Join(\"\\n\", descendingCustomData));\n        }\n\n        public override void OnData(Slice slice)\n        {\n            if (slice.ContainsKey(_customSymbol))\n            {\n                var sortCustomData = slice.Get<SortCustomData>(_customSymbol);\n                if (sortCustomData.Open == 0 || sortCustomData.High == 0 || sortCustomData.Low == 0 || sortCustomData.Close == 0 || sortCustomData.Price == 0)\n                {\n                    throw new RegressionTestException(\"One or more custom data fields (Open, High, Low, Close, Price) are zero.\");\n                }\n\n                _receivedData.Add(sortCustomData);\n            }\n        }\n\n        public override void OnEndOfAlgorithm()\n        {\n            if (_receivedData.Count == 0)\n            {\n                throw new RegressionTestException(\"Custom data was not fetched\");\n            }\n\n            var history = History<SortCustomData>(_customSymbol, StartDate, EndDate, Resolution.Hour).ToList();\n\n            if (history.Count != _receivedData.Count)\n            {\n                throw new RegressionTestException(\"History request returned different data than expected\");","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DescendingCustomDataObjectStoreRegressionAlgorithm.cs#L67-L103","documentation":"OnData checks that every SortCustomData point received from the object store has non-zero Open, High, Low, Close, and Price. If any field is zero, the custom data Reader() parsed a malformed line or returned a default-valued object. This guards the descending-sort custom-data pipeline.","triggerScenarios":"A CSV line in the object-store payload has a missing/empty OHLC column, the Reader parses the wrong column index, or DateTime.ParseExact / ToDecimal fails silently and leaves a field at its default 0m.","commonSituations":"The object-store string was not saved before OnData runs, a column delimiter mismatch, the Reader's csv index offsets are wrong, or the data format changed (extra/fewer columns).","solutions":["Verify ObjectStore.Save runs in Initialize before any OnData and the payload matches the expected CSV schema (date,open,high,low,close,...).","Check SortCustomData.Reader column indices: csv[1]=Open, csv[2]=High, csv[3]=Low, csv[4]=Close — confirm the source data follows this order.","Log the raw line in Reader before parsing to catch empty or misaligned fields.","Return null from Reader for malformed lines instead of a zero-filled object so they are skipped, not asserted on."],"exampleFix":"// before\nvar data = new SortCustomData() { Open = csv[1].ToDecimal(), ... };\nreturn data;\n\n// after — validate before returning\nif (csv.Length < 5) return null;\nvar open = csv[1].ToDecimal();\nif (open == 0) return null;\nreturn new SortCustomData() { Open = open, High = csv[2].ToDecimal(), Low = csv[3].ToDecimal(), Close = csv[4].ToDecimal() };","handlingStrategy":"validation","validationCode":"public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)\n{\n    var csv = line.Split(\",\");\n    if (csv.Length < 5) return null;\n    var open = csv[1].ToDecimal();\n    var high = csv[2].ToDecimal();\n    var low = csv[3].ToDecimal();\n    var close = csv[4].ToDecimal();\n    if (open == 0 || high == 0 || low == 0 || close == 0) return null;\n    return new SortCustomData { Open = open, High = high, Low = low, Close = close, Value = close };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate CSV column count and non-zero values in Reader; return null for bad lines.","Log raw lines during development to catch format drift.","Ensure ObjectStore.Save runs before any OnData."],"tags":["quantconnect","custom-data","object-store","csv-parsing","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}