quantvolt 0.2.0__cp311-abi3-win_amd64.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.
Files changed (114) hide show
  1. quantvolt/__init__.py +426 -0
  2. quantvolt/_core.pyd +0 -0
  3. quantvolt/_core.pyi +89 -0
  4. quantvolt/_validation.py +63 -0
  5. quantvolt/assets/__init__.py +76 -0
  6. quantvolt/assets/_tolerance.py +19 -0
  7. quantvolt/assets/dispatch_approx.py +424 -0
  8. quantvolt/assets/dispatch_deterministic.py +423 -0
  9. quantvolt/assets/dispatch_sdp.py +1258 -0
  10. quantvolt/assets/long_dated.py +350 -0
  11. quantvolt/assets/plant.py +188 -0
  12. quantvolt/assets/storage.py +695 -0
  13. quantvolt/cli.py +102 -0
  14. quantvolt/curvemodels/__init__.py +49 -0
  15. quantvolt/curvemodels/multifactor.py +516 -0
  16. quantvolt/curvemodels/schwartz_smith.py +682 -0
  17. quantvolt/curves/__init__.py +14 -0
  18. quantvolt/curves/arbitrage.py +165 -0
  19. quantvolt/curves/builder.py +208 -0
  20. quantvolt/data/__init__.py +55 -0
  21. quantvolt/data/base.py +294 -0
  22. quantvolt/data/commercial.py +120 -0
  23. quantvolt/data/dataset_catalog.json +15 -0
  24. quantvolt/data/datasets.py +152 -0
  25. quantvolt/data/entsoe.py +448 -0
  26. quantvolt/data/entsog.py +170 -0
  27. quantvolt/data/netztransparenz.py +253 -0
  28. quantvolt/data/open_meteo.py +171 -0
  29. quantvolt/data/smard.py +218 -0
  30. quantvolt/exceptions.py +68 -0
  31. quantvolt/hedging/__init__.py +42 -0
  32. quantvolt/hedging/_conditioning.py +43 -0
  33. quantvolt/hedging/hybrid.py +210 -0
  34. quantvolt/hedging/mean_variance.py +236 -0
  35. quantvolt/hedging/ppa_nomination.py +240 -0
  36. quantvolt/hedging/ppa_walk_forward.py +128 -0
  37. quantvolt/hedging/variance_min.py +245 -0
  38. quantvolt/market/__init__.py +39 -0
  39. quantvolt/market/outages.py +457 -0
  40. quantvolt/market/transmission.py +39 -0
  41. quantvolt/market/weather.py +83 -0
  42. quantvolt/models/__init__.py +138 -0
  43. quantvolt/models/commodity.py +95 -0
  44. quantvolt/models/curve.py +190 -0
  45. quantvolt/models/discount_curve.py +79 -0
  46. quantvolt/models/greeks.py +62 -0
  47. quantvolt/models/instruments.py +514 -0
  48. quantvolt/models/interval.py +55 -0
  49. quantvolt/models/power_hedge.py +75 -0
  50. quantvolt/models/ppa.py +89 -0
  51. quantvolt/models/ppa_terms.py +444 -0
  52. quantvolt/models/schedule.py +74 -0
  53. quantvolt/models/units.py +224 -0
  54. quantvolt/models/vol_surface.py +81 -0
  55. quantvolt/numerics/__init__.py +76 -0
  56. quantvolt/numerics/_degenerate.py +75 -0
  57. quantvolt/numerics/_normal.py +26 -0
  58. quantvolt/numerics/bachelier.py +316 -0
  59. quantvolt/numerics/black76.py +283 -0
  60. quantvolt/numerics/daycount.py +30 -0
  61. quantvolt/numerics/exotic.py +326 -0
  62. quantvolt/numerics/interpolation.py +108 -0
  63. quantvolt/numerics/monte_carlo.py +488 -0
  64. quantvolt/numerics/risk_adjustment.py +143 -0
  65. quantvolt/numerics/rootfind.py +65 -0
  66. quantvolt/numerics/spread_models.py +127 -0
  67. quantvolt/portfolio/__init__.py +29 -0
  68. quantvolt/portfolio/model.py +120 -0
  69. quantvolt/portfolio/settlement.py +125 -0
  70. quantvolt/portfolio/valuation.py +641 -0
  71. quantvolt/pricing/__init__.py +162 -0
  72. quantvolt/pricing/_dates.py +53 -0
  73. quantvolt/pricing/bachelier.py +105 -0
  74. quantvolt/pricing/exotic.py +546 -0
  75. quantvolt/pricing/futures.py +150 -0
  76. quantvolt/pricing/implied_vol.py +398 -0
  77. quantvolt/pricing/mark_to_market.py +135 -0
  78. quantvolt/pricing/power_hedge.py +167 -0
  79. quantvolt/pricing/ppa.py +855 -0
  80. quantvolt/pricing/ppa_valuation.py +372 -0
  81. quantvolt/pricing/spread_option.py +237 -0
  82. quantvolt/pricing/spreads.py +493 -0
  83. quantvolt/pricing/swap.py +183 -0
  84. quantvolt/pricing/tolling.py +371 -0
  85. quantvolt/pricing/transmission_right.py +464 -0
  86. quantvolt/pricing/vanilla.py +197 -0
  87. quantvolt/py.typed +0 -0
  88. quantvolt/risk/__init__.py +47 -0
  89. quantvolt/risk/_levels.py +97 -0
  90. quantvolt/risk/aggregation.py +79 -0
  91. quantvolt/risk/cashflow_metrics.py +122 -0
  92. quantvolt/risk/cfar.py +197 -0
  93. quantvolt/risk/covariance.py +290 -0
  94. quantvolt/risk/credit_var.py +338 -0
  95. quantvolt/risk/engine.py +323 -0
  96. quantvolt/risk/mc_var.py +496 -0
  97. quantvolt/risk/parametric_var.py +391 -0
  98. quantvolt/risk/scenarios.py +216 -0
  99. quantvolt/stats/__init__.py +24 -0
  100. quantvolt/stats/correlation.py +157 -0
  101. quantvolt/stats/descriptive.py +125 -0
  102. quantvolt/stats/mean_reversion.py +114 -0
  103. quantvolt/stats/normality.py +172 -0
  104. quantvolt/stats/stationarity.py +170 -0
  105. quantvolt/testing.py +92 -0
  106. quantvolt/workflow/__init__.py +33 -0
  107. quantvolt/workflow/criteria.py +39 -0
  108. quantvolt/workflow/modeling.py +395 -0
  109. quantvolt-0.2.0.dist-info/METADATA +389 -0
  110. quantvolt-0.2.0.dist-info/RECORD +114 -0
  111. quantvolt-0.2.0.dist-info/WHEEL +4 -0
  112. quantvolt-0.2.0.dist-info/entry_points.txt +2 -0
  113. quantvolt-0.2.0.dist-info/licenses/LICENSE +21 -0
  114. quantvolt-0.2.0.dist-info/sboms/quantvolt-core.cyclonedx.json +1215 -0
quantvolt/__init__.py ADDED
@@ -0,0 +1,426 @@
1
+ """quantvolt — quantitative analysis of European power and energy markets.
2
+
3
+ Pure-computation analytics core (see .kiro/steering/). The optional data-adapters layer
4
+ (`quantvolt[data]`) and the native Rust Monte Carlo kernels (`quantvolt._core`) are separate,
5
+ and the core never imports them.
6
+
7
+ This module is a curated Facade over the subsystems: the domain value objects, the curve
8
+ builder, the pricing entry points, and the risk/portfolio engines. Deeper or more specialised
9
+ names stay on their sub-packages (``quantvolt.numerics``, ``quantvolt.stats``,
10
+ ``quantvolt.market``, ``quantvolt.workflow``, ``quantvolt.testing``).
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from .assets import (
16
+ BangBangHedgeWarning,
17
+ DispatchDiagnostics,
18
+ DispatchFactorModel,
19
+ DispatchResult,
20
+ FactorTransform,
21
+ MonteCarloEvaluation,
22
+ PhysicalFactorMapping,
23
+ PlantModel,
24
+ StorageModel,
25
+ ValuationSource,
26
+ bang_bang,
27
+ dispatch_deterministic,
28
+ dispatch_value,
29
+ horizon_divide,
30
+ storage_intrinsic,
31
+ storage_value,
32
+ time_aggregate,
33
+ valuation_benchmark,
34
+ var_applicability_guard,
35
+ )
36
+ from .curvemodels import MultifactorForwardModel, SchwartzSmithParams
37
+ from .curves import (
38
+ ArbitrageChecker,
39
+ ArbitrageWarning,
40
+ CurveBuilder,
41
+ CurveBuildResult,
42
+ check_arbitrage,
43
+ )
44
+ from .exceptions import (
45
+ ArbitrageError,
46
+ AuthenticationError,
47
+ DataSourceError,
48
+ DataUnavailableError,
49
+ EnergyQuantError,
50
+ ExpiredContractError,
51
+ InsufficientDataError,
52
+ MissingTenorError,
53
+ NativeExtensionError,
54
+ NoPricingDataError,
55
+ NumericalError,
56
+ RateLimitError,
57
+ ScenarioNotFoundError,
58
+ ValidationError,
59
+ )
60
+ from .hedging import (
61
+ PpaNominationCandidate,
62
+ PpaNominationColumns,
63
+ PpaNominationFit,
64
+ PpaNominationObjective,
65
+ PpaWalkForwardResult,
66
+ apply_ppa_nomination,
67
+ calibrate_ppa_nomination,
68
+ linear_cross_hedge,
69
+ variance_min_hedge,
70
+ walk_forward_ppa_nomination,
71
+ )
72
+ from .models import (
73
+ BUILT_IN_COMMODITIES,
74
+ CachedAssetValuation,
75
+ CapFloorStripContract,
76
+ CapFloorType,
77
+ ChangeInLawAllocation,
78
+ CommodityConfig,
79
+ CurtailmentTreatment,
80
+ CurveNode,
81
+ DeliveryPeriod,
82
+ DeliverySchedule,
83
+ DiscountCurve,
84
+ ForwardContract,
85
+ ForwardCurve,
86
+ FuturesContract,
87
+ Granularity,
88
+ Greeks,
89
+ Hub,
90
+ IndexationStep,
91
+ InstrumentPriceRecord,
92
+ Moneyness,
93
+ NegativePriceClause,
94
+ NegativePriceTreatment,
95
+ OptionSide,
96
+ OptionType,
97
+ PipelineRight,
98
+ PlantConfig,
99
+ PowerDeliveryInterval,
100
+ PowerHedgeContract,
101
+ PowerHedgePosition,
102
+ PowerHedgeType,
103
+ PpaAvailabilityGuarantee,
104
+ PpaContract,
105
+ PpaContractMetadata,
106
+ PpaCreditSupportType,
107
+ PpaPriceTerms,
108
+ PpaReconciliationPeriod,
109
+ PpaReconciliationTerms,
110
+ PpaSettlementType,
111
+ PpaTerms,
112
+ PpaToleranceBand,
113
+ PpaVolumeBasis,
114
+ PpaVolumeTerms,
115
+ PriceUnit,
116
+ RiskType,
117
+ SettlementType,
118
+ SpreadOptionContract,
119
+ SwapContract,
120
+ TollingAgreement,
121
+ TransmissionRight,
122
+ TransportDirection,
123
+ VanillaOptionContract,
124
+ VolatilitySurface,
125
+ VolatilityTenor,
126
+ convert_price,
127
+ )
128
+ from .portfolio import (
129
+ Instrument,
130
+ MarketData,
131
+ Portfolio,
132
+ PortfolioSettlement,
133
+ PortfolioValuation,
134
+ Position,
135
+ PricedPosition,
136
+ SettledPortfolioPosition,
137
+ settle_energy_portfolio,
138
+ value_portfolio,
139
+ )
140
+ from .pricing import (
141
+ AsianOptionRequest,
142
+ BachelierOptionRequest,
143
+ BachelierOptionResult,
144
+ BarrierOptionRequest,
145
+ CapFloorRequest,
146
+ CapFloorResult,
147
+ ExoticOptionResult,
148
+ FuturesPricingResult,
149
+ ImpliedVolResult,
150
+ LookbackOptionRequest,
151
+ MissingImbalancePricePolicy,
152
+ MtMPosition,
153
+ MtMPositionResult,
154
+ MtMResult,
155
+ PowerHedgeDataColumns,
156
+ PowerHedgeSettlement,
157
+ PpaDataColumns,
158
+ PpaIntervalSettlement,
159
+ PpaPeriodValuation,
160
+ PpaPeriodVolume,
161
+ PpaReconciliationColumns,
162
+ PpaValuationResult,
163
+ PpaVolumeProfile,
164
+ SpreadOptionRequest,
165
+ SpreadOptionResult,
166
+ SwapPricingResult,
167
+ TollingResult,
168
+ TransportRightResult,
169
+ VanillaOptionRequest,
170
+ VanillaOptionResult,
171
+ basis,
172
+ build_volatility_surface,
173
+ calendar_spread,
174
+ classify_moneyness,
175
+ clean_spread,
176
+ crack_spread,
177
+ dark_spread,
178
+ forward_spread,
179
+ futures_delta,
180
+ implied_heat_rate,
181
+ implied_vol,
182
+ make_ppa_pricer,
183
+ mark_to_market,
184
+ power_cap_payoff,
185
+ power_floor_payoff,
186
+ price_asian,
187
+ price_bachelier_option,
188
+ price_barrier,
189
+ price_cap_floor,
190
+ price_futures,
191
+ price_lookback,
192
+ price_ppa,
193
+ price_spark_spread_option,
194
+ price_spread_option,
195
+ price_swap,
196
+ price_tolling_agreement,
197
+ price_vanilla_option,
198
+ reconcile_ppa_ledger,
199
+ settle_power_hedge_interval,
200
+ settle_power_hedges_frame,
201
+ settle_ppa_frame,
202
+ settle_ppa_interval,
203
+ spark_spread,
204
+ value_transport_right,
205
+ )
206
+ from .risk import (
207
+ CashflowStrategyComparison,
208
+ CashflowStrategyMetrics,
209
+ DeltaMatrix,
210
+ ExcludedPosition,
211
+ RiskEngine,
212
+ RiskResult,
213
+ ScenarioCatalogue,
214
+ ScenarioResult,
215
+ ScenarioShock,
216
+ aggregate_delta,
217
+ cash_flow_at_risk,
218
+ compare_cashflow_strategies,
219
+ credit_var,
220
+ delta_gamma_var,
221
+ ewma_covariance,
222
+ garch11_covariance,
223
+ monte_carlo_var,
224
+ parametric_var,
225
+ )
226
+
227
+ __version__ = "0.2.0"
228
+
229
+ __all__ = [
230
+ "BUILT_IN_COMMODITIES",
231
+ "ArbitrageChecker",
232
+ "ArbitrageError",
233
+ "ArbitrageWarning",
234
+ "AsianOptionRequest",
235
+ "AuthenticationError",
236
+ "BachelierOptionRequest",
237
+ "BachelierOptionResult",
238
+ "BangBangHedgeWarning",
239
+ "BarrierOptionRequest",
240
+ "CachedAssetValuation",
241
+ "CapFloorRequest",
242
+ "CapFloorResult",
243
+ "CapFloorStripContract",
244
+ "CapFloorType",
245
+ "CashflowStrategyComparison",
246
+ "CashflowStrategyMetrics",
247
+ "ChangeInLawAllocation",
248
+ "CommodityConfig",
249
+ "CurtailmentTreatment",
250
+ "CurveBuildResult",
251
+ "CurveBuilder",
252
+ "CurveNode",
253
+ "DataSourceError",
254
+ "DataUnavailableError",
255
+ "DeliveryPeriod",
256
+ "DeliverySchedule",
257
+ "DeltaMatrix",
258
+ "DiscountCurve",
259
+ "DispatchDiagnostics",
260
+ "DispatchFactorModel",
261
+ "DispatchResult",
262
+ "EnergyQuantError",
263
+ "ExcludedPosition",
264
+ "ExoticOptionResult",
265
+ "ExpiredContractError",
266
+ "FactorTransform",
267
+ "ForwardContract",
268
+ "ForwardCurve",
269
+ "FuturesContract",
270
+ "FuturesPricingResult",
271
+ "Granularity",
272
+ "Greeks",
273
+ "Hub",
274
+ "ImpliedVolResult",
275
+ "IndexationStep",
276
+ "Instrument",
277
+ "InstrumentPriceRecord",
278
+ "InsufficientDataError",
279
+ "LookbackOptionRequest",
280
+ "MarketData",
281
+ "MissingImbalancePricePolicy",
282
+ "MissingTenorError",
283
+ "Moneyness",
284
+ "MonteCarloEvaluation",
285
+ "MtMPosition",
286
+ "MtMPositionResult",
287
+ "MtMResult",
288
+ "MultifactorForwardModel",
289
+ "NativeExtensionError",
290
+ "NegativePriceClause",
291
+ "NegativePriceTreatment",
292
+ "NoPricingDataError",
293
+ "NumericalError",
294
+ "OptionSide",
295
+ "OptionType",
296
+ "PhysicalFactorMapping",
297
+ "PipelineRight",
298
+ "PlantConfig",
299
+ "PlantModel",
300
+ "Portfolio",
301
+ "PortfolioSettlement",
302
+ "PortfolioValuation",
303
+ "Position",
304
+ "PowerDeliveryInterval",
305
+ "PowerHedgeContract",
306
+ "PowerHedgeDataColumns",
307
+ "PowerHedgePosition",
308
+ "PowerHedgeSettlement",
309
+ "PowerHedgeType",
310
+ "PpaAvailabilityGuarantee",
311
+ "PpaContract",
312
+ "PpaContractMetadata",
313
+ "PpaCreditSupportType",
314
+ "PpaDataColumns",
315
+ "PpaIntervalSettlement",
316
+ "PpaNominationCandidate",
317
+ "PpaNominationColumns",
318
+ "PpaNominationFit",
319
+ "PpaNominationObjective",
320
+ "PpaPeriodValuation",
321
+ "PpaPeriodVolume",
322
+ "PpaPriceTerms",
323
+ "PpaReconciliationColumns",
324
+ "PpaReconciliationPeriod",
325
+ "PpaReconciliationTerms",
326
+ "PpaSettlementType",
327
+ "PpaTerms",
328
+ "PpaToleranceBand",
329
+ "PpaValuationResult",
330
+ "PpaVolumeBasis",
331
+ "PpaVolumeProfile",
332
+ "PpaVolumeTerms",
333
+ "PpaWalkForwardResult",
334
+ "PriceUnit",
335
+ "PricedPosition",
336
+ "RateLimitError",
337
+ "RiskEngine",
338
+ "RiskResult",
339
+ "RiskType",
340
+ "ScenarioCatalogue",
341
+ "ScenarioNotFoundError",
342
+ "ScenarioResult",
343
+ "ScenarioShock",
344
+ "SchwartzSmithParams",
345
+ "SettledPortfolioPosition",
346
+ "SettlementType",
347
+ "SpreadOptionContract",
348
+ "SpreadOptionRequest",
349
+ "SpreadOptionResult",
350
+ "StorageModel",
351
+ "SwapContract",
352
+ "SwapPricingResult",
353
+ "TollingAgreement",
354
+ "TollingResult",
355
+ "TransmissionRight",
356
+ "TransportDirection",
357
+ "TransportRightResult",
358
+ "ValidationError",
359
+ "ValuationSource",
360
+ "VanillaOptionContract",
361
+ "VanillaOptionRequest",
362
+ "VanillaOptionResult",
363
+ "VolatilitySurface",
364
+ "VolatilityTenor",
365
+ "aggregate_delta",
366
+ "apply_ppa_nomination",
367
+ "bang_bang",
368
+ "basis",
369
+ "build_volatility_surface",
370
+ "calendar_spread",
371
+ "calibrate_ppa_nomination",
372
+ "cash_flow_at_risk",
373
+ "check_arbitrage",
374
+ "classify_moneyness",
375
+ "clean_spread",
376
+ "compare_cashflow_strategies",
377
+ "convert_price",
378
+ "crack_spread",
379
+ "credit_var",
380
+ "dark_spread",
381
+ "delta_gamma_var",
382
+ "dispatch_deterministic",
383
+ "dispatch_value",
384
+ "ewma_covariance",
385
+ "forward_spread",
386
+ "futures_delta",
387
+ "garch11_covariance",
388
+ "horizon_divide",
389
+ "implied_heat_rate",
390
+ "implied_vol",
391
+ "linear_cross_hedge",
392
+ "make_ppa_pricer",
393
+ "mark_to_market",
394
+ "monte_carlo_var",
395
+ "parametric_var",
396
+ "power_cap_payoff",
397
+ "power_floor_payoff",
398
+ "price_asian",
399
+ "price_bachelier_option",
400
+ "price_barrier",
401
+ "price_cap_floor",
402
+ "price_futures",
403
+ "price_lookback",
404
+ "price_ppa",
405
+ "price_spark_spread_option",
406
+ "price_spread_option",
407
+ "price_swap",
408
+ "price_tolling_agreement",
409
+ "price_vanilla_option",
410
+ "reconcile_ppa_ledger",
411
+ "settle_energy_portfolio",
412
+ "settle_power_hedge_interval",
413
+ "settle_power_hedges_frame",
414
+ "settle_ppa_frame",
415
+ "settle_ppa_interval",
416
+ "spark_spread",
417
+ "storage_intrinsic",
418
+ "storage_value",
419
+ "time_aggregate",
420
+ "valuation_benchmark",
421
+ "value_portfolio",
422
+ "value_transport_right",
423
+ "var_applicability_guard",
424
+ "variance_min_hedge",
425
+ "walk_forward_ppa_nomination",
426
+ ]
quantvolt/_core.pyd ADDED
Binary file
quantvolt/_core.pyi ADDED
@@ -0,0 +1,89 @@
1
+ """Type stubs for the native Rust extension `quantvolt._core` (built by maturin)."""
2
+
3
+ import numpy as np
4
+ import numpy.typing as npt
5
+
6
+ def asian_monte_carlo(
7
+ forward: float,
8
+ strike: float,
9
+ sigma: float,
10
+ time_to_expiry: float,
11
+ discount_factor: float,
12
+ averaging_points: int,
13
+ is_call: bool,
14
+ geometric: bool,
15
+ seed: int,
16
+ path_count: int,
17
+ antithetic: bool = True,
18
+ ) -> tuple[float, float]:
19
+ """Return ``(premium, standard_error)``. Native Rust MC kernel (Task 59).
20
+
21
+ Driftless GBM under the forward measure with ``averaging_points`` equally spaced
22
+ fixings; ``antithetic`` (default ``True``) draws ``(+eps, -eps)`` pairs (an odd
23
+ ``path_count`` rounds up to the next even number when antithetic is on).
24
+ ``premium = DF * mean(payoff)`` and ``standard_error =
25
+ DF * std(payoff, ddof=1) / sqrt(n)``. Deterministic per ``seed`` (Req 11.2) — the
26
+ stream is seeded-Rust-RNG reproducible, not NumPy-matching. Raises ``ValueError``
27
+ for ``path_count < 1``, ``averaging_points < 1``, or non-finite float inputs.
28
+ """
29
+ ...
30
+
31
+ def simulate_ou(
32
+ x0: float,
33
+ kappa: float,
34
+ mu: float,
35
+ sigma: float,
36
+ dt: float,
37
+ steps: int,
38
+ seed: int,
39
+ path_count: int,
40
+ ) -> npt.NDArray[np.float64]:
41
+ """Simulate seeded Ornstein-Uhlenbeck (mean-reverting) paths (Task 59, GBM / OU).
42
+
43
+ Euler recursion ``x_{t+dt} = x_t + kappa*(mu - x_t)*dt + sigma*sqrt(dt)*z``. Returns a
44
+ ``float64`` array of shape ``(path_count, steps + 1)`` with ``x0`` in column 0.
45
+ Deterministic per ``seed`` (Req 11.2) — seeded-Rust-RNG reproducible, not
46
+ NumPy-matching. Inputs are validated by the ``numerics.monte_carlo`` wrapper.
47
+ """
48
+ ...
49
+
50
+ def simulate_correlated_forwards(
51
+ z0: npt.NDArray[np.float64],
52
+ drift: npt.NDArray[np.float64],
53
+ cov: npt.NDArray[np.float64],
54
+ steps: int,
55
+ path_count: int,
56
+ seed: int,
57
+ antithetic: bool,
58
+ ) -> npt.NDArray[np.float64]:
59
+ """Correlated multi-commodity log-forward simulation (Appendix A, Task 62).
60
+
61
+ ``z0``/``drift`` are length-``D`` vectors and ``cov`` a ``(D, D)`` symmetric PSD
62
+ covariance (validated Python-side before this call). Returns a ``float64`` array of
63
+ shape ``(n_paths, steps + 1, D)`` with record 0 equal to ``z0``. Increment law
64
+ ``ΔZ = μ + L·ε`` with ``L = chol(cov)`` (eqs A.9-A.13); a zero-variance state index
65
+ stays frozen (eq A.5). Antithetic variates draw ``(+ε, -ε)`` pairs (odd
66
+ ``path_count`` rounds up). Deterministic per ``seed`` (Req 11.2). Raises
67
+ ``ValueError`` on shape/finiteness violations or a non-PSD ``cov`` (defensive; the
68
+ wrapper already gates PSD).
69
+ """
70
+ ...
71
+
72
+ def simulate_correlated_forwards_term(
73
+ z0: npt.NDArray[np.float64],
74
+ drift_steps: npt.NDArray[np.float64],
75
+ covariance_steps: npt.NDArray[np.float64],
76
+ active_steps: npt.NDArray[np.bool_],
77
+ path_count: int,
78
+ seed: int,
79
+ antithetic: bool,
80
+ ) -> npt.NDArray[np.float64]:
81
+ """Simulate time-varying correlated state paths (Appendix A).
82
+
83
+ ``drift_steps`` has shape ``(steps, D)``, ``covariance_steps`` has shape
84
+ ``(steps, D, D)``, and ``active_steps`` has shape ``(steps, D)``. An inactive
85
+ coordinate is held exactly fixed during that step, representing the advancing
86
+ first-live-tenor index. Returns ``(n_paths, steps + 1, D)``. Raises ``ValueError``
87
+ for invalid shapes, non-finite inputs, or non-PSD covariance matrices.
88
+ """
89
+ ...
@@ -0,0 +1,63 @@
1
+ """Reusable boundary-validation guards. Public entry points validate through these before any
2
+ computation (fail loudly; see .kiro/steering/coding-style.md). All raise ValidationError."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import math
7
+ from collections.abc import Sized
8
+
9
+ from .exceptions import ValidationError
10
+
11
+
12
+ def require_positive(name: str, value: float) -> None:
13
+ if not value > 0:
14
+ raise ValidationError(f"{name} must be > 0, got {value!r}")
15
+
16
+
17
+ def require_non_negative(name: str, value: float) -> None:
18
+ if not math.isfinite(value) or value < 0:
19
+ raise ValidationError(f"{name} must be finite and >= 0, got {value!r}")
20
+
21
+
22
+ def require_in_range(name: str, value: float, lo: float, hi: float) -> None:
23
+ if not (lo <= value <= hi):
24
+ raise ValidationError(f"{name} must be in [{lo}, {hi}], got {value!r}")
25
+
26
+
27
+ def require_probability(name: str, value: float) -> None:
28
+ if not (0.0 <= value <= 1.0):
29
+ raise ValidationError(f"{name} must be in [0, 1], got {value!r}")
30
+
31
+
32
+ def require_discount_factor(name: str, value: float) -> None:
33
+ if not (0.0 < value <= 1.0):
34
+ raise ValidationError(f"{name} must be in (0, 1], got {value!r}")
35
+
36
+
37
+ def require_correlation(name: str, value: float) -> None:
38
+ if not (-1.0 < value < 1.0):
39
+ raise ValidationError(f"{name} must be in (-1, 1), got {value!r}")
40
+
41
+
42
+ def require_non_empty(name: str, value: Sized) -> None:
43
+ if len(value) == 0:
44
+ raise ValidationError(f"{name} must be non-empty")
45
+
46
+
47
+ def require_finite(name: str, value: float) -> None:
48
+ """Require one finite real-valued scalar."""
49
+ if not math.isfinite(value):
50
+ raise ValidationError(f"{name} must be finite, got {value!r}")
51
+
52
+
53
+ def require_integer_at_least(name: str, value: int, minimum: int) -> None:
54
+ """Require a genuine integer at or above ``minimum`` (booleans are rejected)."""
55
+ if isinstance(value, bool) or not isinstance(value, int) or value < minimum:
56
+ raise ValidationError(f"{name} must be an integer >= {minimum}, got {value!r}")
57
+
58
+
59
+ def require_length(name: str, value: Sized, expected: int) -> None:
60
+ """Require an exact collection length."""
61
+ actual = len(value)
62
+ if actual != expected:
63
+ raise ValidationError(f"{name} must have length {expected}, got {actual}")
@@ -0,0 +1,76 @@
1
+ """quantvolt.assets — physical-asset optimization (Reqs 21-23).
2
+
3
+ Thermal-generation dispatch, gas storage, and long-dated valuation governance.
4
+ This package holds the *operational* asset models: equipment and operating
5
+ constraints translated into optimization states, feasible actions, cash flows,
6
+ and asset optionality — the guard against unconstrained financial analogies
7
+ overstating physical value.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from .dispatch_approx import BangBangHedgeWarning, bang_bang, horizon_divide, time_aggregate
13
+ from .dispatch_deterministic import DispatchSchedule, dispatch_deterministic
14
+ from .dispatch_sdp import (
15
+ DispatchDiagnostics,
16
+ DispatchFactorModel,
17
+ DispatchResult,
18
+ FactorTransform,
19
+ MonteCarloEvaluation,
20
+ PeakKind,
21
+ PhysicalFactorMapping,
22
+ dispatch_value,
23
+ )
24
+ from .long_dated import (
25
+ BenchmarkResult,
26
+ CorporatePremium,
27
+ LowerBoundResult,
28
+ ValuationSource,
29
+ VarApplicabilityVerdict,
30
+ furthest_forward_lower_bound,
31
+ valuation_benchmark,
32
+ var_applicability_guard,
33
+ )
34
+ from .plant import PlantModel, StartCost, StartState
35
+ from .storage import (
36
+ IntrinsicResult,
37
+ StorageFactorModel,
38
+ StorageModel,
39
+ StorageValueResult,
40
+ storage_intrinsic,
41
+ storage_value,
42
+ )
43
+
44
+ __all__ = [
45
+ "BangBangHedgeWarning",
46
+ "BenchmarkResult",
47
+ "CorporatePremium",
48
+ "DispatchDiagnostics",
49
+ "DispatchFactorModel",
50
+ "DispatchResult",
51
+ "DispatchSchedule",
52
+ "FactorTransform",
53
+ "IntrinsicResult",
54
+ "LowerBoundResult",
55
+ "MonteCarloEvaluation",
56
+ "PeakKind",
57
+ "PhysicalFactorMapping",
58
+ "PlantModel",
59
+ "StartCost",
60
+ "StartState",
61
+ "StorageFactorModel",
62
+ "StorageModel",
63
+ "StorageValueResult",
64
+ "ValuationSource",
65
+ "VarApplicabilityVerdict",
66
+ "bang_bang",
67
+ "dispatch_deterministic",
68
+ "dispatch_value",
69
+ "furthest_forward_lower_bound",
70
+ "horizon_divide",
71
+ "storage_intrinsic",
72
+ "storage_value",
73
+ "time_aggregate",
74
+ "valuation_benchmark",
75
+ "var_applicability_guard",
76
+ ]
@@ -0,0 +1,19 @@
1
+ """Shared floating-point tolerance for discretised grid / feasibility comparisons.
2
+
3
+ :mod:`~quantvolt.assets.storage` and :mod:`~quantvolt.assets.dispatch_deterministic`
4
+ each discretise a continuous state (inventory volume, output level) onto a uniform
5
+ grid and then compare floats against grid boundaries / ramp limits / capacity ceilings.
6
+ Both encode the *same* tolerance for the *same* reason — absorbing floating-point
7
+ rounding in grid-step arithmetic (``floor(span / step + eps)``) and in ``<=``/``>=``
8
+ feasibility checks at a grid boundary — so it is defined once here rather than as two
9
+ independently chosen ``1e-9`` literals.
10
+
11
+ This is distinct from :mod:`~quantvolt.assets.dispatch_sdp`'s
12
+ ``_SURFACE_SLOPE_EPS``, which guards a regression-slope near-singularity (a
13
+ different tolerance for a different purpose) and is not consolidated here.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ #: Grid-alignment / feasibility tolerance shared by storage and deterministic dispatch.
19
+ GRID_EPS = 1e-9