public static char GetHistQuotesInterval(HistQuotesInterval item)
        {
            switch (item)
            {
            case HistQuotesInterval.Daily:
                return('d');

            case HistQuotesInterval.Weekly:
                return('w');

            default:
                return('m');
            }
        }
 /// <summary>
 /// Starts an asynchronous download of historic quotes data.
 /// </summary>
 /// <param name="unmanagedIDs">The unmanaged list of IDs</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <param name="userArgs">Individual user argument</param>
 /// <remarks></remarks>
 public void DownloadAsync(IEnumerable <string> unmanagedIDs, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval, object userArgs)
 {
     if (unmanagedIDs == null)
     {
         throw new ArgumentNullException("unmanagedIDs", "The passed list is null.");
     }
     this.CheckDates(fromDate, toDate);
     this.DownloadAsync(new HistQuotesDownloadSettings(unmanagedIDs, fromDate, toDate, interval), userArgs);
 }
 /// <summary>
 /// Starts an asynchronous download of historic quotes data.
 /// </summary>
 /// <param name="unmanagedID">The unmanaged ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <param name="userArgs">Individual user argument</param>
 /// <remarks></remarks>
 public void DownloadAsync(string unmanagedID, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval, object userArgs)
 {
     if (unmanagedID == string.Empty)
     {
         throw new ArgumentNullException("unmanagedID", "The passed ID is empty.");
     }
     this.DownloadAsync(new string[] { unmanagedID }, fromDate, toDate, interval, userArgs);
 }
 private string DownloadURL(IEnumerable <string> ids, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     string[] idArr = MyHelper.EnumToArray(ids);
     if (idArr.Length == 0)
     {
         throw new ArgumentNullException("unmanagedIDs", "The passed list is empty");
     }
     else
     {
         if (idArr.Length == 1)
         {
             if (idArr[0].Trim() == string.Empty)
             {
                 throw new ArgumentNullException("id", "The passed ID is empty.");
             }
             else
             {
                 System.Text.StringBuilder url = new System.Text.StringBuilder();
                 url.Append("http://ichart.yahoo.com/table.csv?s=");
                 url.Append(Uri.EscapeDataString(MyHelper.CleanYqlParam(FinanceHelper.CleanIndexID(idArr[0]).ToUpper())));
                 url.Append("&a=");
                 url.Append(fromDate.Month - 1);
                 url.Append("&b=");
                 url.Append(fromDate.Day);
                 url.Append("&c=");
                 url.Append(fromDate.Year);
                 url.Append("&d=");
                 url.Append(toDate.Month - 1);
                 url.Append("&e=");
                 url.Append(toDate.Day);
                 url.Append("&f=");
                 url.Append(toDate.Year);
                 url.Append("&g=");
                 url.Append(FinanceHelper.GetHistQuotesInterval(interval));
                 url.Append("&ignore=.csv");
                 return(url.ToString());
             }
         }
         else
         {
             System.Text.StringBuilder url = new System.Text.StringBuilder();
             url.Append("url in (");
             for (int i = 0; i <= idArr.Length - 1; i++)
             {
                 url.Append('\'');
                 url.Append(this.DownloadURL(new string[] { MyHelper.CleanYqlParam(FinanceHelper.CleanIndexID(idArr[i]).ToUpper()) }, fromDate, toDate, interval));
                 url.Append('\'');
                 if (i < idArr.Length - 1)
                 {
                     url.Append(',');
                 }
             }
             url.Append(")");
             return(MyHelper.YqlUrl("*", "csv", url.ToString(), null, true));
         }
     }
 }
 public HistQuotesDownloadSettings(IEnumerable <string> ids, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     if (ids == null)
     {
         throw new ArgumentNullException("unmanagedIDs", "The passed list is null.");
     }
     this.IDs          = MyHelper.EnumToArray(ids);
     this.TextEncoding = System.Text.Encoding.UTF8;
     this.FromDate     = fromDate;
     this.ToDate       = toDate;
     this.Interval     = interval;
 }
 public HistQuotesDownloadSettings(string id, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     this.IDs          = new string[] { id };
     this.TextEncoding = System.Text.Encoding.UTF8;
     this.FromDate     = fromDate;
     this.ToDate       = toDate;
     this.Interval     = interval;
 }
 public static char GetHistQuotesInterval(HistQuotesInterval item)
 {
     switch (item)
     {
         case HistQuotesInterval.Daily:
             return 'd';
         case HistQuotesInterval.Weekly:
             return 'w';
         default:
             return 'm';
     }
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="unmanagedIDs">The unmanaged ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public YahooManaged.Base.Response <HistQuotesResult> Download(IEnumerable <string> unmanagedIDs, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     if (unmanagedIDs == null)
     {
         throw new ArgumentNullException("unmanagedID", "The passed ID is empty.");
     }
     this.CheckDates(fromDate, toDate);
     string[] ids = FinanceHelper.CleanIDfromAT(unmanagedIDs);
     return(this.Download(new HistQuotesDownloadSettings(ids, fromDate, toDate, interval)));
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="managedIDs">The managed ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public YahooManaged.Base.Response <HistQuotesResult> Download(IEnumerable <IID> managedIDs, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     if (managedIDs == null)
     {
         throw new ArgumentNullException("managedIDs", "The passed list is null.");
     }
     return(this.Download(FinanceHelper.IIDsToStrings(managedIDs), fromDate, toDate, interval));
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="unmanagedID">The unmanaged ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public YahooManaged.Base.Response <HistQuotesResult> Download(string unmanagedID, System.DateTime fromDate, System.DateTime todate, HistQuotesInterval interval)
 {
     if (unmanagedID.Trim() == string.Empty)
     {
         throw new ArgumentNullException("unmanagedID", "The passed ID is empty.");
     }
     return(this.Download(new string[] { unmanagedID }, fromDate, todate, interval));
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="managedID">The managed ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public YahooManaged.Base.Response <HistQuotesResult> Download(IID managedID, System.DateTime fromDate, System.DateTime todate, HistQuotesInterval interval)
 {
     if (managedID == null)
     {
         throw new ArgumentNullException("managedID", "The passed ID is null.");
     }
     return(this.Download(managedID.ID, fromDate, todate, interval));
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="unmanagedIDs">The unmanaged ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public Base.Response<HistQuotesResult> Download(IEnumerable<string> unmanagedIDs, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     if (unmanagedIDs == null)
         throw new ArgumentNullException("unmanagedID", "The passed ID is empty.");
     this.CheckDates(fromDate, toDate);
     string[] ids = FinanceHelper.CleanIDfromAT(unmanagedIDs);
     return this.Download(new HistQuotesDownloadSettings(ids, fromDate, toDate, interval));
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="managedIDs">The managed ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public Base.Response<HistQuotesResult> Download(IEnumerable<IID> managedIDs, System.DateTime fromDate, System.DateTime toDate, HistQuotesInterval interval)
 {
     if (managedIDs == null)
         throw new ArgumentNullException("managedIDs", "The passed list is null.");
     return this.Download(FinanceHelper.IIDsToStrings(managedIDs), fromDate, toDate, interval);
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="unmanagedID">The unmanaged ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public Base.Response<HistQuotesResult> Download(string unmanagedID, System.DateTime fromDate, System.DateTime todate, HistQuotesInterval interval)
 {
     if (unmanagedID.Trim() == string.Empty)
         throw new ArgumentNullException("unmanagedID", "The passed ID is empty.");
     return this.Download(new string[] { unmanagedID }, fromDate, todate, interval);
 }
 /// <summary>
 /// Downloads historic quotes data.
 /// </summary>
 /// <param name="managedID">The managed ID</param>
 /// <param name="fromDate">The startdate of the reviewed period</param>
 /// <param name="todate">The enddate of the reviewed period</param>
 /// <param name="interval">The trading period interval</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public Base.Response<HistQuotesResult> Download(IID managedID, System.DateTime fromDate, System.DateTime todate, HistQuotesInterval interval)
 {
     if (managedID == null)
         throw new ArgumentNullException("managedID", "The passed ID is null.");
     return this.Download(managedID.ID, fromDate, todate, interval);
 }