liveBook · Manning

Contract

As explained in Applied Reinforcement Learning

A fixed, mutually agreed interface that connected software modules are not allowed to change silently.

A contract is a fixed, mutually agreed interface between software modules. Define its fields, meanings, and allowed ranges in advance so independently built modules do not silently drift apart. A stable, versioned, validated contract lets different signal producers serve the same agent without changing the environment or agent. section 12.5

Listing 12.6 The signal schema: thirteen named fields
@dataclass
class MarketSignal:
    market_sentiment:   float = 0.0   #A
    risk_on_signal:     float = 0.0
    rates_pressure:     float = 0.0
    inflation_pressure: float = 0.0
    growth_signal:      float = 0.0
    tech_signal:        float = 0.0   #B
    energy_signal:      float = 0.0
    financials_signal:  float = 0.0
    defensive_signal:   float = 0.0
    volatility_risk:    float = 0.0
    liquidity_risk:     float = 0.0
    geopolitical_risk:  float = 0.0
    confidence:         float = 0.0   #C
 
    def to_vector(self) -> np.ndarray:
        return np.asarray([getattr(self, f) for f in self.FIELDS], 
        ➥ dtype=np.float32)  #D

The MarketSignal schema makes the contract concrete: it names thirteen fields and specifies their value ranges. section 12.5

How Applied Reinforcement Learning covers it

How deep it goes
Defines thirteen named fields and bounded ranges, and calls for versioning and validation without detailing compatibility procedures.
Examples
Uses a MarketSignal schema with twelve directional or risk fields and a confidence field.
What it assumes
Assumes independently built modules need to exchange structured signals; introduces the interface contract in plain terms.
What you can do after
Build it from scratch by fixing field meanings and ranges, then validating and versioning the interface.
How it connects
Links application programming interfaces, schemas, language models, and reinforcement learning agents.

Also explained in

Compare how 58 books explain contract →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Applied Reinforcement Learning. The section links point to the parts of the book it draws on.