backtrader.filters.calendardays module

Calendar Days Filter Module - Calendar day filling.

This module provides the CalendarDays filter for adding missing calendar days to trading day data.

Classes:

CalendarDays: Fills missing calendar days.

示例

>>> data = bt.feeds.GenericCSVData(dataname='data.csv')
>>> data.addfilter(bt.filters.CalendarDays())
>>> cerebro.adddata(data)
class backtrader.filters.calendardays.CalendarDays[源代码]

基类:ParameterizedBase

Bar Filler to add missing calendar days to trading days

Params:

  • fill_price (def: None):

    > 0: The given value to fill 0 or None: Use the last known closing price -1: Use the midpoint of the last bar (High-Low average)

  • fill_vol (def: float('NaN')):

    Value to use to fill the missing volume

  • fill_oi (def: float('NaN')):

    Value to use to fill the missing Open Interest

params = (('fill_price', None), ('fill_vol', nan), ('fill_oi', nan))
ONEDAY = datetime.timedelta(days=1)
lastdt = datetime.date(9999, 12, 31)
__init__(data, **kwargs)[源代码]

Initialize the CalendarDays filter.

参数:
  • data -- The data feed to apply the filter to.

  • **kwargs -- Additional keyword arguments passed to parent class.

__call__(data)[源代码]

If the data has a gap larger than 1 day amongst bars, the missing bars are added to the stream.

Params:
  • data: the data source to filter/process

返回:

this filter does not remove bars from the stream

返回类型:

  • False (always)