Fix Yahoo Fundamental retrieval.
Fix SeekingAlpha news retrieval.
This commit is contained in:
@@ -158,7 +158,45 @@ namespace MarketData.Utils
|
||||
return DateTime.Parse("01-01-0001");
|
||||
}
|
||||
}
|
||||
// Sep. 25, 2022 at 4:31 p.m. ET
|
||||
// "Apr. 04"
|
||||
// "1:00pm"
|
||||
public static DateTime ParseValueDateTimeMonth(String strText)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(null==strText)return DateTime.Parse("01-01-0001");
|
||||
|
||||
if(strText.EndsWith("am") || strText.EndsWith("pm"))
|
||||
{
|
||||
return DateTime.Now;
|
||||
}
|
||||
else if(strText.Contains("."))
|
||||
{
|
||||
strText=strText.Replace(".",null);
|
||||
String[] subItems=strText.Split(' ');
|
||||
DateTime currentDate = DateTime.Now;
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.Append(subItems[0]).Append(" ");
|
||||
sb.Append(subItems[1]).Append(",").Append(" ");
|
||||
sb.Append(currentDate.Year.ToString());
|
||||
DateTime resultingDate = ParseValueDateTimeMonthFormat(sb.ToString());
|
||||
if(resultingDate>currentDate)resultingDate = new DateTime(resultingDate.Year-1,resultingDate.Month, resultingDate.Day);
|
||||
return resultingDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Utility.ParseDate(strText);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValueDateTimeMonth] Error parsing date '" + strText + "', " + exception.ToString());
|
||||
return DateTime.Parse("01-01-0001");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sep. 25, 2022 at 4:31 p.m. ET
|
||||
public static DateTime ParseValueDateTimeMonthFormatTZ(String strText)
|
||||
{
|
||||
try
|
||||
@@ -177,7 +215,6 @@ namespace MarketData.Utils
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static DateTime? ParseRelativeDate(String strDate)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace MarketDataLib.Utility
|
||||
{
|
||||
String sectionItem=sections[startIndex];
|
||||
if(item.Contains(sectionItem))continue;
|
||||
if("".Equals(sectionItem)||"-".Equals(sectionItem)||sectionItem.StartsWith("("))continue;
|
||||
if("".Equals(sectionItem)||"-".Equals(sectionItem)||"--".Equals(sectionItem)||sectionItem.StartsWith("("))continue;
|
||||
if((sectionItem.All(Char.IsLetter)||sectionItem.Contains(" ")))break;
|
||||
strItem=sectionItem;
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,19 @@ namespace MarketData.Utils
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// poses a question to the console and receives a confirmation response
|
||||
/// </summary>
|
||||
/// <param name="message">The message to ask the user.</param>
|
||||
public static bool GetVerificationToProceed(String message)
|
||||
{
|
||||
Console.Write(String.Format("{0} Y/N? ",message));
|
||||
String answer = Console.ReadLine();
|
||||
answer=answer.ToUpper();
|
||||
if(!"Y".Equals(answer))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long DateToUnixDate(DateTime dateTime)
|
||||
{
|
||||
DateTime javascriptEpoch=DateTime.Parse("01-01-1970 00:00:00");
|
||||
@@ -432,7 +445,7 @@ namespace MarketData.Utils
|
||||
public static DateTime ParseDate(String strDate)
|
||||
{
|
||||
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
|
||||
String[] formats=new[] { "yyyy-MM-dd hh:mm:ss tt","dddd, MMMM dd","MMM dd yyyy","yyyy-MM","ddd, MMM. d","ddd, MMM. dd","yyyy/MM/dd","M-d-yyyy","dd-MM-yyyy","MM-dd-yyyy","M.d.yyyy","dd.MM.yyyy","MM.dd.yyyy","yyyyMMdd" }.Union(cultureInfo.DateTimeFormat.GetAllDateTimePatterns()).ToArray();
|
||||
String[] formats=new[] { "yy-MM-dd","yyyy-MM-dd hh:mm:ss tt","dddd, MMMM dd","MMM dd yyyy","yyyy-MM","ddd, MMM. d","ddd, MMM. dd","yyyy/MM/dd","M-d-yyyy","dd-MM-yyyy","MM-dd-yyyy","M.d.yyyy","dd.MM.yyyy","MM.dd.yyyy","yyyyMMdd" }.Union(cultureInfo.DateTimeFormat.GetAllDateTimePatterns()).ToArray();
|
||||
strDate = strDate.Trim();
|
||||
DateTime dateTime=DateTime.ParseExact(strDate, formats, new System.Globalization.CultureInfo("en-US"), DateTimeStyles.AssumeLocal);
|
||||
return dateTime;
|
||||
|
||||
Reference in New Issue
Block a user