Table of Contents

Convert to different timeframes

Compression

The Balsam.Compression namespace contains classes designed to compress or convert data to different timeframes and even different bar types. The BarSeries class itself exposes the following convenience methods which call common compression routines using the default values:

  • ToIntraday() converts intraday data to higher timeframes. For example, to convert one minute bars to hourly call ToIntraday(60).
  • ToDaily() converts intraday data to daily bars ending at a specified time of day.
  • ToWeekly() converts daily data to weekly assuming a Friday week end.
  • ToMonthly() converts data to monthly bars.

For more fine-grained control, call the Compress() method and pass in a compressor object. In the EventStudy example, we forced the weekly bars to use a Friday date even on weeks when Friday was a holiday by setting UseFixedDates to true.

.Compress(new WeeklyCompression() { UseFixedDates = true });

Conversion

Other classes within this namespace transform intraday data in other ways that can be helpful:

  • To create constant volume bars, use the ConstantVolumeCompression to create bars targeting a fixed number of contracts or shares.
  • To extract the day session from 24 hour trading, use SessionCompression and pass in a start time and end time. A new BarSeries will be returned containing only bars within the specified times.