opensced 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,164 @@
1
+ """ERCOT's rulebooks, one per effective date.
2
+
3
+ Each entry under `notes` says where the number comes from: 'protocols' (read from ERCOT's Nodal Protocols or a
4
+ market notice) or 'measured' (fitted to ERCOT's own disclosed dispatch, because the public documents do not state it).
5
+ """
6
+ from opensced.core.rules import Limit, Product, Rulebooks, Rules, Status
7
+
8
+ def _products(pfr_reserved_mw):
9
+ """ERCOT's reserve products. The last three entries of each say where the adapter finds the product in ERCOT's
10
+ files: the capability columns of the SCED disclosure, the price columns of the reserve offer disclosure (block
11
+ number left out) and the kinds of offer that can carry it."""
12
+ return (
13
+ Product('RegUp', 'up', duration_hours=0.5, regulation=True, ramp_minutes=5,
14
+ capability_columns=('ASCapREGUP',), offer_price_columns=('REGUP',), offer_kinds=('ONRES',)),
15
+ Product('RegDown', 'down', duration_hours=0.5, regulation=True, ramp_minutes=5,
16
+ capability_columns=('ASCapREGDN',), offer_price_columns=('REGDN',), offer_kinds=('REGDN',)),
17
+ Product('RRS-PFR', 'up', duration_hours=0.5, demand='RRS', reserved_mw=pfr_reserved_mw,
18
+ capability_columns=('ASCapRRSPFR',), offer_price_columns=('RRSPFR',), offer_kinds=('ONRES',)),
19
+ Product('RRS-FFR', 'up', duration_hours=0.25, demand='RRS',
20
+ capability_columns=('ASCapRRSFFR',), offer_price_columns=('RRSFFR',), offer_kinds=('ONRES',)),
21
+ Product('RRS-UFR', 'up', duration_hours=0.25, demand='RRS',
22
+ capability_columns=('ASCapRRSUFR',), offer_price_columns=('RRSUFR',), offer_kinds=('ONRES',)),
23
+ Product('ECRS', 'up', duration_hours=1.0, ramp_minutes=10,
24
+ capability_columns=('ASCapECRS',), offer_price_columns=('ECRS',), offer_kinds=('ONRES', 'OFFNS')),
25
+ Product('NonSpin', 'up', duration_hours=4.0, ramp_minutes=30,
26
+ capability_columns=('ASCapNSPIN',), offer_price_columns=('NSPIN',), offer_kinds=('ONRES', 'OFFNS')),
27
+ )
28
+
29
+
30
+ # Telemetered Resource Status (Protocols 3.9.1(5)(b)): what SCED may do with a resource in each.
31
+ _ONLINE = {'ONRES': None, 'REGDN': None}
32
+ _RRS_ECRS = ('RRS-PFR', 'RRS-FFR', 'RRS-UFR', 'ECRS')
33
+ STATUSES = (
34
+ Status('ON', True, _ONLINE), Status('ONRUC', True, _ONLINE), Status('ONOPTOUT', True, _ONLINE), Status('ONEMR', True, _ONLINE),
35
+ Status('ONOS', True, _ONLINE), # on an Output Schedule: held by ERCOT's proxy curve
36
+ # off-line quick start: available for SCED deployment. Its ECRS is offered as an on-line reserve (ONRES), because it
37
+ # can be on within ten minutes; its Non-Spin through either kind of offer
38
+ Status('OFFQS', True, {'ONRES': ('ECRS', 'NonSpin')}),
39
+ # an off-line unit is awarded only what it submitted: ERCOT's proxy offer is not used for its capacity ...
40
+ Status('OFF', False, {'OFFNS': ('NonSpin',)}, proxy_reserves=False),
41
+ # ... unless it is a quick-start unit that happens to telemeter OFF (the adapter's `quick_start` names them)
42
+ Status('OFF-QS', False, {'OFFNS': ('NonSpin',)}),
43
+ Status('ONSC', False, {'ONRES': _RRS_ECRS}), # synchronous condenser
44
+ # starting up: held at its base point and "not eligible for an Ancillary Service award" (3.9.1(5)(b)) ...
45
+ Status('STARTUP'),
46
+ # ... except the units 6.4.9.1.1(4)-(5) name: a quick-start unit, and an off-line unit that was carrying Non-Spin and
47
+ # starts while ERCOT has Non-Spin deployed. They keep Non-Spin, on their on-line offer, up to HSL less base point.
48
+ # The adapter's `startup_non_spin` names them
49
+ Status('STARTUP-NS', False, {'ONRES': ('NonSpin',)}),
50
+ Status('ONTEST'), Status('ONHOLD'), Status('SHUTDOWN'), Status('OUT'), Status('EMR'), Status('EMRSWGR'),
51
+ Status('ONL', True, {'ONRES': None}), # a Load Resource that is on-line
52
+ Status('OUTL'),
53
+ Status('ONREG', True, _ONLINE), Status('ONDSR', True, _ONLINE), Status('ONRR', True, _ONLINE), Status('FRRSUP', True, _ONLINE), # retired: older files
54
+ )
55
+
56
+
57
+ RTC_B = Rules(
58
+ name='ercot/2025-12-05',
59
+ effective='2025-12-05',
60
+ source='Real-Time Co-optimization plus Batteries (RTC+B) go-live, December 5, 2025',
61
+ shortage_price=None, # = voll + offer_cap + shortage_adder = 11,052.01
62
+ voll=5000.0,
63
+ offer_cap=2000.0,
64
+ offer_floor=-250.0,
65
+ shortage_adder=4052.01,
66
+ surplus_price=-250.0,
67
+ default_max_shadow_price=5251.0,
68
+ block_mw=5.0,
69
+ dispatch_limits='ramp',
70
+ interval_hours=5 / 60,
71
+ regulation_share=5 / 7,
72
+ products=_products(pfr_reserved_mw=1365.0),
73
+ limits=(
74
+ Limit('FFR', ('RRS-FFR',), max_mw=450.0, source='AS methodology, RRS: fast frequency response is limited to 450 MW'),
75
+ Limit('relay loads + FFR', ('RRS-FFR', 'RRS-UFR'), max_share=0.60, of='RRS',
76
+ source='Protocols 3.16(4): load resources on under-frequency relays and FFR are limited to 60% of the RRS requirement'),
77
+ Limit('ECRS from loads', ('ECRS',), max_share=0.50, of='ECRS', where=(('type', 'NCLR'),),
78
+ source='Protocols 3.16(7): load resources other than controllable ones are limited to 50% of the ECRS requirement'),
79
+ Limit('Non-Spin from loads', ('NonSpin',), max_less=1430.2, of='NonSpin', where=(('type', 'NCLR'),),
80
+ source='AS methodology, Non-Spin: Non-Spin from SCED-dispatchable resources is at least the lower of the Most Severe '
81
+ 'Single Contingency and the hour\'s Non-Spin requirement'),
82
+ ),
83
+ price_cap=None, # = voll
84
+ shift_factor_cutoff=0.0001,
85
+ storage_charge_efficiency=0.85,
86
+ block_refine=3,
87
+ self_arranged_price=-10000.0, reserve_offer_floor=-1e9,
88
+ statuses=STATUSES,
89
+ two_step=True,
90
+ mitigated_offer_floors={'nuclear': -250.0, 'hydro': -250.0, 'coal': -20.0, 'combined_cycle': -20.0, 'gas_steam_ct': -20.0,
91
+ 'qf': -50.0, 'wind': -100.0, 'pv': -50.0, 'esr': -250.0, 'other': -50.0},
92
+ mitigation_adder_share=0.0,
93
+ generic_heat_rates={'in_service_by_2004': 10.5, 'in_service_after_2004': 14.5},
94
+ shadow_price_caps={'base': 5251.0, 'above_200kv': 4500.0, '100_to_200kv': 3500.0, 'below_100kv': 2800.0},
95
+ features=('network', 'reserves', 'storage'),
96
+ notes={
97
+ 'shortage_price': 'protocols: effective value of lost load 5,000 + effective system-wide offer cap 2,000 + 4,052.01',
98
+ 'surplus_price': 'protocols: the over-generation penalty',
99
+ 'default_max_shadow_price': 'a fallback, used only when ERCOT publishes a constraint without its maximum shadow price',
100
+ 'dispatch_limits': 'protocols 6.5.7.3: SCED dispatches each resource between its LDL and HDL. Measured on three days of 2026: '
101
+ 'about 200 resources per run have an HDL up to 0.05 MW above their HSL (6 MW per run in all), and the base point '
102
+ 'follows the HDL on nearly nine in ten of them; no base point is above its HDL beyond rounding. With reserves '
103
+ 'awarded, base point + upward awards stays within the higher of HSL and HDL',
104
+ 'regulation_share': 'protocols 6.5.7.3(12): a scaling factor of 5/7 on Reg-Up against HDL and on Reg-Down against LDL',
105
+ 'price_cap': 'protocols 6.5.7.3(14)(d): system lambda and reserve prices are capped at the effective value of lost load, 5,000',
106
+ 'shift_factor_cutoff': 'protocols Section 22 Attachment P 3.3: default cutoff 0.0001',
107
+ 'Non-Spin from loads': 'the methodology does not print the Most Severe Single Contingency. Measured on four days of 2026: with '
108
+ 'a Non-Spin requirement of 1,455 / 1,477 / 1,223 MW the non-controllable loads together hold exactly '
109
+ '24.8 / 46.8 / 0 MW in every run of the hour (25.0 / 47.0 / 0 in the day-ahead market), at a clearing price '
110
+ 'above their offers; in every other hour they are awarded in full. That is the requirement less 1,430.2 MW '
111
+ '(1,430 day-ahead). The requirement is the AS Plan (NP4-33-CD), not the demand curve\'s total MW: without '
112
+ 'the plan file the limit cannot bind',
113
+ 'limits': 'written as procurement rules (3.16 and the AS methodology, which says "DAM will limit"); applied here in real time too',
114
+ 'duration_hours': 'Section 8.1.1.3 qualification times: Reg-Up, Reg-Down and RRS-PFR 30 min, RRS-FFR 15 min, ECRS 1 h, Non-Spin 4 h. '
115
+ 'Measured against ERCOT awards on seven days: about 361,000 battery-runs with upward awards, none breaks the '
116
+ 'stored-energy rule and two thirds sit exactly on it; 31,450 battery-runs with Reg-Down, none breaks the '
117
+ 'charge-side rule at 30 min times the battery\'s efficiency and one in five sits exactly on it',
118
+ 'storage_charge_efficiency': 'protocols 3.7.1.3(1)(c): Round Trip Efficiency is a registered Resource Parameter and is not published. '
119
+ 'helpers.battery_efficiency() reads each battery\'s value off ERCOT\'s Reg-Down awards (0.81 to 1.0; '
120
+ 'a third of batteries have no award to read it from). 0.85 is the most common value, used for the rest',
121
+ 'self_arranged_price': 'measured on four days (190,980 load-runs with self-provided reserves): the ECRS award equals the self-provided '
122
+ 'ECRS, or the room left after RRS, on 97%; where room is short RRS is filled first on 95%. A load is '
123
+ 'never awarded anything while not ONL (341,380 load-runs). The price is only a device to make the clearing '
124
+ 'take self-provided MW first; it is never the marginal offer. An award equals the offer MW used for it, so a block '
125
+ 'priced this low is always awarded',
126
+ 'statuses_startup': 'Protocols 3.9.1(5)(b): a unit in STARTUP is not eligible for an Ancillary Service award. 6.4.9.1.1(4)-(5) '
127
+ 'keep Non-Spin for an off-line unit that starts after a Non-Spin deployment and for a quick-start unit, up '
128
+ 'to HSL less base point. Measured on 13 days with deployment times (7,353 unit-runs in STARTUP, 37 awarded): '
129
+ 'awarding a quick-start unit always, and a unit that carried off-line Non-Spin before starting while ERCOT '
130
+ 'has Non-Spin deployed, on its on-line offer row, agrees with ERCOT to 0.5 MW on 36 of 39 unit-runs. Giving '
131
+ 'every starting unit its off-line offer agreed on 33 of 122. ECRS is never awarded (13,103 unit-runs). When '
132
+ 'ERCOT had Non-Spin deployed is in its operations messages, not in any data report',
133
+ 'statuses_offqs': 'measured on two days (3,093 unit-runs): an off-line quick-start unit is awarded ECRS and Non-Spin from its '
134
+ 'ONRES row only. Its OFFNS row repeats the same MW and is not added',
135
+ 'shadow_price_caps': 'protocols Section 22 Attachment P: base case 5,251; contingency by voltage 4,500 / 3,500 / 2,800',
136
+ 'statuses': 'protocols 3.9.1(5)(b). Which off-line units get ERCOT\'s proxy offer (6.5.7.3(5), "qualified Resources") is measured on three '
137
+ 'days: a quick-start unit does, whether it telemeters OFFQS (74 of 74 unit-runs awarded above the MW it submitted) or '
138
+ 'OFF (6 of 6 awarded at full capability with nothing submitted); any other off-line unit does not (0 of 10 with the '
139
+ 'proxy price under the clearing price, and 0 of 4 above its submitted MW)',
140
+ 'storage_signed_energy': 'measured: base point x 5 minutes (signed) + awards x duration <= SOC - MinSOC holds on every one of '
141
+ 'about 260,000 battery-runs with upward awards on five days of 2026, and about 40% sit exactly on it',
142
+ 'two_step': 'protocols 6.5.7.3(14): step 1 on competitive constraints gives reference prices; step 2 floors and caps the offers',
143
+ 'mitigated_offer_floors': 'protocols 4.4.9.4.2',
144
+ 'generic_heat_rates': 'protocols 4.4.9.4.1: generic incremental heat rate 10.5 for commercial operation on or before January 1, 2004, else 14.5',
145
+ 'mitigation_adder_share': 'protocols 6.5.7.3(14)(b)(i): "a variable not to exceed 0.01". The value ERCOT uses is not stated; 0 here',
146
+ 'ramp_minutes': 'reconstructed: awards against disclosed capability (Reg 5, ECRS 10, Non-Spin 30 minutes)',
147
+ 'RRS-PFR reserved_mw': 'AS methodology: RRS from primary frequency response shall not be less than 1,365 MW (2025) / '
148
+ '1,377 MW (2026), and ERCOT may set a higher value by month. Confirmed in the disclosure: the '
149
+ 'RRS-PFR awarded sits at exactly this many MW in nearly every run',
150
+ 'block_mw': 'a modelling choice, not an ERCOT rule: the step used to cut sloped offer curves',
151
+ 'not modelled': "ERCOT's demand target (not published: the sum of base points is used); the rule that a "
152
+ 'non-controllable load may not hold Non-Spin together with RRS or ECRS (it needs a yes/no choice per '
153
+ 'load, which a linear program cannot make); the reliability deployment price adder (a second pricing run)',
154
+ },
155
+ )
156
+
157
+ PFR_1377 = RTC_B.replace(
158
+ name='ercot/2026-01-01',
159
+ effective='2026-01-01',
160
+ source='ERCOT Methodologies for Determining Minimum Ancillary Service Requirements, effective January 1, 2026: RRS from primary frequency response at least 1,377 MW (was 1,365)',
161
+ products={'RRS-PFR': {'reserved_mw': 1377.0}},
162
+ )
163
+
164
+ ALL = Rulebooks([RTC_B, PFR_1377])
@@ -0,0 +1,276 @@
1
+ Metadata-Version: 2.5
2
+ Name: opensced
3
+ Version: 0.1.0
4
+ Summary: An open market-clearing engine for power markets: offers, limits, reserve demand and network constraints in; prices at every node out. First market: ERCOT real-time co-optimization.
5
+ Project-URL: Repository, https://github.com/anthonyrizkallah/opensced
6
+ Project-URL: Documentation, https://github.com/anthonyrizkallah/opensced/tree/main/docs
7
+ Project-URL: Issues, https://github.com/anthonyrizkallah/opensced/issues
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: ERCOT,LMP,RTC+B,SCED,ancillary services,economic dispatch,power markets
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: numpy>=1.24
17
+ Requires-Dist: pandas>=2.0
18
+ Requires-Dist: scipy>=1.11
19
+ Provides-Extra: exact
20
+ Requires-Dist: highspy>=1.7; extra == 'exact'
21
+ Provides-Extra: parquet
22
+ Requires-Dist: pyarrow>=14; extra == 'parquet'
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=7; extra == 'test'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # opensced
28
+
29
+ An open market-clearing engine for power markets. Give it offers, limits, reserve demand and network constraints for
30
+ one dispatch interval, and it returns the system price, the price at every node, dispatch, reserve awards and reserve
31
+ prices.
32
+
33
+ The first market is **ERCOT's real-time market**: SCED with energy and ancillary services co-optimized, live since
34
+ December 5, 2025. The engine implements ERCOT's clearing rules as a dated rulebook and reads ERCOT's public report
35
+ formats. [docs/clearing_math.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/clearing_math.md) writes out the program it solves.
36
+
37
+ **This repository is the engine only. It ships no market data.** You bring the inputs.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install opensced
43
+ ```
44
+
45
+ Python 3.10 or later. It depends on numpy, pandas and scipy only. The examples and tests are in the
46
+ [repository](https://github.com/anthonyrizkallah/opensced).
47
+
48
+ ## Five minutes, no data
49
+
50
+ ```python
51
+ import opensced
52
+
53
+ case = opensced.examples.three_bus() # a made-up grid: 3 nodes, 3 generators, a battery, one line
54
+ result = opensced.clear(case)
55
+ print(result)
56
+ ```
57
+
58
+ ```text
59
+ Clearing [rules: custom]
60
+ system lambda $54.75 /MWh
61
+ dispatched 250.0 MW across 2 resources
62
+ constraints 1 of 1 binding; highest $82.92 on WEST-CITY
63
+ node prices $5.00 to $54.75 over 3 nodes
64
+ ```
65
+
66
+ ```python
67
+ result.node_prices() # WEST 5.00, NORTH 38.17, CITY 54.75
68
+ result.dispatch # MW per resource
69
+ result.shadow_prices # $/MWh per constraint
70
+ ```
71
+
72
+ Everything is a pandas object. Change an input and clear again:
73
+
74
+ ```python
75
+ opensced.clear(case.copy(demand=300)).system_lambda
76
+ ```
77
+
78
+ ## The clearing
79
+
80
+ One interval is one linear program, solved with HiGHS through scipy:
81
+
82
+ ```text
83
+ minimize energy offer cost + reserve offer cost - value of reserves bought on the demand curves
84
+ + shortage price x shortfall - surplus price x surplus + max shadow price x constraint violations
85
+
86
+ subject to power balance sum of dispatch + shortfall - surplus = demand
87
+ dispatch range each resource between its limits and what its ramp rate can reach
88
+ network flow + sum(shift factor x change in output) <= limit + violation
89
+ reserves energy and awards share each resource's headroom; offers; demand curves; limits
90
+ storage energy and reserve awards fit in each battery's state of charge
91
+ ```
92
+
93
+ Prices are the program's duals:
94
+
95
+ | Price | Is |
96
+ |---|---|
97
+ | System lambda | Dual of the power balance |
98
+ | Shadow price of a constraint | Dual of its row |
99
+ | Node price | `lambda - sum(shift factor x shadow price)` |
100
+ | Reserve clearing price | Dual of the product's demand row |
101
+
102
+ - **Energy.** An offer curve is a sloped line between its points. It is cut into steps and the program is solved
103
+ again with finer steps around each resource's dispatch, so dispatch lands where the line meets the price.
104
+ - **Network.** Only the change in dispatch is multiplied by shift factors; the flow at current outputs is an input.
105
+ A constraint nothing can relieve prices at its maximum shadow price.
106
+ - **Reserves.** Cleared in the same program as energy. Several products can serve one demand curve.
107
+ - **Storage.** Each product has a duration; a battery's awards must fit in the energy it holds.
108
+ - **Mitigation.** Optionally two steps: reference prices from the competitive constraints, then floors and caps.
109
+
110
+ The full formulation is in [docs/clearing_math.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/clearing_math.md). The code for each part is one short file
111
+ in `src/opensced/core/features/`.
112
+
113
+ ## A real ERCOT run
114
+
115
+ ```python
116
+ ercot = opensced.market('ercot')
117
+ day = ercot.read_day('my_data/2026-08-12') # your folder of ERCOT's public files for one day
118
+ print(day) # which files were found, how many SCED runs
119
+ run = day.times[0]
120
+
121
+ result = ercot.clear(day.inputs(run)) # no network: one price for the whole system
122
+ result.system_lambda, day.published_lambda()[run] # the engine's price, and ERCOT's
123
+
124
+ inputs = day.inputs(run, shift_factors=my_shift_factors, resource_nodes=my_resource_nodes) # with your network
125
+ result = ercot.clear(inputs) # uses the rulebook in force that day
126
+ opensced.score(result, system_lambda=day.published_lambda()[run], node_prices=day.published_node_prices().loc[run])
127
+ ```
128
+
129
+ [docs/ercot.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot.md#getting-the-files) says where to download each file and what to name it.
130
+
131
+ A whole day:
132
+
133
+ ```python
134
+ out = ercot.clear_day(day, shift_factors=my_shift_factors, resource_nodes=my_resource_nodes)
135
+ out.system_lambda # time -> $/MWh
136
+ out.node_prices # time x settlement point
137
+ opensced.score(out, system_lambda=day.published_lambda(), node_prices=day.published_node_prices())
138
+ ```
139
+
140
+ A run of intervals, each starting where the last one ended:
141
+
142
+ ```python
143
+ out = ercot.clear_day(day, shift_factors=sf, resource_nodes=nodes, carry=('output', 'ramp', 'soc'))
144
+ out = opensced.clear_sequence(list_of_inputs, rules) # any market, any list of intervals
145
+ ```
146
+
147
+ `carry` picks what the engine works out from the interval before instead of reading from each interval's tables:
148
+ each resource's starting output, how far its ramp rate lets it move, and each battery's state of charge.
149
+
150
+ Run the examples:
151
+
152
+ ```bash
153
+ python examples/01_three_bus.py # the made-up grid, step by step: no data needed
154
+ python examples/02_ercot_one_run.py my_data/2026-08-12 # one real SCED run against ERCOT's published prices
155
+ python examples/03_what_if.py my_data/2026-08-12 # more demand, less solar, a changed rule
156
+ ```
157
+
158
+ ## How data feeds the engine
159
+
160
+ ```mermaid
161
+ flowchart LR
162
+ A["ERCOT public reports<br/>(you download)"] --> R["ercot.read_day<br/>adapter"]
163
+ B["shift_factors, resource_nodes<br/>(you supply)"] --> R
164
+ R --> I["Input tables<br/>one set per SCED run"]
165
+ RB["Rulebook<br/>in force on the date"] --> C
166
+ I --> C["opensced.clear<br/>one linear program"]
167
+ C --> O["Prices, dispatch,<br/>reserve awards"]
168
+ O --> S["opensced.score<br/>against ERCOT's prices"]
169
+ ```
170
+
171
+ The full chart, with every ERCOT report and the table it fills, is in [docs/data_flow.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/data_flow.md). The
172
+ input tables are defined column by column in [docs/schema.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/schema.md).
173
+
174
+ ## What you bring
175
+
176
+ A folder with one operating day of ERCOT's public reports ([docs/ercot.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot.md#getting-the-files) says where
177
+ to get each file). ERCOT
178
+ publishes everything the clearing needs except two things:
179
+
180
+ | Input | What it is |
181
+ |---|---|
182
+ | `shift_factors` | A table, constraint x settlement point: MW of flow on the constraint per MW injected there |
183
+ | `resource_nodes` | Which settlement point each resource injects at |
184
+
185
+ This package does not ship either, and does not estimate them. Without them a run still clears, as one node with no
186
+ network. ERCOT posts its shift factors to its secure Market Information System
187
+ ([docs/data_flow.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/data_flow.md#shift-factors)). To forecast instead of replay, you replace any other table
188
+ with your own: demand, offers, wind and solar limits, outages.
189
+
190
+ ## The inputs
191
+
192
+ One interval is an `opensced.Inputs`: a handful of plain tables. `resources` and `demand` are required, the rest are
193
+ optional and switch features on.
194
+
195
+ | Table | One row per | Switches on |
196
+ |---|---|---|
197
+ | `resources` | Resource: limits, ramp range, current output | |
198
+ | `energy_offers` | Offer curve point | |
199
+ | `demand` | One number, MW | |
200
+ | `constraints`, `shift_factors`, `resource_nodes` | Constraint; constraint x node; resource | The network and node prices |
201
+ | `reserve_demand`, `reserve_limits`, `reserve_offers` | Demand curve point; resource and product; offer block | Reserves cleared with energy |
202
+ | `storage` | Battery: state of charge and its bounds | State-of-charge limits on reserves |
203
+
204
+ ```python
205
+ print(opensced.schema()) # every table, column by column, with units
206
+ print(opensced.schema('resources')) # one table
207
+ inputs.validate() # raises with the table and the row at fault
208
+ ```
209
+
210
+ The full data dictionary is in [docs/schema.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/schema.md). ERCOT's own calculations (dispatch limits from
211
+ ramp rates, proxy offers, constraint caps) are in `opensced.market('ercot').helpers`, for when you forecast the
212
+ underlying numbers instead of reading ERCOT's result.
213
+
214
+ ## Markets and rule versions
215
+
216
+ A market is its public-file adapter plus a list of dated rulebooks. A rulebook holds the numbers and switches the
217
+ clearing used from one date until the next change: penalty prices, reserve products and their durations. ERCOT has
218
+ two so far: go-live on December 5, 2025, and January 1, 2026, when the RRS kept for primary frequency response rose
219
+ from 1,365 MW to 1,377 MW.
220
+
221
+ ```python
222
+ ercot.rules.versions() # every rulebook, with its start date and source
223
+ rules = ercot.rules.on('2026-08-12') # the one in force that day
224
+ print(rules)
225
+
226
+ # Test a rule change before it exists
227
+ draft = rules.replace(name='draft/ecrs-2h', products={'ECRS': {'duration_hours': 2.0}})
228
+ rules.diff(draft)
229
+ ercot.clear(inputs, rules=draft)
230
+ ```
231
+
232
+ Clearing a date picks its rulebook automatically, so a backtest across a rule change uses the right rules on each
233
+ side. More in [docs/rules.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/rules.md) and [docs/ercot.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot.md).
234
+
235
+ `opensced.list_markets()` shows what is built. Today that is ERCOT. PJM, MISO, SPP, CAISO and NYISO are planned in
236
+ the same package, on the same input tables.
237
+
238
+ ## What it does not do
239
+
240
+ - It does not estimate shift factors or map resources to nodes.
241
+ - It does not forecast anything. It clears the inputs it is given.
242
+ - It does not decide which units are online. Commitment is an input, through each resource's limits.
243
+ - A chained run assumes every resource does exactly what it was told. Real fleets drift from their instructions.
244
+ - For ERCOT, demand is the sum of ERCOT's base points rather than ERCOT's own demand target, which is not published.
245
+ [docs/ercot_conformance.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot_conformance.md) lists what is still open.
246
+ - Dates before December 5, 2025 cleared under different rules (energy only, with a scarcity adder) and are not
247
+ modelled yet.
248
+
249
+ ## Checked against ERCOT
250
+
251
+ The clearing was checked against ERCOT's published system lambda on every SCED run of 34 operating days from December
252
+ 11, 2025 to September 15, 2026, with congestion taken from ERCOT's own published node prices so that only the
253
+ clearing rules and math are tested. Of 9,909 runs, 9,904 are within $1 of ERCOT. The five that are not:
254
+
255
+ | Run | Difference | Cause |
256
+ |---|---|---|
257
+ | December 11, 2025 16:35 | -$20.93 | ERCOT held batteries at zero energy in this one run. Not a rule that can be read from the files |
258
+ | March 23, 2026 21:30 | +$7.91 | Depends on when ERCOT had Non-Spin deployed, which is not in any data report |
259
+ | June 4, 2026 14:07 | -$1.15 | A run between the five-minute runs. Not yet examined |
260
+ | August 26, 2026 22:30 | +$1.13 | How a battery short on stored energy splits RRS and ECRS. Rule not identified |
261
+ | January 28, 2026 07:20 | -$1.00 | Not yet explained |
262
+
263
+ [docs/ercot_conformance.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot_conformance.md) lists every clearing rule in ERCOT's Protocols against what the
264
+ engine does. Node prices also depend on the shift factors you supply, which are not part of the engine.
265
+
266
+ Three inputs the clearing needs are not in ERCOT's data reports, and are read off ERCOT's own results for the day
267
+ unless you supply them: when Non-Spin was deployed, the qualified MW of controllable loads, and which off-line units
268
+ ERCOT awards through its proxy offer. [docs/ercot.md](https://github.com/anthonyrizkallah/opensced/blob/main/docs/ercot.md) covers each.
269
+
270
+ ## Questions and bugs
271
+
272
+ Open an issue on GitHub: https://github.com/anthonyrizkallah/opensced/issues
273
+
274
+ ## Licence
275
+
276
+ Apache-2.0. See [LICENSE](https://github.com/anthonyrizkallah/opensced/blob/main/LICENSE).
@@ -0,0 +1,27 @@
1
+ opensced/__init__.py,sha256=A0e4FIyGAiTi96MgSaICPt3k3x3Fh5f32BIwYRtLotw,1576
2
+ opensced/examples.py,sha256=fkiwSBRLf9J2fkxhAOMsX8HOVMbVAwRQAlmDiRdowoQ,3514
3
+ opensced/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ opensced/core/market.py,sha256=MSqPK32bXk-vZcBGI83UYbFjFKxNIuUmzAxNkhYe6ik,4672
5
+ opensced/core/model.py,sha256=cBdiwLn7sGLH5-pNpr_vaMIiv4Omd6XGhmJ0lJ2brLs,9798
6
+ opensced/core/program.py,sha256=Hb0ZuaErCVRlWBLYqPOHxkP-i9LvWpXk3I3-Ypfupzs,5087
7
+ opensced/core/result.py,sha256=P0ENzCg9OWFe1pfa1garkfpIa4l4cXkoglVVP3VtOek,7539
8
+ opensced/core/rules.py,sha256=BIHLhXOG0py8ReeCzZONaJHaBBlDTk4zxi3uDTqMVj8,18624
9
+ opensced/core/score.py,sha256=GN9eZKzixvpkw35H1d-WUKQ-4M9OYY6dBo4qs2koDzM,3593
10
+ opensced/core/sequence.py,sha256=Qt7GV1c1Oc-p7TVuxYk1KZvax-RcE_AnsgCpLQr70i8,6922
11
+ opensced/core/tables.py,sha256=wJ1zOeyWCDBWfRiCuXNwmkhN7qA8hZwrURQiPXBgODc,18873
12
+ opensced/core/features/__init__.py,sha256=LC-XnkkDj5c7gYxJpZ8YSvUXmEMaayCYXrzaVKjSFNc,387
13
+ opensced/core/features/balance.py,sha256=gTI7qylrzORIc4vXC9ufx8LL0SpwW3YuFZ1mCw7qwGI,4591
14
+ opensced/core/features/mitigation.py,sha256=JMxcSqvbg3HH_-AIgDEIm2L8Y7-BxqgfbC2AawIQ-X4,5288
15
+ opensced/core/features/network.py,sha256=os-VgYlfKaOylbU2U3O6m7M4LiGZ4Rlk3zZyiJQzxuo,3402
16
+ opensced/core/features/reserves.py,sha256=1HWqgY4QGG_cx79llxaOFUZv6bPcHPxH8zdOMh1Sp9I,9487
17
+ opensced/core/features/storage.py,sha256=e-ywxWmwIsOhLFqVQ_oL-tBL1nTMIKWph-QlBa_FFH8,6130
18
+ opensced/markets/__init__.py,sha256=1P4GkWXR3K6VpD5e2Uis2Wa99hY7ulW57TD2S6IGZMA,127
19
+ opensced/markets/ercot/__init__.py,sha256=MIjK2PtXKh2FzERJRNqH7IjsfWRLhY4Nd7twKMcho_A,421
20
+ opensced/markets/ercot/adapter.py,sha256=v5ie177xlBUC2zYiVInYKV8w_lR5H0Ezx7Q4Sdxt1rQ,65682
21
+ opensced/markets/ercot/helpers.py,sha256=-l48qE6QzLVtOB_P4fFzh_jlw1IIPXyygWfsArw54NQ,19300
22
+ opensced/markets/ercot/pricing.py,sha256=TbGG-QxnI2UmvpTa1YKqUSKhli6UOm0WOZF9NQ6hdoI,19683
23
+ opensced/markets/ercot/rulebooks.py,sha256=84Rw7EMwSmrEu-S2XVKa-PCE1LJnTu-wFHCkb0aG45U,13907
24
+ opensced-0.1.0.dist-info/METADATA,sha256=XYmHgmI6TaHeYLa1nrstkUS3X6qeCBxChvQuzZZYzEE,13650
25
+ opensced-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
26
+ opensced-0.1.0.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
27
+ opensced-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any