Exemple #1
0
        protected override string GetUrl()
        {
            if (this.ID == string.Empty)
            {
                throw new ArgumentException("ID is empty.", "ID");
            }
            System.Text.StringBuilder url = new System.Text.StringBuilder();
            url.Append("http://");
            url.Append("chart.finance.yahoo.com/");

            if (this.SimplifiedImage)
            {
                url.Append("t?");
            }
            else if (this.ImageSize == ChartImageSize.Small)
            {
                url.Append("h?");
            }
            else
            {
                url.Append("z?");
            }

            url.Append("s=");
            url.Append(MyHelper.CleanYqlParam(FinanceHelper.CleanIndexID(this.ID)));

            if (this.SimplifiedImage)
            {
                url.Append("&width=" + this.ImageWidth.ToString());
                url.Append("&height=" + this.ImageHeight.ToString());
            }
            else if (this.ImageSize != ChartImageSize.Small)
            {
                url.Append("&t=");
                url.Append(FinanceHelper.GetChartTimeSpan(this.TimeSpan));
                url.Append("&z=");
                url.Append(FinanceHelper.GetChartImageSize(this.ImageSize));
                url.Append("&q=");
                url.Append(FinanceHelper.GetChartType(this.Type));
                url.Append("&l=");
                url.Append(FinanceHelper.GetChartScale(this.Scale));
                if (this.MovingAverages.Count > 0 | this.ExponentialMovingAverages.Count > 0 | this.TechnicalIndicators.Count > 0)
                {
                    url.Append("&p=");
                    foreach (MovingAverageInterval ma in this.MovingAverages)
                    {
                        url.Append('m');
                        url.Append(FinanceHelper.GetMovingAverageInterval(ma));
                        url.Append(',');
                    }
                    foreach (MovingAverageInterval ma in this.ExponentialMovingAverages)
                    {
                        url.Append('e');
                        url.Append(FinanceHelper.GetMovingAverageInterval(ma));
                        url.Append(',');
                    }
                    foreach (TechnicalIndicator ti in this.TechnicalIndicators)
                    {
                        url.Append(FinanceHelper.GetTechnicalIndicatorsI(ti));
                    }
                }
                if (this.TechnicalIndicators.Count > 0)
                {
                    url.Append("&a=");
                    foreach (TechnicalIndicator ti in this.TechnicalIndicators)
                    {
                        url.Append(FinanceHelper.GetTechnicalIndicatorsII(ti));
                    }
                }
                if (this.ComparingIDs.Count > 0)
                {
                    url.Append("&c=");
                    foreach (string csid in this.ComparingIDs)
                    {
                        url.Append(MyHelper.CleanYqlParam(FinanceHelper.CleanIndexID(csid)));
                        url.Append(',');
                    }
                }
                if (this.Culture == null)
                {
                    this.Culture = Culture.DefaultCultures.UnitedStates_English;
                }
            }
            url.Append(YahooHelper.CultureToParameters(this.Culture));
            return(url.ToString());
        }