Skip to content

Strategy

Strategy

data property

The first data source used by the strategy.

datas property

The data sources used by the strategy.

index property

The index of the data used by the strategy.

Indicator(data, ffill=False, bfill=False)

Creates an indicator for the strategy.

Parameters:

Name Type Description Default
data ndarray | Series

The data to create the indicator from.

required
ffill bool

Whether to forward fill the data.

False
bfill bool

Whether to backward fill the data.

False

Returns:

Type Description
Indicator

The indicator.

__init__(commission=None, context=None, cash=10000, margin=None, multiplier=1)

Strategy is the base class for all strategies.

Parameters:

Name Type Description Default
commission Commission | None

The commission object to use to calculate commissions.

None
context PricingData | None

The pricing data to use. If None, a new pricing data object will be created.

None
cash float

The starting cash to use. If None, the starting cash will be 10,000.

10000
margin Margin | None

The margin object to use. If None, a new margin object will be created.

None
multiplier float

The multiplier to the orders in the backtest.

1

add_data(data, name=None)

Adds a data source to the strategy.

Parameters:

Name Type Description Default
data DataSource

The data source to add.

required
name str | None

The name of the data source. If None, the name will be the same as the data source.

None