本文整理汇总了C#中System.DateTime.ToFredDateString方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToFredDateString方法的具体用法?C# DateTime.ToFredDateString怎么用?C# DateTime.ToFredDateString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToFredDateString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReleases
/// <summary>
/// Get all releases of economic data. Corresponds to http://api.stlouisfed.org/fred/releases
/// </summary>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period. </param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 1000, defaults to 1000. </param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="orderBy">Order results by values of the specified attribute.</param>
/// <param name="order">Sort results is ascending or descending order for attribute values specified by order_by.</param>
/// <returns>All releases in the FRED database.</returns>
public IEnumerable<Release> GetReleases(DateTime realtimeStart, DateTime realtimeEnd, int limit = 1000,
int offset = 0,
Release.OrderBy orderBy = Release.OrderBy.ReleaseId,
SortOrder order = SortOrder.Ascending)
{
var url = String.Format(Urls.Releases, _key, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(orderBy),
Extensions.ToString(order));
return CreateReleases(url);
}
示例2: GetReleaseAsync
/// <summary>
/// Get a release of economic data. Corresponds to http://api.stlouisfed.org/fred/release
/// </summary>
/// <param name="releaseId">The ID of the release to retrieve.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period. </param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 1000, defaults to 1000. </param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="orderBy">Order results by values of the specified attribute.</param>
/// <param name="order">Sort results is ascending or descending order for attribute values specified by order_by.</param>
/// <returns>The requested release.</returns>
/// <remarks>Note that release dates are published by data sources and do not necessarily represent when data will be available on the FRED or ALFRED websites.</remarks>
public async Task<Release> GetReleaseAsync(int releaseId, DateTime realtimeStart, DateTime realtimeEnd, int limit = 1000,
int offset = 0,
Release.OrderBy orderBy = Release.OrderBy.ReleaseId,
SortOrder order = SortOrder.Ascending)
{
var url = String.Format(Urls.Release, _key, releaseId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
var root = await GetRootAsync(url);
var element = root.Elements("release").First();
return CreateRelease(element);
}
示例3: GetReleasesAsync
/// <summary>
/// Get all releases of economic data. Corresponds to http://api.stlouisfed.org/fred/releases
/// </summary>
/// <param name="realtimeStart"> The start of the real-time period. </param>
/// <param name="realtimeEnd"> The end of the real-time period. </param>
/// <param name="limit"> The maximum number of results to return. An integer between 1 and 1000, defaults to 1000. </param>
/// <param name="offset"> non-negative integer, optional, default: 0 </param>
/// <param name="orderBy"> Order results by values of the specified attribute. </param>
/// <param name="order"> Sort results is ascending or descending order for attribute values specified by order_by. </param>
/// <returns> All releases in the FRED database. </returns>
public async Task<IEnumerable<Release>> GetReleasesAsync(DateTime realtimeStart, DateTime realtimeEnd,
int limit = 1000,
int offset = 0,
Release.OrderBy orderBy = Release.OrderBy.ReleaseId,
SortOrder order = SortOrder.Ascending)
{
var url = String.Format(Urls.Releases, _key, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(orderBy),
Extensions.ToString(order));
var root = await GetRootAsync(url);
return root.Elements("release").Select(CreateRelease).ToList();
}
示例4: GetSeriesReleaseAsync
/// <summary>
/// Get the release for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/release
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>The release for an economic data series.</returns>
public async Task<Release> GetSeriesReleaseAsync(string seriesId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.SeriesRelease, _key, seriesId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
var root = await GetRootAsync(url);
var element = root.Elements("release").First();
return CreateRelease(element);
}
示例5: GetSeriesSearchAsync
/// <summary>
/// Get economic data series that match keywords. Corresponds to http://api.stlouisfed.org/fred/series/search
/// </summary>
/// <param name="searchText">The words to match against economic data series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <param name="type">Determines the type of search to perform.
/// 'full_text' searches series attributes title, units, frequency, and notes by parsing words into stems.
/// This makes it possible for searches like 'Industry' to match series containing related words such as 'Industries'.
/// Of course, you can search for multiple words like 'money' and 'stock'. Remember to url encode spaces (e.g. 'money%20stock').
/// 'series_id' performs a substring search on series IDs. Searching for 'ex' will find series containing 'ex' anywhere in
/// a series ID. '*' can be used to anchor searches and match 0 or more of any character. Searching for 'ex*' will
/// find series containing 'ex' at the beginning of a series ID. Searching for '*ex' will find series containing
/// 'ex' at the end of a series ID. It's also possible to put an '*' in the middle of a string. 'm*sl' finds any
/// series starting with 'm' and ending with 'sl'.
/// optional, default: full_text.</param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 1000, optional, default: 1000</param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="orderBy">Order results by values of the specified attribute.</param>
/// <param name="order">Sort results is ascending or descending order for attribute values specified by order_by.</param>
/// <param name="filter">The attribute to filter results by.</param>
/// <param name="filterValue">The value of the filter_variable attribute to filter results by.</param>
/// <returns>Economic data series that match keywords</returns>
public async Task<IEnumerable<Series>> GetSeriesSearchAsync(string searchText, DateTime realtimeStart, DateTime realtimeEnd,
SearchType type = SearchType.FullText,
int limit = 1000,
int offset = 0,
Series.OrderBy orderBy = Series.OrderBy.SearchRank,
SortOrder order = SortOrder.Ascending,
Series.FilterBy filter = Series.FilterBy.None,
string filterValue = "")
{
var url = String.Format(Urls.SeriesSearch, _key, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(orderBy),
Extensions.ToString(order), Extensions.ToString(filter),
filterValue, Extensions.ToString(type), Uri.EscapeUriString(searchText));
return await CreateSeriesAsync(url);
}
示例6: GetCategorySeriesAsync
/// <summary>
/// Get the series in a category. Corresponds to http://api.stlouisfed.org/fred/category/series
/// </summary>
/// <param name="categoryId">The id for a category.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 1000, optional, default: 1000</param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="orderBy">Order results by values of the specified attribute.</param>
/// <param name="order">Sort results is ascending or descending order for attribute values specified by order_by.</param>
/// <param name="filter">The attribute to filter results by.</param>
/// <param name="filterValue">The value of the filter_variable attribute to filter results by.</param>
/// <returns>The series in a category.</returns>
public async Task<IEnumerable<Series>> GetCategorySeriesAsync(int categoryId, DateTime realtimeStart, DateTime realtimeEnd,
int limit = 1000,
int offset = 0,
Series.OrderBy orderBy = Series.OrderBy.SeriesId,
SortOrder order = SortOrder.Ascending,
Series.FilterBy filter = Series.FilterBy.None,
string filterValue = "")
{
var url = String.Format(Urls.CategorySeries, _key, categoryId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(orderBy),
Extensions.ToString(order), Extensions.ToString(filter), filterValue);
return await CreateSeriesAsync(url);
}
示例7: GetSeriesCategoriesAsync
/// <summary>
/// Get the categories for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/categories
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>The categories for an economic data series.</returns>
public async Task<IEnumerable<Category>> GetSeriesCategoriesAsync(string seriesId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.SeriesCategories, _key, seriesId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
return await CreateCategoriesAsync(url);
}
示例8: GetReleaseSeries
/// <summary>
/// Get the series on a release of economic data. Corresponds to http://api.stlouisfed.org/fred/release/series
/// </summary>
/// <param name="releaseId">The id for a release.</param>
/// <param name="realtimeStart">The start of the real-time period</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 1000, optional, default: 1000</param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="orderBy">Order results by values of the specified attribute.</param>
/// <param name="order">Sort results is ascending or descending order for attribute values specified by order_by.</param>
/// <param name="filter">The attribute to filter results by.</param>
/// <param name="filterValue">The value of the filter_variable attribute to filter results by.</param>
/// <returns>The series on a release of economic data. </returns>
public IEnumerable<Series> GetReleaseSeries(int releaseId, DateTime realtimeStart, DateTime realtimeEnd,
int limit = 1000,
int offset = 0,
Series.OrderBy orderBy = Series.OrderBy.SeriesId,
SortOrder order = SortOrder.Ascending,
Series.FilterBy filter = Series.FilterBy.None,
string filterValue = "")
{
var url = String.Format(Urls.ReleaseSeries, _key, releaseId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(orderBy),
Extensions.ToString(order), Extensions.ToString(filter), filterValue);
return CreateSeries(url);
}
示例9: GetReleaseDates
/// <summary>
/// Get release dates for a release of economic data. Corresponds to http://api.stlouisfed.org/fred/release/dates
/// </summary>
/// <param name="releaseId">The id for a release.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <param name="limit">The maximum number of results to return. Integer between 1 and 10000, optional, default: 10000</param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="order">Sort results is ascending or descending release date order.</param>
/// <param name="includeReleaseWithNoData">Determines whether release dates with no data available are returned. The defalut value 'false' excludes release dates that do not have data.</param>
/// <returns>Release dates for a release of economic data</returns>
/// <remarks>Note that release dates are published by data sources and do not necessarily represent when data will be available on the FRED or ALFRED websites.</remarks>
public IEnumerable<ReleaseDate> GetReleaseDates(int releaseId, DateTime realtimeStart, DateTime realtimeEnd,
int limit = 1000,
int offset = 0,
SortOrder order = SortOrder.Ascending,
bool includeReleaseWithNoData = false)
{
var url = Format(Urls.ReleaseDates, _key, releaseId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString(), limit, offset, Extensions.ToString(order),
includeReleaseWithNoData.ToString().ToLowerInvariant());
return (from releaseDate in GetRoot(url).Elements("release_date")
select new ReleaseDate
{
ReleaseId = int.Parse(releaseDate.Attribute("release_id").Value),
ReleaseName = "",
Date = releaseDate.Value.ToFredDate()
}).ToList();
}
示例10: GetSource
/// <summary>
/// Get a source of economic data. Corresponds to http://api.stlouisfed.org/fred/source
/// </summary>
/// <param name="sourceId">The id for a source.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>A source of economic data.</returns>
public Source GetSource(int sourceId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.Source, _key, sourceId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
var element = GetRoot(url).Elements("source").First();
return CreateSource(element);
}
示例11: GetSeriesObservationsFileAsync
/// <summary>
/// Get the observations or data values for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/observations
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="fileType">The type of file to send.</param>
/// <param name="filename">The where to save the file.</param>
/// <param name="observationStart">The start of the observation period.</param>
/// <param name="observationEnd">The end of the observation period.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <param name="vintageDates">A comma separated string of YYYY-MM-DD formatted dates in history (e.g. 2000-01-01,2005-02-24).
/// Vintage dates are used to download data as it existed on these specified dates in history. Vintage dates can be
/// specified instead of a real-time period using realtime_start and realtime_end.
///
/// Sometimes it may be useful to enter a vintage date that is not a date when the data values were revised.
/// For instance you may want to know the latest available revisions on 2001-09-11 (World Trade Center and
/// Pentagon attacks) or as of a Federal Open Market Committee (FOMC) meeting date. Entering a vintage date is
/// also useful to compare series on different releases with different release dates.</param>
/// <param name="limit">The maximum number of results to return. An integer between 1 and 100000, optional, default: 100000</param>
/// <param name="offset">non-negative integer, optional, default: 0</param>
/// <param name="order">Sort results is ascending or descending observation_date order.</param>
/// <param name="transformation">Type of data value transformation.</param>
/// <param name="frequency">An optional parameter that indicates a lower frequency to aggregate values to.
/// The FRED frequency aggregation feature converts higher frequency data series into lower frequency data series
/// (e.g. converts a monthly data series into an annual data series). In FRED, the highest frequency data is daily,
/// and the lowest frequency data is annual. There are 3 aggregation methods available- average, sum, and end of period.</param>
/// <param name="method">A key that indicates the aggregation method used for frequency aggregation.</param>
/// <param name="outputType">Output type:
/// 1. Observations by Real-Time Period
/// 2. Observations by Vintage Date, All Observations
/// 3. Observations by Vintage Date, New and Revised Observations Only
/// 4. Observations, Initial Release Only
/// </param>
/// <returns>Observations or data values for an economic data series.</returns>
public async Task GetSeriesObservationsFileAsync(string seriesId, FileType fileType, string filename,
DateTime observationStart,
DateTime observationEnd,
DateTime realtimeStart,
DateTime realtimeEnd,
IEnumerable<DateTime> vintageDates, int limit = 100000,
int offset = 0, SortOrder order = SortOrder.Ascending,
Transformation transformation = Transformation.None,
Frequency frequency = Frequency.None,
AggregationMethod method = AggregationMethod.Average,
OutputType outputType = OutputType.RealTime)
{
var vintageString = vintageDates.Aggregate(string.Empty,
(current, vintageDate) =>
current + (vintageDate.ToFredDateString() + ","));
if (vintageString.Length > 0)
{
vintageString = vintageString.Substring(0, vintageString.Length - 1);
}
var realtimeStartStr = (vintageString.Length == 0) ? realtimeStart.ToFredDateString() : string.Empty;
var realtimeEndStr = (vintageString.Length == 0) ? realtimeEnd.ToFredDateString() : string.Empty;
var url = String.Format(Urls.SeriesObservations, _key, seriesId, realtimeStartStr,
realtimeEndStr, limit, offset, Extensions.ToString(order),
observationStart.ToFredDateString(),
observationEnd.ToFredDateString(),
Extensions.ToString(transformation), Extensions.ToString(frequency),
Extensions.ToString(method), Extensions.ToString(outputType),
Extensions.ToString(fileType), vintageString);
try
{
if (fileType != FileType.Xml && !Path.GetExtension(filename).Equals(".zip", StringComparison.OrdinalIgnoreCase))
{
filename += ".zip";
}
await _downloader.DownloadFileAsync(url, filename);
}
catch (WebException exp)
{
var response = (HttpWebResponse)exp.Response;
var buffer = new byte[response.ContentLength];
response.GetResponseStream().Read(buffer, 0, buffer.Length);
var xml = Encoding.UTF8.GetString(buffer);
var start = xml.IndexOf("message=", StringComparison.OrdinalIgnoreCase);
if (start < 0)
{
throw;
}
start += 9;
var end = xml.LastIndexOf("\"", StringComparison.OrdinalIgnoreCase);
var message = xml.Substring(start, end - start);
throw new FredExecption(message, exp);
}
}
示例12: GetSeriesRelease
/// <summary>
/// Get the release for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/release
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>The release for an economic data series.</returns>
public Release GetSeriesRelease(string seriesId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.SeriesRelease, _key, seriesId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
var element = GetRoot(url).Elements("release").First();
return CreateRelease(element);
}
示例13: GetSeries
/// <summary>
/// Get an economic data series. Corresponds to http://api.stlouisfed.org/fred/series
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>An economic data series.</returns>
public Series GetSeries(string seriesId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = Format(Urls.Series, _key, seriesId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
var element = GetRoot(url).Elements("series").First();
return CreateSeries(element);
}
示例14: GetSeriesCategories
/// <summary>
/// Get the categories for an economic data series. Corresponds to http://api.stlouisfed.org/fred/series/categories
/// </summary>
/// <param name="seriesId">The id for a series.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>The categories for an economic data series.</returns>
public IEnumerable<Category> GetSeriesCategories(string seriesId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.SeriesCategories, _key, seriesId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
return CreateCategories(url);
}
示例15: GetCategoryChildern
/// <summary>
/// Get the child categories for a specified parent category. Corresponds to http://api.stlouisfed.org/fred/category/children
/// </summary>
/// <param name="categoryId">The id for a category.</param>
/// <param name="realtimeStart">The start of the real-time period.</param>
/// <param name="realtimeEnd">The end of the real-time period.</param>
/// <returns>The child categories for a specified parent category</returns>
public IEnumerable<Category> GetCategoryChildern(int categoryId, DateTime realtimeStart, DateTime realtimeEnd)
{
var url = String.Format(Urls.CategoryChildern, _key, categoryId, realtimeStart.ToFredDateString(),
realtimeEnd.ToFredDateString());
return CreateCategories(url);
}