public void DownloadAsync(BondScreenerData res, object userArgs = null) { this.DownloadAsync(new BondScreenerInfoDownloadSettings(res), userArgs); }
public BondScreenerInfoDownloadSettings(BondScreenerData data) { this.Data = data; }
public Base.Response <BondScreenerInfoResult> Download(BondScreenerData res) { return(this.Download(new BondScreenerInfoDownloadSettings(res))); }
public BondScreenerInfoDownloadSettings() { this.Data = null; }
protected override BondScreenerResult ConvertResult(ConnectionInfo connInfo, System.IO.Stream stream, SettingsBase settings) { List <BondScreenerData> results = new List <BondScreenerData>(); System.Globalization.CultureInfo convCulture = new System.Globalization.CultureInfo("en-US"); XDocument doc = MyHelper.ParseXmlDocument(stream); XElement[] resultsNodes = XPath.GetElements("//results", doc); if (resultsNodes.Length == 1) { XElement resultsNode = resultsNodes[0]; foreach (XElement trNode in resultsNode.Elements()) { XAttribute classAtt = trNode.Attribute(XName.Get("class")); if (classAtt != null) { if (classAtt.Value == "yfnc_tabledata1") { BondScreenerData res = new BondScreenerData(); int index = 0; foreach (XElement tdNode in trNode.Elements()) { switch (index) { case 0: XElement fontNode = null; //tdNode.FirstNode; switch (fontNode.Value) { case "Treas": res.Type = BondType.Treasury; break; case "Zero": res.Type = BondType.TreasuryZeroCoupon; break; case "Corp": res.Type = BondType.Corporate; break; case "Muni": res.Type = BondType.Municipal; break; } break; case 1: XElement aNode = null; // tdNode.FirstNode.FirstNode; fontNode = null; //fontNode = tdNode.LastNode.FirstNode; res.Issue = new Link(fontNode.Value.Replace("\n", ""), new Uri("http://reports.finance.yahoo.com" + aNode.Attribute(XName.Get("href")).Value)); break; case 2: fontNode = null; //fontNode = tdNode.FirstNode.FirstNode; double t; if (double.TryParse(fontNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) { res.Price = t; } break; case 3: fontNode = null; //fontNode = tdNode.FirstNode.FirstNode; if (double.TryParse(fontNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) { res.CouponInPercent = t; } break; case 4: XElement nobrNode = null; // tdNode.FirstNode.FirstNode.FirstNode; DateTime d; if (System.DateTime.TryParseExact(nobrNode.Value, "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) { res.Maturity = d; } break; case 5: fontNode = null; //fontNode = tdNode.FirstNode.FirstNode; if (double.TryParse(fontNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) { res.YieldToMaturityInPercent = t; } break; case 6: fontNode = null; //fontNode = tdNode.FirstNode.FirstNode; if (double.TryParse(fontNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) { res.CurrentYieldInPercent = t; } break; case 7: fontNode = null; //fontNode = tdNode.FirstNode; foreach (Rating r in Enum.GetValues(typeof(Rating))) { if (r.ToString() == fontNode.Value) { res.FitchRating = r; break; // TODO: might not be correct. Was : Exit For } } break; case 8: fontNode = null; //fontNode = tdNode.FirstNode; res.Callable = Convert.ToBoolean((fontNode.Value == "Yes" ? true : false)); break; } index += 1; } results.Add(res); } } } } return(new BondScreenerResult(results.ToArray())); }