Parent: Object
TimeSeriesCompressor is a static utility class containing methods that compress a TimeSeries from one scale into a less granular scale. For example, you can use ToWeekly to compress a daily TimeSeries into a weekly TimeSeries. For each compressed period, TimeSeriesCompressor retains the last value from the source TimeSeries. This makes it suitable for compressing series such as closing prices or calculated indicators. If you need the true open, high, or low of a compressed period, use BarHistoryCompressor instead. If you want to plot or otherwise use a compressed TimeSeries alongside its original-scale data, use TimeSeriesSynchronizer to expand the compressed series back to the original DateTimes.
Compresses source to a daily scale and returns a new TimeSeries containing the final source value for each trading day.
The overload accepting market should be used when market trading hours affect where the trading day begins and ends, particularly for markets that trade through midnight.
If market is null, this overload behaves like ToDaily(source).
The returned TimeSeries retains the source TimeSeries' Description.
Remarks
- The final intraday value does not necessarily equal an exchange's official daily settlement value.
- When using intraday source data, the inclusion or exclusion of pre/post-market data affects the resulting daily values.
- To obtain actual daily Open, High, or Low values, compress a BarHistory using BarHistoryCompressor.ToDaily instead.
Compresses an intraday source TimeSeries to the specified number of minutes and returns a TimeSeries containing the final source value in each compressed interval. The source must have a finer scale than the requested interval. For example, 1-minute data can be compressed to 5-minute data. If the source already has a Minute scale:
- interval must be greater than or equal to the source interval.
- interval must be evenly divisible by the source interval.
- If the requested interval equals the existing interval, the original source TimeSeries is returned. Second-based data can also be compressed when the requested minute interval represents an exact multiple of the source's second interval. The method returns null if the requested compression is not compatible with the source scale. The market parameter is used to determine the correct market open and close times when establishing compressed intervals. If market is null, WealthLab attempts to determine the open and close times from the source DateTimes. The returned TimeSeries retains the source TimeSeries' Description.
Compresses source to a monthly scale and returns a new TimeSeries containing the final source value for each month. The DateTime of each resulting value corresponds to the final source DateTime in that month. The returned TimeSeries retains the source TimeSeries' Description. Remarks
- When using intraday source data, the inclusion or exclusion of pre/post-market data affects the result.
- To obtain actual monthly Open, High, or Low values, use BarHistoryCompressor.ToMonthly.
Compresses source to a quarterly scale and returns a new TimeSeries containing the final source value for each calendar quarter. Calendar quarters end in March, June, September, and December. The DateTime of each resulting value corresponds to the final source DateTime in that quarter. The returned TimeSeries retains the source TimeSeries' Description. Remarks
- When using intraday source data, the inclusion or exclusion of pre/post-market data affects the result.
- To obtain actual quarterly Open, High, or Low values, use BarHistoryCompressor.ToQuarterly.
Compresses source to the scale specified by scale. The method supports the following target frequencies:
- Daily
- Weekly
- Monthly
- Quarterly
- Yearly
- Minute
For Minute compression, scale.Interval specifies the requested minute interval and market is passed to ToMinute.
For the other supported frequencies, the corresponding TimeSeriesCompressor method is called.
An
ArgumentExceptionis thrown if the requested HistoryScale frequency is not supported.
Compresses source to a weekly scale and returns a new TimeSeries containing the final source value for each week. The DateTime of each resulting value corresponds to the final source DateTime in that week. The returned TimeSeries retains the source TimeSeries' Description. Remarks
- When using intraday source data, the inclusion or exclusion of pre/post-market data affects the result.
- To obtain actual weekly Open, High, or Low values, use BarHistoryCompressor.ToWeekly.
Compresses source to a yearly scale and returns a new TimeSeries containing the final source value for each calendar year. The DateTime of each resulting value corresponds to the final source DateTime in that year. The returned TimeSeries retains the source TimeSeries' Description.