A House Divided A House DividedDocumentation
↵
Changelog
Game Design/Economy & Finance

Commodities

Last updated 2026-10-29
Player wikiCommodities
Source files

Player guide: Commodities

Summary#

Commodities model inputs and outputs between corporate sectors. Prices move with global and regional supply and demand, and feed into sector profit margins.

Supply is not an abstract number: under the live market mode (marketSystemMode: "plants", see The Capacity Economy (as shipped)) a sector's commodity output comes from real plant capacity it built and staffed. A sector still under construction, or mothballed, contributes nothing to supply even though it exists on paper. Sold units, not nameplate revenue, are what move the D/S ratio below. Beyond the margin modifiers described here, commodity prices also scale sector revenue directly through price realization (see that section below), and under the deeper clearing/capital tiers, revenue itself is derived from what capacity actually sold, not asserted from a growth rate. See The Capacity Economy (as shipped) and the in-game Market System guide for the full production side of this loop.

Rules#

The 27 commodities#

27 commodity types trade across the economy (COMMODITY_TYPES, ):

Category Commodities
Extractable Iron Ore, Coal, Crude Oil, Rare Earth Minerals (merged with copper), Natural Gas, Timber
Industrial Steel, Electronics, Chemicals, Plastics, Ordnance
Energy & Fuels Electricity (Energy), Fertilizers, Pharmaceuticals, Vehicles
Food Food Products
Construction Building Materials, Construction Services
Services Software, Financial Services, Healthcare Services, Real Estate Services, Advertising, Consulting Services, Freight, Retail, Network Services

Each sector type supplies and demands specific commodities at rates tied to sector revenue (units are sector daily revenue x rate / basePrice, with the rate tables SECTOR_SUPPLY and SECTOR_DEMAND in ). A sector's production policy scales its flows through getOutputMultiplier and getInputMultiplier (): policy is clamped to -25 to +25, and at +25 supply is x1.15 and input demand x1.10, at -25 supply is x0.90 and input demand x0.85, linear in between. Retail demands many inputs and supplies the Consumer Goods (retail) commodity. Only owned corporate sectors participate in a state's commodity flow. State-owned sectors count at NATCORP_COMMODITY_MULTIPLIER = 1.0.

Base prices (COMMODITY_BASE_PRICES, same file) are in dollars per unit, for example steel 800 per ton, oil 80 per barrel, energy 60 per MWh, vehicles 25,000, rare earth 21,000 per ton (a demand-weighted copper and rare-earth blend). Worlds on an earlier-era unit basis divide them by the era unit scale (eraScaledBasePrices).

Pricing#

Each turn, prices update from supply and demand using logarithmic scaling with no hard cap:

ratio = demand / supply
if ratio >= 1: price = basePrice × (1 + 0.7 × ln(ratio))    # shortage
else:          price = basePrice / (1 + 0.7 × ln(1/ratio))   # oversupply

The 0.7 is COMMODITY_PRICE_LOG_SCALE (); the formula is computeMarketPrice in the same file.

Blended price for display: 50% wide leg + 25% national (country aggregate) + 25% regional (state-level) (GLOBAL_PRICE_WEIGHT, NATIONAL_PRICE_WEIGHT, REGIONAL_PRICE_WEIGHT, , blended by blendPrice). The wide leg is the price of the market a country can actually reach when it has a reachable book, and the plain global price otherwise (priceCommodity, ). The 50/25/25 price blend is fixed. Tariffs do not move it: they shift the weights of the margin blend only, through getTariffBlendWeights (), linearly from 50/25/25 with no tariff stack to 25/50/25 at a full stack (TARIFF_BLEND_SHIFT_AT_FULL = 0.25, ; the local leg stays 25%); see Tariffs.

Drift and damping:

Raw supply/demand pressure is compressed by a soft-knee (a point past which extra pressure counts for much less) before it reaches the price formula. In computeEffectiveCommodityPressureRatio (), with L = |ln(raw ratio)| and K = ln(knee), effective log pressure is L when L <= K, otherwise K + (L - K) x COMMODITY_PRESSURE_TAIL_SLOPE, with the sign of the original pressure. Both supply and demand are floored at MIN_COMMODITY_FLOW_UNITS = 0.01 before the ratio is taken. Pressure stays at full fidelity up to COMMODITY_PRESSURE_SOFT_KNEE = 3 (3x shortage/oversupply, ), beyond which the tail is compressed at COMMODITY_PRESSURE_TAIL_SLOPE = 0.25. Worked example: a raw 5x shortage has L = 1.609, K = 1.099, so effective pressure is exp(1.099 + 0.510 x 0.25) = 3.41x and the price is basePrice x (1 + 0.7 x ln 3.41) = 1.86x base. The six extractable resources (iron, coal, oil, natural gas, timber, rare earth) use a wider knee for PRICE math only, EXTRACTABLE_PRESSURE_SOFT_KNEE = 8 (, chosen by getPriceSoftKnee), so scarcity in those markets keeps signalling further before compression kicks in. Margin math always uses the default 3x knee, even for extractables.

Macro-driven commodities (financial services, healthcare services, advertising, real estate services) use a 50/50 global/national blend because state-level activity is meaningless for nationally-driven demand (COMMODITIES_NATIONAL_REGIONAL_PRICE_BLEND, ).

Extra demand that does not come from sectors, all in :

Demand source Constant Value
Government healthcare spending to healthcare services GOVT_HEALTHCARE_DEMAND_RATE 0.015
GDP to network services NETWORK_SERVICES_GDP_DEMAND_FRACTION 4e-6
GDP to construction services CONSTRUCTION_SERVICES_GDP_DEMAND_FRACTION 5e-7
GDP to building materials BUILDING_MATERIALS_GDP_DEMAND_FRACTION 2e-4
GDP to real estate services REAL_ESTATE_GDP_DEMAND_FRACTION 0.00002
Marketing budget to advertising MARKETING_ADVERTISING_DEMAND_RATE 0.9, with elasticity MARKETING_ADVERTISING_DEMAND_ELASTICITY 0.85
State media to advertising STATE_MEDIA_DEMAND_RATE 0.09
Government defence spending to ordnance GOVT_DEFENSE_ORDNANCE_DEMAND_RATE 0.005
Bond issuance to financial services FINANCIAL_DEMAND_ISSUANCE_FRACTION 0.000022, scaled by a rate multiplier clamped 0.6 to 1.4 around FINANCIAL_NEUTRAL_RATE 2.75
Retail GDP demand RETAIL_GDP_DEMAND_SCALE 15, multiplier clamped 0.5 to 2.0, weighted 0.5 national and 0.5 regional

Per-country national demand multiplier (COUNTRY_COMMODITY_DEMAND_MULTIPLIER): only DD construction_services x18, applied to that country's national demand leg only; every other pair defaults to 1.

Margins#

Margin modifiers are computed independently at global, national, and state level, then blended 50/25/25 by default, or by the tariff-shifted weights above:

globalMod   = -K × Σ(rate_i × ln(D_global_i / S_global_i))
nationalMod = -K × Σ(rate_i × ln(D_national_i / S_national_i))
stateMod    = -K × Σ(rate_i × ln(D_state_i / S_state_i))
rawMod = 0.5 × globalMod + 0.25 × nationalMod + 0.25 × stateMod

Each ln term uses the soft-knee effective ratio, and each commodity's contribution is rounded to 2 decimals. With COMMODITY_LOG_K = 40, shortages are meaningful but manageable:

Scenario (rate=0.25) Ratio Margin hit
Mild shortage 1.1× -1.0%
Moderate 1.4× -3.4%
Severe 2.0× -6.9%
Extreme 5.0× -12.3%

The 5.0x row is a raw ratio: the 3x soft-knee compresses it to an effective 3.41x before the formula, so the hit is 40 x 0.25 x ln 3.41 = 12.3%. Rows at or below 3x are unaffected.

Sellers in scarce markets get an equivalent surplus bonus (same formula, positive sign); sellers in a glut take the matching negative.

Per-commodity soft cap: No single commodity can contribute more than ±50 percentage points to the modifier (COMMODITY_PER_ITEM_CAP = 50).

All margin constants live in , and the blend is computed by computeBlendedMarginModifiers in the same file, which takes the tariff-aware weights.

Aggregate caps: After blending, the input leg is floored at −COMMODITY_AGGREGATE_INPUT_CAP (30) and the surplus leg is capped at +COMMODITY_AGGREGATE_SURPLUS_CAP (30). If input plus surplus falls below −COMMODITY_COMBINED_FLOOR (15), both legs are scaled by 15 / |combined| so the combined channel cannot go below −15 percentage points.

State stabilizers: A state-level stabilizer prevents extreme ratios when a state has zero local supply, applied only in the margin path (state prices remain fully dynamic).

Retail penalty: Retail sectors take only 25% of negative input penalties (RETAIL_NEGATIVE_COMMODITY_PENALTY_FACTOR, ), reflecting substitution power. It is applied before the aggregate input floor.

Price realization#

Beyond the margin modifiers above, commodity prices scale sector revenue directly (when the market system tier is enabled):

factor = clamp((price / basePrice) ^ 0.5, 0.7, 2.0)
sectorRealization = supply-rate-weighted mean of factors across a sector's outputs
realizedRevenue = baseRevenue × sectorRealization

Prices are lagged one turn to break the price-to-revenue-to-supply feedback loop, and realization alone moves revenue by at most -30% to +100% (the clamp). This is on top of, not instead of, the margin modifiers: shortages now reward producers with more top-line revenue, not just a better margin percentage, and gluts bleed revenue even when the margin looks tolerable. The constants are PRICE_REALIZATION_MIN = 0.7, PRICE_REALIZATION_MAX = 2.0 and an exponent of 0.5, in . A missing, non-finite or non-positive price ratio is treated as 1, and a sector with no positive supply rates realizes exactly 1. Worked example: a sector selling steel at 2x base gets 2 ^ 0.5 = 1.41x revenue; at 0.5x base it gets 0.71x; at 8x base it is capped at 2.0x.

Data#

Collection Fields Player-visible
commodityPrices (written, one doc per commodity) basePrice, globalPrice, globalSupply, globalDemand, statePrices, stateSupply, stateDemand, nationalPrices, nationalSupply, nationalDemand, reachablePrices, scarcityMult, scarcityMultByCountry, hardPeg, stateHardPegs, nudgePrice, stateNudges, priceAttribution, turn, updatedAt prices, supply, demand: yes. Pegs, scarcity multipliers and attribution: admin or detail views
commodityPriceHistory per-turn price snapshot per commodity, pruned beyond 240 turns yes, as the price chart
commodityFlows per-turn flow ledger (supplied, demanded, cleared, unmet, unsold), kept COMMODITY_FLOW_RETENTION_TURNS = 240 turns, written when marketSystemMode is at least ledger partly
tradeFlowSnapshots trade clearing snapshot for the map yes
corporateSectors (read) sectorType, revenue, stateId, countryId, strategy and production policy yes
macroMetrics, states, federalBudget, stateBudgets, bonds, centralBanks, exchangeRates (read) GDP, budgets, issuance and rates that feed the latent demand sources yes
tariffs, tradeEmbargoes, organizationMemberships (read) tariff and embargo posture yes
stateResourceCapacity, extractionContracts (read) extraction capacity and contracts yes
gameConfig (read) the flags in Configuration no

Types are in .

Configuration#

Behaviour that depends on gameConfig (, document _id: "default"). Every flag is off, unset or 0 unless an operator sets it, and an absent marketSystemMode resolves to "off" (getMarketSystemMode, ).

Field Default Effect
marketSystemMode "off" when absent; live worlds run "plants" Graduated tier ladder from off up to plants; plants makes supply come from real plant capacity, ledger and above write the flow ledger
productLinesV2Enabled off Product-project reads; needs plants tier
commandEconomyEnabled off Planned economies get administered national prices (dual-track by planned share)
extractionOutputScaleEnabled off Applies EXTRACTION_OUTPUT_SCALE to extraction supply: rare earth 2.5, natural gas 2.0, iron 1.8, timber 1.6, oil 1.4; coal omitted ()
demographicsDemandEnabled off, uncalibrated Income demographics add consumer demand
householdConsumptionEnabled off, uncalibrated Household ledger demand, supersedes retail's input proxy and the demographics flag
householdConsumptionPerCapita unset Optional per-world sizing override
commodityScarcityDriftEnabled off Persistent imbalance ratchets a per-commodity price multiplier (scarcityMult)
commodityFixStage 0 Treadmill fix stages 0 to 6, advanced one per turn by an operator ()
marketRecoveryStage 0 Market recovery program stage ()
stockCoverCapEnabled off Extra spoilage on stock above the cover cap
producerFundedBookStage 0 Prices from the funded market's measured book
commodityNominalPriceIndex, retailDemandTransitionStartTurn, producerPriceMaxMove, producerPriceMaxMultiplier unset Nominal price index, retail demand transition, funded price pace limits

Constants such as COMMODITY_PRICE_DRIFT_RATE, the knees and the stabilizers are code constants, not config. The era unit scale (eraScaledBasePrices) and the DD demand multiplier are the only preset or country variants.

Timing#

Order within one turn (, ):

  1. corporationTurn runs first. Sector margins and price realization read the stored prices from the previous turn, which is the one-turn lag.
  2. macroCountryTurn updates the national figures (GDP, budgets) that feed the latent demand sources.
  3. commodityPrices runs processCommodityPriceTurn (), in parallel with bondTurn. It builds supply and demand from owned sectors and the latent sources, computes global, national and state prices, drifts them, and saves history.
  4. contractSettlement follows, settling extraction contracts at the new prices.
corporationTurn (reads last turn's prices) -> macroCountryTurn -> [commodityPrices || bondTurn] -> contractSettlement

So a supply change made this turn shows up in the price this turn, but reaches sector revenue and margins on the next turn.

Worked trace#

One steel market, one manufacturer, at a turn where currentTurn is not supplied to the drift term, so no unowned drift is added. Steel base price 800, global stabilizer 41,000 (COMMODITY_STABILIZER).

Global price:

  1. Owned sectors supply 60,000 units of steel and demand 100,000. With the stabilizer on both sides: supply 101,000, demand 141,000.
  2. Ratio 141,000 / 101,000 = 1.3960, below the 3x knee, so effective pressure is unchanged. ln = 0.3336.
  3. Target price = 800 x (1 + 0.7 x 0.3336) = 800 x 1.2335 = 986.84.
  4. Previous global price was 900. Drift: 900 + 0.06 x (986.84 - 900) = 905.21 stored as globalPrice.

Margin for a manufacturer with a steel input rate of 0.2:

  1. Global: -40 x 0.2 x 0.3336 = -2.67.
  2. National book as is, 20,000 supply and 30,000 demand: ratio 1.5, ln 0.4055, so -40 x 0.2 x 0.4055 = -3.24.
  3. State book 100 supply and 400 demand, plus the 250 state stabilizer on each side: 350 and 650, ratio 1.8571, ln 0.6190, so -4.95.
  4. Blend: 0.5 x -2.67 + 0.25 x -3.24 + 0.25 x -4.95 = -1.335 - 0.81 - 1.2375 = -3.38 percentage points. It is above the -30 floor, so it stands.

Price realization next turn for a steel producer: price over base is 905.21 / 800 = 1.1315, ^0.5 = 1.0637, inside 0.7 to 2.0, so its revenue is multiplied by 1.064.

Edge cases and limits#

Invariants#

Failure and recovery#

Connections#

Driven by:

Affects:

Related pages:

Tests#

Known issues and history#

Commodity Page#

The commodity detail page shows:

In-game UI: /commodity/[type] is the detail page; sector pages link their commodity rows into it; for sector economics see Corporations.

Key files:

Last checked: 2026-10-29, version 1.18.0

Ask