Recently Yahoo made some changes on their earnings calendar / surprise pages (eg, https://biz.yahoo.com/z/20160201.html) that caused the Historical Earnings Surprise, EPS and Consensus Data downloader to stop working properly. That data is pretty important for a number of my strategies, so I went ahead and coded up a fix.
Now, my question is, what is the best way to share the fix? It would be nice to be able to update the existing trading object with the update, but I don't think I can do that(?) I know that I could submit a new trading object, but that seems like it would be confusing since its purpose would be identical to the existing object. Suggestions?
Anyhow, I'll go ahead and paste the updated Pre-Script code below -- it should be the only change needed to fix the downloader.
public ParseHtml(QuantShare.Scripting.Global g, PreScript c)
{
this.Global = g;
this.Content = c;
// Get date from URL
string date = Content.GetURLORFileName().Replace(".html", "");
date = date.Substring(date.LastIndexOf('/') + 1);
this.UrlDate = date;
// Yahoo uses "N/A" for unknown / invalid data; QS needs NAN for these
this.UrlContent = Content.GetContent().Replace("N/A", "NAN");
// Ignore all unprocessed data
for(int i=0; i < Content.Rows.Length; i++) {
Content.Rows[i].IsIgnoreLine = true;
}
}
public void Parse()
{
Thread t = new Thread(DoParse);
t.ApartmentState = ApartmentState.STA;
t.Start((object)UrlContent);
t.Join();
}
private void DoParse(object html)
{
WebBrowser wbc = new WebBrowser();
// Grab all rows in the document
HtmlElementCollection rows = doc.GetElementsByTagName("TR");
// Inspect each row looking for those containing 7 TD elements; these rows hold
// the data that we're after. Quick and dirty, but awfully fragile...
foreach (System.Windows.Forms.HtmlElement row in rows) {
I downloaded the script and data - but it gives NaN for all releases after Jan 2015, for the Surprise, EPS and Consensus fields.
How do i fix this, so it gives valid data for all the recent releases in 2015 and 2016?
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.