Skip to content

Trade offer

A Trade offer (engine class: trade) is X4’s representation of buy offers, sell offers, and trade orders (deals). The same trade type covers all three — distinguished via .isbuyoffer / .isselloffer / .isoffer / .isorder flags.

PropertyTypeDescription
.existsbooleanTrade exists
.availablebooleanTrade exists and is available
.isbuyofferbooleanIs a buy offer
.issellofferbooleanIs a sell offer
.isofferbooleanIs an offer (buy or sell)
.isorderbooleanIs an order (accepted deal)
PropertyTypeDescription
.buyercontainerBuyer container
.sellercontainerSeller container
.ownercontainerOwner (seller or buyer)
PropertyTypeDescription
.warewareTrade ware
.amountintegerTrade amount
.desiredamountintegerTrade desired amount (may exceed affordable)
.offeramountintegerTrade amount + reserved
.offeramount.{$object}integerTrade amount + reserved for $object
.minamountintegerMinimum trade amount
.transferredamountintegerWares transferred for this trade
.destroyedamountintegerWares destroyed for this trade
.volumeintegerTotal volume of trade amount
.offervolumeintegerTrade volume + reserved
.offervolume.{$object}integerTrade volume + reserved for $object
.minvolumeintegerVolume of minimum amount
PropertyTypeDescription
.pricemoneyTotal price of trade amount
.unitpricemoneyPrice per single unit
.minpricemoneyTotal price of minimum amount
.relativepricefloatCurrent price between min and max (-1.0 to +1.0)
.quantityfactorfloatCurrent/average price ratio
.hasdynamicpricebooleanPrice not fixed (e.g., player-set)
PropertyTypeDescription
.stocklevelfloatTrade amount / target amount ratio
.stocklevel.{$amount}floatAmount / target amount ratio
PropertyTypeDescription
.ispricelocked.{$container}booleanPrice locked on $container’s trade partner
PropertyTypeDescription
.bundlebooleanFlagged for converting ammo/units → wares on transfer
.unbundlebooleanFlagged for converting ware → ammo/units on transfer
PropertyTypeDescription
.ismissionbooleanTrade spawned by mission cue
.missioncuecueMission cue used
.tradeoffertradeSource trade offer (for orders)
PropertyTypeDescription
.buyfreebooleanBuyer doesn’t spend money
.buyfree.{$object}booleanFree for specific buyer
.sellfreebooleanSeller doesn’t receive money
.sellfree.{$object}booleanFree for specific seller
<set_value name="$offers" exact="$station.tradeoffers.sell.list"/>
<do_for_each name="$offer" in="$offers">
<write_to_logbook text="$offer.ware.name + ': ' + $offer.unitprice + 'Cr'"/>
</do_for_each>

"Get a station’s current sell price for a ware"

Section titled “"Get a station’s current sell price for a ware"”
<set_value name="$price" exact="$station.sellprices.{ware.advancedcomposites}"/>

"Check if trade offer is part of a mission"

Section titled “"Check if trade offer is part of a mission"”
<do_if value="$trade.ismission">
<write_to_logbook text="'Mission offer: ' + $trade.missioncue.name"/>
</do_if>

"Reserve trade amount for a specific buyer”

Section titled “"Reserve trade amount for a specific buyer””
<set_value name="$reserved" exact="$trade.offeramount.{$myShip}"/>
  • The same trade type covers offers AND orders. Always check .isoffer vs .isorder before assuming meaning.
  • .amount reflects current state; use .offeramount.{$object} for reservation-aware accounting when working with specific buyer/seller.
  • .price is the TOTAL — use .unitprice for per-unit calculations.
  • .relativeprice ranges -1.0 to +1.0 — not 0..1 or percentage. -1 = minimum price, +1 = maximum.
  • Mission trades may be .buyfree or .sellfree — your economy mod’s accounting must handle these.
  • .tradeoffer links orders back to source offers — useful for understanding fulfilment.
ActionPurpose
<create_trade_offer>Spawn a new trade offer
<remove_trade_offer>Remove an offer
<transfer_money>Money transfer (part of trade flow)
<transfer_inventory>Ware transfer (part of trade flow)

Trade offer is the central economic abstraction. Stations expose them as .tradeoffers.*, missions create them programmatically, and the price mechanics drive the entire X4 economy.