# Strategy parameters



Use `openbacktesting.inputs` to declare configurable class attributes. Read the resolved values as `self.length`, `self.enabled`, etc. inside your strategy. Parameters are read-only during a run.

[int](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-int) · [float](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-float) · [bool](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-bool) · [string](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-string) · [price](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-price) · [time](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-time) · [session](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-session) · [color](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-color) · [enum](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-enum) · [describe](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-describe) · [request_for](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-request-for) · [InputError](https://docs.openbacktesting.com/reference/inputs/#openbacktesting-inputs-inputerror)

## Declare and override parameters

```python
from openbacktesting import Backtest, Strategy, inputs
from openbacktesting.test import GOOG

class Configurable(Strategy):
    length = inputs.int(20, title="Average length", minval=1, maxval=200)
    enabled = inputs.bool(True, title="Trade")

    def init(self):
        self.average = self.ta.ema(length=self.length)

    def next(self):
        if self.enabled and self.average.valid[-1] and not self.position:
            self.buy(qty=1)

bt = Backtest(GOOG, Configurable, end_policy="close_at_last_close")
result = bt.run(length=30, enabled=True)
print(result["# Trades"])
```

`bt.run` uses Python field names; `title` is the unique display/configuration key. Duplicate titles, including inherited titles, are rejected. Defaults apply to omitted values. An invalid override raises `InputError` before strategy execution.

## Choose a type

| Factory and example | Runtime value | Optional domain controls |
| --- | --- | --- |
| `inputs.int(20, title="Length", minval=1)` | `int`; rejects bool and float | `options` **or** `minval/maxval/step` |
| `inputs.float(0.5, title="Threshold", minval=0)` | Finite `float` | Same as int |
| `inputs.bool(True, title="Enabled")` | `bool`, without numeric/string coercion | None |
| `inputs.string("fast", title="Mode", options=["fast", "slow"])` | `str` | `options` |
| `inputs.price(100.0, title="Entry price")` | Finite `float` | No numeric bounds/options |
| `inputs.time(0, title="Start time")` | Integer Unix **milliseconds** | None |
| `inputs.session("0930-1600:23456", title="Session")` | Normalized session string | None; does not filter data automatically |
| `inputs.color("#22AA44", title="Line color")` | Immutable `Color` | None |
| `inputs.enum(Mode.FAST, title="Mode")` | Member of your Python Enum | `options` of that enum type |

All factories require a default and `title`. Numeric `options` cannot be combined with bounds or step. `step` is a suggested adjustment increment, not a divisibility check. Session weekday numbers are Sunday=1 through Saturday=7; `24x7` means all times/days. Your strategy must implement any session filter.

Shared presentation arguments are `tooltip`, `group`, `inline`, `display`, `active`, and `confirm`. They describe controls for a consuming application; this package does not display a settings UI. `active={"title": "Enabled"}` can refer to a boolean input; inactive/hidden fields still validate and retain values.

## Inspect or submit a title-based configuration

```python
schema = inputs.describe(Configurable)
request = inputs.request_for(Configurable, {"length": 40})
result = bt.run_inputs(request)
print(result.attrs["input_snapshot"])
```

Continue from the first example. `request_for` accepts Python field names and constructs the title-keyed request, including schema identity. Applications can use `describe` to build controls and `run_inputs` to submit a request with `schemaVersion`, `schemaHash`, and `values`. Rediscover after changing declarations; old schema hashes are rejected. Native color overrides accept `Color` or hex strings, while serialized requests use hex strings. Enum requests use member names.

## Declaration signatures

The shared factory signatures expose all domain keywords; only the combinations in the type table are accepted. `...` below means omit that option, not pass `None` or an ellipsis.

<a id="openbacktesting-inputs-int"></a>



## int

```python
inputs.int(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-float"></a>



## float

```python
inputs.float(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-bool"></a>



## bool

```python
inputs.bool(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-string"></a>



## string

```python
inputs.string(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-price"></a>



## price

```python
inputs.price(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-time"></a>



## time

```python
inputs.time(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-session"></a>



## session

```python
inputs.session(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-color"></a>



## color

```python
inputs.color(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-enum"></a>



## enum

```python
inputs.enum(
    defval,
    *,
    title,
    tooltip='',
    group='',
    inline='',
    display=None,
    active=True,
    confirm=False,
    options=...,
    minval=...,
    maxval=...,
    step=...,
)
```

Declare read-only strategy configuration fields; inputs.bool/int/float and other entry points bind the kind.

<a id="openbacktesting-inputs-describe"></a>



## describe

```python
inputs.describe(strategy_class)
```

Export an independent JSON definition of the loaded strategy class without running it.

<a id="openbacktesting-inputs-request-for"></a>



## request_for

```python
inputs.request_for(strategy_class, kwargs)
```

Convert Python field kwargs for a declared strategy_class into a title-based request; first confirm the class contains Input; invalid values raise InputError.

<a id="openbacktesting-inputs-inputerror"></a>



## InputError

Parameter error that callers can display using code/title/expected/actual_type.

Catch `InputError` when accepting user configuration. Its `code`, `title`, `expected`, and `actual_type` identify the rejected input.

[Strategy](https://docs.openbacktesting.com/reference/strategy/index.md) · [Colors](https://docs.openbacktesting.com/reference/colors/index.md) · [Saved experiments](https://docs.openbacktesting.com/reference/optimizer/index.md) · [User manual](https://docs.openbacktesting.com/index.md)
