Skip to content

SeriesSampler

QuantConnect.SeriesSampler

SeriesSampler(resolution: timedelta)

Bases: Object

A type capable of taking a chart and resampling using a linear interpolation strategy

Creates a new SeriesSampler to sample Series data on the specified resolution

Parameters:

Name Type Description Default
resolution timedelta

The desired sampling resolution

required

step

step: timedelta

The desired sampling resolution

This codeEntityType is protected.

sub_sample

sub_sample: bool

True if sub sampling is enabled, if false only subsampling will happen

interpolate

interpolate(
    x_0: float,
    y_0: Optional[float],
    x_1: float,
    y_1: Optional[float],
    x_target: float,
    step: float,
) -> Optional[float]

Linear interpolation used for sampling

This codeEntityType is protected.

sample

sample(
    series: BaseSeries,
    start: Union[datetime, date],
    stop: Union[datetime, date],
    truncate_values: bool = False,
) -> BaseSeries

Samples the given series

Parameters:

Name Type Description Default
series BaseSeries

The series to be sampled

required
start Union[datetime, date]

The date to start sampling, if before start of data then start of data will be used

required
stop Union[datetime, date]

The date to stop sampling, if after stop of data, then stop of data will be used

required
truncate_values bool

True will truncate values to integers

False

Returns:

Type Description
BaseSeries

The sampled series.

sample_chart

sample_chart(
    chart: Chart,
    start: Union[datetime, date],
    stop: Union[datetime, date],
) -> Chart

Samples the given chart

Parameters:

Name Type Description Default
chart Chart

The chart to be sampled

required
start Union[datetime, date]

The date to start sampling

required
stop Union[datetime, date]

The date to stop sampling

required

Returns:

Type Description
Chart

The sampled chart.

sample_charts

sample_charts(
    charts: IDictionary[str, Chart],
    start: Union[datetime, date],
    stop: Union[datetime, date],
) -> Dictionary[str, Chart]

Samples the given charts

Parameters:

Name Type Description Default
charts IDictionary[str, Chart]

The charts to be sampled

required
start Union[datetime, date]

The date to start sampling

required
stop Union[datetime, date]

The date to stop sampling

required

Returns:

Type Description
Dictionary[str, Chart]

The sampled charts.