> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a market

> Name the programs to compare, such as a current and a proposed program, and put their premiums on one basis.

A market holds named programs to rate on the same book. This market compares the example program
with a proposed version that raises the collision base rate by 5%:

```python theme={null}
from decimal import Decimal

from relativities import Market, Program

current = Program.load("effective://example-ca-ppa")
rates = current.rater.tables["BaseRate"]
collision = rates["coverage"] == "collision"
rates.loc[collision, "rate"] = rates.loc[collision, "rate"] * Decimal("1.05")
proposed = current.with_rater(current.rater.with_tables({"BaseRate": rates}))
market = Market({"current": current, "proposed": proposed})
market  # Market(current, proposed)
```

`with_tables` builds a new rater from the edited table, with its own `bundle_id`. `with_rater` pairs
it with the same `prepare` and schema.

```mermaid theme={null}
flowchart LR
  book["Book"] --> current["current: example-ca-ppa"]
  book --> proposed["proposed: collision base rate +5%"]
  current --> rows["One row per submission and program"]
  proposed --> rows
```

## Choose the columns to compare

Each rater names its own outcomes. Give each program a `read` that returns the columns to compare.
This `read` keeps the premium and adds the policy's collision premium:

```python theme={null}
def with_collision(inputs, outputs):
    """The annual premium, and the collision premium of every vehicle together."""
    collision = sum(vehicle["coverage_premium"]["collision"] for vehicle in outputs["vehicles"])
    return {"premium": outputs["premium"], "collision": collision}


market = Market({"current": current.with_read(with_collision), "proposed": proposed.with_read(with_collision)})
```

Programs whose `read` returns the same name share that column. To compare carriers with different
premium terms, put each premium on one term in its `read`, and state that conversion in the exhibit.

## Add other programs

Add any program by name, such as a competitor from your catalog or a file. Each program keeps its own
schema and `prepare`, so one book serves every program. [Load a program](/relativities/how-to/load-a-program)
lists the sources.

## Close the market

Closing a market closes each program's rater:

```python theme={null}
market.close()
```

`with Market(...) as market:` closes the market at the end of the block.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.