A local gap detector for latency arbitrage, DRY by default.

HFTE Agent is an experimental open-source agent written in Rust. It compares a fast price feed with a slow trading account, raises a signal when a gap opens and, only if you enable it, sends an order to the slow account and closes it automatically.

Experimental software, provided as is, without warranty. Not financial advice.

Local TCP onlyListens on 127.0.0.1, default port 9100. No other network access, no telemetry.
DRY by defaultSignals are logged and no order is sent until you set LIVE_ORDERS=1.
Decided locallyEvery decision is taken on your machine. Logs go to stderr, timestamped in UTC.
MIT licensedRead it, audit it, fork it. The names and logos are not licensed.
Read this first. This is experimental software. It runs in DRY mode by default: signals are logged and no order is ever sent. Set LIVE_ORDERS=1 only on a demo account first, with the minimum lot size. You are responsible for every order it sends.
Brokers. Many brokers restrict or prohibit latency arbitrage. Read your broker's terms before using this software. Whether your use is allowed is your responsibility.

How it works

From a quote to an automatic exit, in four stages.

1. Receive

Your local client program sends quotes, positions and order results to the agent over TCP on 127.0.0.1. The protocol is described in docs/PROTOCOL.md.

2. Detect

With a fast quote F and a slow quote S: buy_gap = F.bid - S.ask and sell_gap = S.bid - F.ask. A signal is raised when the larger gap reaches min_gap_pts.

3. Filter

A cooldown, a maximum slow spread, a freshness check on the slow quote and a maximum number of positions.

4. Order and exit

Live mode only: an order goes to the slow account, then closes on stop loss, take profit, trailing stop, gap convergence or maximum age.

Build it, run it

You need a stable Rust toolchain. No prebuilt binaries are published.

terminal - hfte-agent
# 1. Build and test
cargo build --release
cargo test

# 2. Run from the folder that contains hfte-config.json (DRY mode)
target/release/hfte-agent

# 3. Orders: demo account only, minimum lot size
LIVE_ORDERS=1 target/release/hfte-agent
VariableDefaultMeaning
LIVE_ORDERSunsetSet to 1 to send orders. Anything else means DRY.
AGENT_PORT9100TCP port on 127.0.0.1.
PIN_COREunsetIndex of the CPU core to pin the decision thread to.

On Windows the binary is target\release\hfte-agent.exe. Configuration is described in docs/CONFIG.md. If you build and distribute your own executable, expect antivirus false positives on unsigned binaries.

Is it for you?

We would rather you know before you build it.

A good fit if you

  • Are comfortable building a Rust project with cargo
  • Can write, or already have, a local client that speaks the protocol
  • Want to read exactly how every decision is taken
  • Will start in DRY mode, then on a demo account

Not for you if you

  • Expect returns: this is not a strategy shown to make money, and it makes no performance claim
  • Want a ready-to-use client or console: those are part of Nexus HFTE
  • Trade with a broker whose terms forbid latency arbitrage
  • Cannot afford to lose the capital you trade with

Known limitations

Listed in the repository, repeated here.

A single setup

Only gap-EURUSD is wired in. GBPUSD and USDJPY quotes are parsed but no setup uses them. Point size assumes 5-digit pairs and a 3-digit USDJPY.

Fast-side trigger

Only quotes from the fast connection trigger a decision. Freshness is measured on arrival time and the timestamp sent by the client is ignored.

Risk limits

risk.daily_loss is read and validated but not enforced. max_positions counts every position the client reports, not only those opened by the agent.

No market guards yet

No quote-freeze detection, no spread filter on the fast side (abnormal fast quotes around the daily rollover are not filtered) and no trading-hours window.

Exit scope

Automatic exits apply only to tickets opened by the agent during the current run, while the client keeps sending position reports. After a restart, existing positions are left to their stop loss.

Age after reconnect

After a disconnection of the trading client, the age of a position restarts from zero, so max_life restarts too. One demo order was once not closed by max_life in an internal build, cause unknown. Keep the stop loss on.

Config fallback

An invalid or missing configuration file makes the agent fall back to the defaults. It logs why.

Scripted client only

This build has been tested against a scripted local client only. No live broker connection has been tested with it. The decision loop has no unit test yet.

Optimistic DRY logs

DRY signals are based on quote arrival times: no slippage, no rejection, no last look. The core_us value is a diagnostic, not a latency. End-to-end latency has not been measured.

Clone it, read it, run it in DRY mode

HFTE Agent is free and open source under the MIT license. The cloud console, the ready-to-use client and the support are part of Nexus HFTE and are not in this repository.

Research software, not investment advice. Trading leveraged products carries a high risk of loss. See our risk disclosure. The names "Nexus HFTE" and "Algotradingresearch" and any logo are not licensed under the MIT license.