Agentic tradingMarket dataRiskDevelopers

How market data pipelines stay safe when agents trade through one API

How a single API keeps market data safe for trading agents. It filters bad ticks, enforces scoped keys, and prevents data corruption from causing major losses.

By the Felix team9 min read
Key takeaways
  • 01Market data for trading agents must be treated as a safety layer, not just plumbing, because bad data causes autonomous systems to lose money fast.
  • 02A single API normalizes venue-specific formats into plain dollars and standard structures, reducing the chance that an agent misinterprets a tick.
  • 03Scoped keys separate data read access from execution authority, so a compromised or confused agent cannot trade beyond its pre-approved limits.
  • 04The pipeline filters stale ticks, anomalous spikes, and divergent sources before they reach the agent, shrinking the window for data-driven errors.
  • 05The kill switch operates independently of data quality, immediately revoking access and flattening positions when the owner needs to stop everything.

Trading agents that act on stale, manipulated, or misinterpreted market data can lose money before a human notices the error. A single API that feeds prices and order books to autonomous agents must treat data integrity as a safety layer, not just an infrastructure detail. The safety model behind Felix's market data pipeline separates read access from execution authority, enforces rate limits and anomaly checks at the API boundary, and ensures that bad data alone cannot trigger unbounded trades. This design keeps the agent informed while preventing the data stream from becoming an attack vector.

What makes market data risky for autonomous agents?

Autonomous agents do not sleep or second-guess. They ingest a price, compare it to a rule, and act. If the price is wrong, the trade is wrong, and the loss is real. Market data can fail in ways that are subtle enough to fool an automated system while remaining obvious to a human trader. A venue might publish a stale quote after a brief outage. A thin order book might show a distorted midpoint after a large market order. A corrupted websocket frame might present a bid above the ask. In each case, the agent sees a signal and executes against it.

The risk is amplified by speed. An agent scanning multiple markets across stocks, crypto, perps, options, and prediction markets can issue orders within milliseconds of receiving a tick. There is no natural pause for reflection. Without a safety model wrapped around the data layer, the agent effectively delegates its risk assessment to the feed itself. That is a single point of failure. If the feed fails, the agent's strategy fails with it, and the capital at risk belongs to the owner, not the venue.

Furthermore, agents often operate with strategies that assume continuous data. A mean-reversion bot might see a stale high price and sell into a market that has already crashed. A grid trader might stack orders at levels computed from a frozen index. The consequences cascade because the agent's future decisions depend on its current position. One bad tick can alter the entire state machine. This is why the pipeline cannot be treated as a passive pipe. It must be an active participant in risk control.

How does one API normalize data without centralizing trust?

Felix exposes one API and one key model, but the goal is not to make the agent trust the API as an oracle. The goal is to translate venue-specific noise into a consistent language so the agent can reason in plain dollars and uniform structures. When an agent requests a price for a perpetual future or an option, the API handles contract sizing, decimal conventions, and notional math. The agent receives a number it can compare to its strategy directly. This reduces the chance that the agent misinterprets a venue-specific format and trades on a miscalculated notional.

Normalization happens at the infrastructure layer, while safety controls stay at the authorization layer. The API does not take custody of funds, and it does not ask the agent to trust it with withdrawal rights. The non-custodial design means the owner's wallet remains under the owner's key. The API can only spend within pre-approved limits. This separation is important because it means a corrupted data pipeline cannot re-route funds. It can, at worst, cause a bad trade, and even that is bounded by the controls described later.

The single API also shields the agent from venue churn. If a perps venue changes its tick size or a prediction market alters its odds format, the API absorbs the change. The agent's strategy code stays stable. This indirection is a safety feature because it reduces the likelihood that an agent will trade on misunderstood contract terms after a remote update. The agent deals in dollars and standard structures, while the API manages the mapping. Developers who want to understand the full checklist for reliable pipelines can read our guide on how to build a reliable market data pipeline for trading agents. The broader architecture of the API itself is covered in a trading API built for AI agents.

Where do scoped keys and budget caps protect the pipeline?

The market data pipeline is protected by the same key scoping that protects execution. A developer can create a key that is allowed to read order books but not to place orders. Another key might be allowed to trade, but only up to a daily budget cap. A third might be restricted to a single market type, such as prediction markets only. These scopes are enforced by the API, not by the agent's good behavior. This means that if an agent is compromised, or if its logic is confused by bad data, the damage is mechanically limited.

The distinction between read and write scopes is particularly important for data safety. An agent that only needs to monitor prices should receive a read-only key. If that agent is hijacked or hallucinates a trading signal, the API will reject any order submission. The read-only key acts as a sandbox. When the agent is later upgraded with trading logic, it receives a new, narrowly scoped key with explicit limits. This progression prevents a simple data-gathering script from accidentally becoming a live trader.

Budget caps are the universal backstop. Even if every price in the feed is wrong and the agent trades on all of them, the total outflow is capped. Position limits prevent concentration in any single instrument. Exit plans can force closure after a holding period. The agent cannot escalate privileges by asking for more data. It cannot read a bad price and then bypass a position limit because the limit is checked at the API gateway, not inside the agent's code. The owner can review the flattened positions, revoke the key, and investigate without facing an unbounded loss. For a step-by-step walkthrough of setting these boundaries, see how to set guardrails for a trading agent.

How does the pipeline handle stale or anomalous prices?

Raw feeds are noisy. The API applies a set of sanity filters before any tick reaches the agent. Timestamps are checked. If a venue's update is older than the configured threshold, the API marks it stale and may withhold it from the normalized stream. Cross-venue checks apply for instruments that trade on multiple platforms. If one source diverges sharply from the others, the API flags the outlier rather than blending it into a false consensus. The agent receives either a clean price or an explicit warning.

Spike detection acts as a circuit breaker. Suppose a thin crypto order book prints a trade at ten percent away from the last valid tick. The API can delay publishing that tick until it is confirmed, or it can annotate it with a volatility warning. The agent, or the human operator, can decide whether to act. In some configurations, the API will reject order requests that reference an anomalous price until the feed stabilizes. This is a deliberate trade-off: it sacrifices some latency for consistency.

The pipeline also monitors its own health. If the websocket or REST connection to a venue degrades, the API surfaces that status to the agent. An agent that is aware of feed health can pause trading rather than execute against stale silence. These checks do not guarantee perfect data, but they shrink the window during which bad data can cause bad trades. The responsibility is shared. The API filters the feed, and the agent should still sanity-check values against its own model. Neither layer alone is sufficient.

How does the kill switch interact with data-driven execution?

A kill switch is the final layer of the safety model. It is not a data filter; it is a revocation mechanism. When an owner triggers the switch, the API flattens open positions and permanently revokes the scoped keys. The data pipeline does not need to be healthy for this to work. The switch operates on the authorization layer, independent of market feeds. This matters because data corruption and malicious execution can look similar. If an agent begins trading erratically, the owner may not know whether the strategy is broken, the model is hallucinating, or the feed is lying. The kill switch does not require a diagnosis. It simply stops everything.

Because the API is non-custodial, flattening returns funds to the owner-controlled wallet, minus the losses already incurred. The switch cannot recover past losses, but it prevents future ones. The revocation is immediate. There is no graceful shutdown period during which the agent can place more orders. This is by design. An emergency stop that allows a few more trades is not an emergency stop. Operators should verify this latency in paper mode before going live.

The interaction between the kill switch and the data pipeline is worth testing in paper mode. An operator should verify that revoking a key mid-stream causes the agent to lose execution rights immediately, not at the end of a batch. The docs describe how to wire this into an external monitoring system. For a deeper look at the mechanics, see how kill switches work from first principles for trading agents.

What should developers test before trusting the pipeline with live capital?

Paper trading exists precisely for this validation. Before an agent touches real money, it should run against the live data pipeline in a mode where orders are simulated but feeds are real. During this phase, developers should inject artificial latency, observe how the agent behaves when a tick arrives late, and confirm that the API's anomaly filters behave as expected. If the agent is designed to trade across multiple market types, test each one. The contract math for options differs from that for perps, and the API's normalization should be verified in both.

Developers should also audit key scopes. A key that is supposed to be read-only must be unable to trade. A key with a budget cap must hit a hard wall at the limit. The exact request schema is in the docs; the shape looks like this:

curl -X GET
  -H "Authorization: Bearer YOUR_KEY"
  -H "Content-Type: application/json"
  "https://api.felix.trade/v1/feed/status"
  -d '{"check": "stale_ticks"}'

The response should indicate whether the feed is healthy and whether the key is authorized for the requested scope. Do not treat this example as the final specification; it illustrates the pattern. The actual endpoints and fields are documented at the docs. Finally, test the kill switch. Trigger it during a paper session, confirm that the agent's key is rejected on the next request, and verify that the flattening logic behaves correctly for the markets you intend to trade. Only after these steps should the owner authorize live trading for a scoped key. Trading can lose money, including the entire budget allocated to the agent. Paper mode is the right place to discover failure modes, not production.

Frequently asked questions

Can bad market data cause my agent to lose all my money?

Bad data can cause losses, but the safety model is designed to prevent total loss. Budget caps, position limits, and the kill switch act as independent backstops. Even if the agent trades repeatedly on incorrect prices, the scoped key will eventually hit its hard limits and stop.

Does the API guarantee that every price is accurate?

No API can guarantee perfect accuracy across external venues. The pipeline applies timestamp checks, cross-venue comparisons, and spike filters to reduce error rates. Agents should still include their own sanity checks as a final line of defense.

How quickly does the kill switch stop my agent?

The kill switch revokes the API key immediately. The agent loses execution rights on its very next request. Open positions are flattened according to the exit plan configured for that key.

Can I let my agent read data without giving it permission to trade?

Yes. Scoped keys allow read-only access to market data. An agent with a read-only key cannot place orders, which lets you test strategies and monitor feeds without execution risk.

Should I test the data pipeline in paper mode first?

Yes. Paper trading uses live feeds but simulated orders. It is the right environment to observe how the agent handles latency, anomalies, and normalization across different market types.

What happens if a venue feed goes down entirely?

The API marks the feed as stale or unavailable and surfaces this status to the agent. Orders that rely on the missing data may be rejected until the feed recovers. The agent should be designed to pause rather than trade into silence.

Give your agent a key.

One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.

Keep reading

Not a brokerage, exchange, or investment adviser. Not investment advice. Trading involves risk, including total loss.