opensced 0.1.0__tar.gz

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.
Files changed (39) hide show
  1. opensced-0.1.0/.gitignore +16 -0
  2. opensced-0.1.0/LICENSE +202 -0
  3. opensced-0.1.0/PKG-INFO +276 -0
  4. opensced-0.1.0/README.md +250 -0
  5. opensced-0.1.0/docs/clearing_math.md +145 -0
  6. opensced-0.1.0/docs/data_flow.md +78 -0
  7. opensced-0.1.0/docs/ercot.md +228 -0
  8. opensced-0.1.0/docs/ercot_conformance.md +293 -0
  9. opensced-0.1.0/docs/rules.md +96 -0
  10. opensced-0.1.0/docs/schema.md +102 -0
  11. opensced-0.1.0/examples/01_three_bus.py +31 -0
  12. opensced-0.1.0/examples/02_ercot_one_run.py +58 -0
  13. opensced-0.1.0/examples/03_what_if.py +49 -0
  14. opensced-0.1.0/pyproject.toml +38 -0
  15. opensced-0.1.0/src/opensced/__init__.py +32 -0
  16. opensced-0.1.0/src/opensced/core/__init__.py +0 -0
  17. opensced-0.1.0/src/opensced/core/features/__init__.py +7 -0
  18. opensced-0.1.0/src/opensced/core/features/balance.py +74 -0
  19. opensced-0.1.0/src/opensced/core/features/mitigation.py +102 -0
  20. opensced-0.1.0/src/opensced/core/features/network.py +69 -0
  21. opensced-0.1.0/src/opensced/core/features/reserves.py +169 -0
  22. opensced-0.1.0/src/opensced/core/features/storage.py +110 -0
  23. opensced-0.1.0/src/opensced/core/market.py +97 -0
  24. opensced-0.1.0/src/opensced/core/model.py +181 -0
  25. opensced-0.1.0/src/opensced/core/program.py +107 -0
  26. opensced-0.1.0/src/opensced/core/result.py +159 -0
  27. opensced-0.1.0/src/opensced/core/rules.py +343 -0
  28. opensced-0.1.0/src/opensced/core/score.py +75 -0
  29. opensced-0.1.0/src/opensced/core/sequence.py +105 -0
  30. opensced-0.1.0/src/opensced/core/tables.py +296 -0
  31. opensced-0.1.0/src/opensced/examples.py +59 -0
  32. opensced-0.1.0/src/opensced/markets/__init__.py +2 -0
  33. opensced-0.1.0/src/opensced/markets/ercot/__init__.py +8 -0
  34. opensced-0.1.0/src/opensced/markets/ercot/adapter.py +911 -0
  35. opensced-0.1.0/src/opensced/markets/ercot/helpers.py +277 -0
  36. opensced-0.1.0/src/opensced/markets/ercot/pricing.py +284 -0
  37. opensced-0.1.0/src/opensced/markets/ercot/rulebooks.py +164 -0
  38. opensced-0.1.0/tests/test_core.py +390 -0
  39. opensced-0.1.0/tests/test_ercot.py +534 -0
@@ -0,0 +1,16 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .env
8
+ .env.*
9
+ # No market data is published in this repository. Bring your own files.
10
+ *.parquet
11
+ *.csv
12
+ *.csv.gz
13
+ *.zip
14
+ examples/ercot/
15
+ my_data/
16
+ .DS_Store
opensced-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -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).