IEnumerable <Queue <Charts> > FindTheOldestDueDate(string code) { var temporary = new Temporary(code.Length); if (code.Length == 8 && Temporary.CodeStorage != null && Temporary.CodeStorage.Any(o => o.Code.StartsWith(code.Substring(0, 3)) && o.Code.EndsWith(code.Substring(5)))) { var stack = new Stack <Codes>(); var days = temporary.CallUpTheChartAsync(code); foreach (var arg in Temporary.CodeStorage.Where(o => o.Code.StartsWith(code.Substring(0, 3)) && o.Code.EndsWith(code.Substring(5))).OrderByDescending(o => o.MaturityMarketCap.Length == 8 ? o.MaturityMarketCap.Substring(2) : o.MaturityMarketCap)) { stack.Push(arg); } Days = days.Result; while (stack.Count > 0) { yield return(temporary.CallUpTheChartAsync(stack.Pop()).Result); } } else if (code.Length == 6 && Temporary.CodeStorage != null && Temporary.CodeStorage.Any(o => o.Code.Equals(code))) { Market = Temporary.CodeStorage.First(o => o.Code.Equals(code)).MarginRate == 1; string sDate = temporary.FindTheChartStartsAsync(code).Result, date = string.IsNullOrEmpty(sDate) ? DateTime.Now.AddDays(-5).ToString(format) : sDate.Substring(0, 6); Days = new Queue <Charts>(); foreach (var day in temporary.CallUpTheChartAsync(code).Result) { if (string.Compare(day.Date.Substring(2), date) < 0) { Days.Enqueue(day); } } if (int.TryParse(date, out int start)) { var end = string.Empty; var count = 0; while (string.IsNullOrEmpty(end) || string.Compare(end, DateTime.Now.ToString(format)) <= 0) { if (end.CompareTo(excluding) > 0 && end.CompareTo(theDate) < 0) { for (int i = 0; i < 0x1C; i++) { count++; } } yield return(temporary.CallUpTheChartAsync(new Catalog.Request.Charts { Code = code, Start = (start - 1 + 0x12C * count++).ToString(nFormat), End = end = (start - 1 + 0x12C * count).ToString(nFormat) }).Result); } } } }
IEnumerable <Queue <Charts> > FindTheOldestDueDate(string code) { if (code.Length == 8 && Temporary.CodeStorage != null && Temporary.CodeStorage.Any(o => o.Code.Length == 8 && o.Code.StartsWith(code.Substring(0, 3)) && o.Code.EndsWith(code.Substring(5)))) { var stack = new Stack <Codes>(); if (code[0].Equals('1')) { MarginRate = Temporary.CodeStorage.First(o => o.Code.Equals(code)).MarginRate; TransactionMultiplier = GetTransactionMultiplier(code); } foreach (var arg in Temporary.CodeStorage.Where(o => o.Code.StartsWith(code.Substring(0, 3)) && o.Code.EndsWith(code.Substring(5))) .OrderByDescending(o => o.MaturityMarketCap.Length == 8 ? o.MaturityMarketCap.Substring(2) : o.MaturityMarketCap)) { stack.Push(arg); Days = new Queue <Charts>(); if (uint.TryParse(arg.MaturityMarketCap.Length == 8 ? arg.MaturityMarketCap.Substring(2) : arg.MaturityMarketCap, out uint remain) && Temporary.RemainingDay.Add(remain - 1)) { Console.WriteLine(code + "_" + Temporary.RemainingDay.Count + "_" + (remain - 1)); } } foreach (var day in Temporary.CallUpTheChartAsync(code).Result) { Days.Enqueue(day); } while (stack.Count > 0) { var codes = stack.Pop(); if (codes.Code.Equals("105QA000")) { foreach (var arg in Temporary.CallUpTheChartAsync(Temporary.CodeStorage.First(o => o.Code.Equals("101QC000"))).Result) { if (arg.Date.Substring(6, 4).Equals("1545")) { Days.Enqueue(new Charts { Date = string.Concat("20", arg.Date.Substring(0, 6)), Price = arg.Price }); } } continue; } yield return(Temporary.CallUpTheChartAsync(codes).Result); } } else if (code.Length == 6 && Temporary.CodeStorage != null && Temporary.CodeStorage.Any(o => o.Code.Equals(code))) { Market = Temporary.CodeStorage.First(o => o.Code.Equals(code)).MarginRate == 1; string sDate = Temporary.FindTheChartStartsAsync(code).Result, date = string.IsNullOrEmpty(sDate) ? DateTime.Now.AddDays(-5).ToString(format) : sDate.Substring(0, 6); Days = new Queue <Charts>(); foreach (var day in Temporary.CallUpTheChartAsync(code).Result) { if (string.Compare(day.Date.Substring(2), date) < 0) { Days.Enqueue(day); } } if (DateTime.TryParseExact(date, format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime start)) { var end = string.Empty; var count = 0; while (string.IsNullOrEmpty(end) || string.Compare(end, DateTime.Now.ToString(format)) <= 0) { yield return(Temporary.CallUpTheChartAsync(new Catalog.Request.Charts { Code = code, Start = start.AddDays(-1).AddDays(0x4B * count++).ToString(format), End = end = start.AddDays(-1).AddDays(0x4B * count).ToString(format) }).Result); } } } }