Migrating from 0.2.x to 1.0#
pyeconomics 1.0 is a rewrite. 0.2.x was four monetary-policy rules on FRED data; 1.0 is a library of models with typed inputs, a data layer of many sources, and a command line, a REST API and an MCP server on top. The rules are still here, and their numbers still match, but no 0.2.x call runs unchanged.
Before you start#
pip install pyeconomicsnow gives you 1.0. To stay on 0.2.6 for now, pinpyeconomics<1: its releases stay on PyPI.0.2.x has ended. 0.2.x received security fixes only and reached end-of-life when pyeconomics 1.0.0 was released, on 2026-11-28, as ADR-0003 promised. It receives no more fixes.
1.0 needs Python 3.12 or later. Try it with
pip install pyeconomics, in a new virtual environment.1.0 is licensed under Apache-2.0. Releases through 0.2.x remain MIT-licensed (Legal notices).
What changed, and why#
A registry of models. 0.2.x exported a function per rule. In 1.0 every model
has a permanent id, such as macro.policy_rule, and one entry point runs them
all: pyeconomics.run(id, ...). A model is a pure function with validated inputs
and outputs, so it never fetches, prints or plots. The four rules are four
calculations of one model. That one registry generates every surface, so a
result is the same bytes in Python, on the command line, over REST and through
MCP.
A data layer. 0.2.x read FRED through a global client. 1.0 reads 31 sources
through pyeconomics.data. You ask for a concept, such as
us.unemployment.rate, and a resolver chooses a source that delivers exactly
that, starting with the body that publishes it. FRED is one source among them
(Data sources and keys).
Real-time vintages. A 0.2.x history used today’s revised data, which nobody
had at the time. pyeconomics.bind reads each series as published on the date you
name, and labels any revised data as revised_data in the result
(Binding models to data).
The manifest. Every result carries how it was produced: the model’s version, the library’s and its dependencies’ versions, a hash of its inputs and outputs, and a record of each series it read (Results and manifests). A number can be checked years later.
Decimals for rates. 0.2.x took and returned percent, so 2.5 meant 2.5%. Every
rate in 1.0 is a decimal, so 2.5% is 0.025. Every input and output declares its
unit.
Licence classes. Every source declares what its terms allow, and data flows
only where they allow it. FRED’s terms forbid storing its data and passing it to a
language model, so 1.0 never writes FRED data to disk and never sends it to an AI
assistant (Data sources and keys). 0.2.x kept FRED data in a local pickle cache:
delete the cache directory it left beside the package.
The four rules#
These examples hold one economy fixed: inflation and unemployment both at 3.5%, a natural rate of 4.2%, a real rate of 2%, a policy rate of 5.375%, policy inertia of 0.7 and the lower bound on. Each 0.2.x call and its result come from the recorded behaviour of 0.2.6, and a test holds both blocks to that record.
Every 1.0 weight below is the model’s default, which is 0.2.x’s default too. A result is no longer rounded, so these examples round it to compare.
Taylor rule#
>>> taylor_rule(
... EconomicIndicators(
... current_inflation_rate=3.5,
... current_unemployment_rate=3.5,
... natural_unemployment_rate=4.2,
... long_term_real_interest_rate=2.0,
... current_fed_rate=5.375,
... ),
... TaylorRuleParameters(rho=0.7, apply_elb=True),
... )
5.85
>>> import pyeconomics
>>> result = pyeconomics.run(
... "macro.policy_rule",
... calculation="taylor_1993",
... inflation=0.035,
... unemployment=0.035,
... natural_unemployment=0.042,
... neutral_real_rate=0.02,
... previous_rate=0.05375,
... smoothing=0.7,
... lower_bound=0.00125,
... )
>>> round(result.outputs.prescribed_rate * 100, 2)
5.85
Balanced approach rule#
>>> balanced_approach_rule(
... EconomicIndicators(
... current_inflation_rate=3.5,
... current_unemployment_rate=3.5,
... natural_unemployment_rate=4.2,
... long_term_real_interest_rate=2.0,
... current_fed_rate=5.375,
... ),
... BalancedApproachRuleParameters(rho=0.7, apply_elb=True),
... )
6.06
>>> result = pyeconomics.run(
... "macro.policy_rule",
... calculation="balanced_approach",
... inflation=0.035,
... unemployment=0.035,
... natural_unemployment=0.042,
... neutral_real_rate=0.02,
... previous_rate=0.05375,
... smoothing=0.7,
... lower_bound=0.00125,
... )
>>> round(result.outputs.prescribed_rate * 100, 2)
6.06
Balanced approach shortfalls rule#
The option use_shortfalls_rule=True is now a calculation of its own. With
unemployment below its natural rate there is no shortfall, so this rule ignores the
tight labour market and prescribes less than the rule above.
>>> balanced_approach_rule(
... EconomicIndicators(
... current_inflation_rate=3.5,
... current_unemployment_rate=3.5,
... natural_unemployment_rate=4.2,
... long_term_real_interest_rate=2.0,
... current_fed_rate=5.375,
... ),
... BalancedApproachRuleParameters(
... rho=0.7, apply_elb=True, use_shortfalls_rule=True
... ),
... )
5.64
>>> result = pyeconomics.run(
... "macro.policy_rule",
... calculation="balanced_approach_shortfalls",
... inflation=0.035,
... unemployment=0.035,
... natural_unemployment=0.042,
... neutral_real_rate=0.02,
... previous_rate=0.05375,
... smoothing=0.7,
... lower_bound=0.00125,
... )
>>> round(result.outputs.prescribed_rate * 100, 2)
5.64
First-difference rule#
This rule reads last year’s unemployment rate and natural rate, and no real rate.
>>> first_difference_rule(
... EconomicIndicators(
... current_inflation_rate=3.5,
... current_unemployment_rate=3.5,
... natural_unemployment_rate=4.2,
... lagged_unemployment_rate=4.0,
... lagged_natural_unemployment_rate=4.2,
... current_fed_rate=5.375,
... ),
... FirstDifferenceRuleParameters(rho=0.7, apply_elb=True),
... )
5.75
>>> result = pyeconomics.run(
... "macro.policy_rule",
... calculation="first_difference",
... inflation=0.035,
... unemployment=0.035,
... natural_unemployment=0.042,
... unemployment_lagged=0.04,
... natural_unemployment_lagged=0.042,
... previous_rate=0.05375,
... smoothing=0.7,
... lower_bound=0.00125,
... )
>>> round(result.outputs.prescribed_rate * 100, 2)
5.75
Where the numbers differ#
Every recorded 0.2.6 output either matches 1.0 at two decimals or falls under one of three named differences, which a test proves case by case:
Half-way rounding. 0.2.x rounded every result to two decimals, in percent. Where the exact result sits on a half-way value (x.xx5), the two versions’ arithmetic land on either side of it in the last bit and round 0.01 apart. 1.0 does not round.
The lower bound comes after smoothing. 0.2.x floored the rule’s rate and then smoothed it, so a smoothed rate could fall below the bound. 1.0 smooths and then floors, so a prescription never sits below the bound.
The lagged gap in a history. 0.2.x’s historical first-difference table reused the first month’s lagged gap for the second and third months of a quarter. In 1.0 each month reads its own unemployment rate a year earlier.
Every public name#
0.2.x’s public names, and what replaces each. pyeconomics.data was a module of
dataclasses in 0.2.x and is the data layer in 1.0, so an old import there fails
rather than doing something else.
Rules and estimates#
0.2.x |
1.0 |
Notes |
|---|---|---|
|
|
Pass values, or bind them to data (below) |
|
|
With |
|
|
|
|
One run per calculation |
Removed: the four-row table was a view of four runs (below) |
|
|
Removed: a model reads no history itself (below) |
|
The same |
|
|
The same |
|
|
The same, one calculation at a time |
Inputs and options#
The dataclasses are gone: every input is a named field of the run, and validated.
0.2.x |
1.0 |
Notes |
|---|---|---|
|
The run’s input fields |
Rates divided by 100 |
|
The run’s input fields |
|
|
The run’s input fields |
|
|
The run’s input fields |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A catalog concept, not a FRED id |
|
|
|
|
|
|
|
|
|
|
|
A decimal: |
|
|
|
|
|
In output-gap units: the balanced approach’s |
|
|
|
|
|
Needs |
|
|
A decimal: |
|
|
|
|
|
|
|
|
Removed: a model prints nothing |
Printing and plotting#
Models print and plot nothing, so a result is data you can show as you like. matplotlib is no longer a dependency.
0.2.x |
1.0 |
Notes |
|---|---|---|
|
|
Removed |
|
|
Removed, with its advice to raise or lower the rate: 1.0 reports the rule’s rate and advises nothing |
|
The same |
Removed |
|
The same |
Removed |
|
The same |
Removed |
|
|
Removed |
|
The same |
Removed |
|
The same |
Removed |
|
The same |
Removed. |
FRED and the cache#
0.2.x |
1.0 |
Notes |
|---|---|---|
|
|
Removed: importing 0.2.x built this client, and failed with no key. 1.0 reads a key only when a source needs one |
|
The same |
Removed |
|
|
Values are decimals |
|
|
|
|
|
|
|
|
|
|
|
A field you pass is not fetched |
|
Nothing |
Removed: there is no global client |
|
|
Before 16 December 2008, when the target was one number, read |
|
Automatic |
Removed: the data layer caches what a source’s terms allow, as JSON, never a pickle (The cache and offline mode) |
|
Automatic |
Removed |
|
|
Still read |
The keyring entry |
|
Store it again: 1.0 reads service |
Live data#
In 0.2.x, leaving out an indicator fetched it from FRED. In 1.0 you say so: bind
reads the data, run runs it, and the result records every series it read. On the
command line, any data option does both. These read live data, and need your keys
for the sources they reach (Keys and configuration):
$ pyeconomics models run macro.policy_rule --calculation taylor_1993 --profile default
$ pyeconomics models run macro.policy_rule --calculation taylor_1993 --as-of 2024-06-28
From Python, the same run is
pyeconomics.run("macro.policy_rule", pyeconomics.bind("macro.policy_rule", calculation="taylor_1993", as_of=date)).
The default series changed. 1.0’s default profile reads core PCE inflation, the Holston-Laubach-Williams real rate and the effective federal funds rate, where 0.2.x read FRED’s trimmed-mean PCE, the ten-year TIPS yield and the top of the target range, so the same date gives a different answer. To read 0.2.x’s series, name their concepts:
$ pyeconomics models run macro.policy_rule --calculation taylor_1993 --as-of 2024-06-28 --concept inflation=us.inflation.pce_trimmed_mean.yoy --concept neutral_real_rate=us.treasury.real_10y --concept previous_rate=us.policy_rate.target_upper
0.2.x FRED series |
1.0 concept |
Read by default? |
|---|---|---|
|
|
No: |
|
|
Yes |
|
|
Yes |
|
|
No: |
|
|
No: |
Several rules or dates#
calculate_policy_rule_estimates gave one table of four rules. Loop over the
calculations instead:
>>> economy = {
... "inflation": 0.035,
... "unemployment": 0.035,
... "natural_unemployment": 0.042,
... "neutral_real_rate": 0.02,
... }
>>> for calculation in ("taylor_1993", "balanced_approach"):
... run = pyeconomics.run("macro.policy_rule", calculation=calculation, **economy)
... print(calculation, round(run.outputs.prescribed_rate * 100, 2))
taylor_1993 6.95
balanced_approach 7.65
A historical_* function fetched a history and returned a table. With your own
table, run_batch gives one row per date, in order:
>>> import pandas as pd
>>> history = pd.DataFrame(
... {
... "calculation": ["taylor_1993"] * 3,
... "inflation": [0.035, 0.03, 0.025],
... "unemployment": [0.035, 0.04, 0.045],
... "natural_unemployment": [0.042, 0.042, 0.042],
... "neutral_real_rate": [0.02, 0.02, 0.02],
... }
... )
>>> batch = pyeconomics.run_batch("macro.policy_rule", history)
>>> batch.to_pandas()["outputs.prescribed_rate"].round(4).tolist()
[0.0695, 0.057, 0.0445]
To read data as it stood on each date instead, run bind once per date. That
reads real-time vintages where a source keeps them, and labels revised data where
one does not. 0.2.x’s forward-fill of missing months is gone too: each field reads
its last observation on or before the date, by a rule the model declares.
Next#
Tutorials walks through 1.0 from the start, and the macro.policy_rule page has the rules’ formulas and every input.