Urgent.News

What's breaking now, across thousands of outlets.

Tech

Building a Trading Engine in Java: Beyond BUY and SELL Signals

Generating a BUY or SELL signal is relatively straightforward. Building a system that can reliably execute that signal is a different engineering problem. When I started developing NERV Trade , I was primarily interested in building a trading system capable of analyzing market conditions across multiple timeframes. The initial idea was simple: Market Data | v Technical Analysis | v Trading…

The development of the NERV Trade trading engine in Java presented numerous challenges beyond simply generating BUY or SELL signals. The system needed to become a durable, broker-neutral trading engine capable of handling complex real-world scenarios.

One key insight was that a trading signal and a trade are distinct concepts. A signal represents a strategy's decision, while a trade encompasses the actual execution, order lifecycle, broker interactions, and accounting. This distinction is crucial when building a robust system.

The architecture evolved to separate market data analysis, trading decisions, execution, and persistence into distinct responsibilities. Market analysis should not concern itself with broker-specific details, while a broker adapter shouldn't calculate technical indicators. Each component has its own clear purpose, ensuring the system remains maintainable and scalable.

Another important realization was that a position is not the same as a trade. Multiple strategies can generate exposure in the same instrument without affecting each other's lifecycle. A trade intent owns its exposure, and the aggregate position is simply a derived view. This principle helps avoid unintended consequences when strategies exit or reverse exposure.

Partial fills added another layer of complexity. Realistic execution scenarios involve multiple partial executions, requiring the engine to track individual executions, update relevant state, and maintain consistency. Acknowledgment of an order doesn't guarantee execution, and the system must handle asynchronous updates and reconciliation scenarios carefully.

Handling duplicate executions, which can occur in distributed systems or during restarts, is another critical aspect. The engine must correctly process the execution only once, preventing incorrect position updates. These issues necessitated careful design and robust error handling mechanisms.

As the system grew in complexity, each architectural decision became increasingly important. The separation of concerns, clear ownership of lifecycle stages, and careful tracking of asynchronous updates all contributed to a more reliable and maintainable trading engine. This journey from simple signal generation to a comprehensive trading system demonstrates the engineering challenges inherent in building robust financial infrastructure.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

i wrote a cookie policy for a product that sets no cookies

most cookie policies are confessions written by lawyers. mine is a confession written by me. i’m om yaduvanshi, 18, an applied ai developer building cloudline , a cookieless analytics tool.

  • 18-year-old developer Om Yaduvanshi created Cloudline, a cookieless analytics tool.
  • Cloudline's cookie policy page exists despite no cookies being set, to avoid appearing negligent.
  • The policy outlines four data points collected: page, referrer, screen size, and time.

Writing Freelance Client Proposals That Get Signed

Disclosure: this post was written with AI assistance and reviewed before publishing. A proposal is not a CV and not a brochure.

  • Restate client's problem using their exact terminology
  • Outline measurable desired outcomes in the goals section
  • Present 2-3 pricing options with clear scope and terms

How to preview a coding benchmark run before spending on model calls

Use the --dry-run option to inspect a benchmark plan before launching model calls. In Weave Router's public weave-bench harness, the option resolves the pinned task manifest and prints the Harbor…

  • Use --dry-run option to preview benchmark plan without network impact.
  • --smoke selects smaller task set but may initiate jobs and incur costs.
  • Verify task selection, pinned versions, and comparison arms before removing --dry-run flag.

Why we stopped retrying on timeout and built reconciliation instead

Early in StareBrain’s action dispatch layer, we had a simple rule: if an action times out, retry it. It felt safe. It felt standard. It was wrong. The problem isn’t the retry.

  • StareBrain's previous rule was to retry actions on timeout, which proved incorrect.
  • New state model tracks Delivery and Acceptance states independently to reconcile ambiguous actions.

Pushing Beats Polling Explained: Live Poll Trust Above a Handful of Viewers

Short answer: pushing beats polling above a handful of viewers because one state change should not trigger repeated reads for every screen, but treat delivery as an optimization, not as authorization.

  • Pushing poll results, not polling, reduces unnecessary load and scaling issues with more viewers
  • Trust must be established independently of transport layer for untrusted clients
  • Small, immutable poll state snapshots enable reconnects with correct, up-to-date view

More from Saturday 17 October →