Verace Gapline
Fair value gap and session-filtered backtests with an asynchronous order loop for bitcoin and gold-proxy markets.
- Price klines: Open, high, low and close records per interval
- 50-period moving average: Trend filter on gap signals
- Fair value gap entry: Three-candle gap with trend and session filter
Overview
Verace Gapline is a set of rule-based trading strategies and the code that tests them. Its central signal is the fair value gap: a three-candle pattern in which the first candle's range and the third candle's range do not overlap, leaving a price gap across the middle candle. The question the system addresses is whether trading retracements into such gaps, filtered by trend and by time of day, produces a usable signal on hourly and minute price bars for a bitcoin pair and a gold-backed token pair. A separate backtest tests a z-score mean reversion rule on the same bitcoin data.
The system is organised as standalone scripts. A data ingestor downloads historical price bars, called klines (open, high, low, close records per interval), into a local JSON matrix. Three backtests apply the fair value gap rule. A bullish gap exists when , where is the first candle's high and the third candle's low. Each backtest adds a 50-period simple moving average as a trend filter, and one adds a London session window of UTC hours 8 to 16. An asynchronous engine streams 1-minute klines, applies the same gap and session logic, and builds signed market orders for an exchange test network.
The code implements the strategy logic. The bitcoin gap backtest trades a fixed 0.05 quantity per signal and liquidates remaining inventory at the end of the data. The gold-proxy backtests size each trade at 25% of balance. The mean reversion backtest computes over 20 closes and trades 0.02 quantity when , gated by a sentiment value computed as of the bar index, which is a placeholder rather than a real signal. Two ingestion scripts print progress messages for news, sentiment and video ingestion without ingesting any data.
Status: the backtests, the historical data ingestor and the asynchronous order loop exist as code. No backtest output, performance figure or evaluation record is recorded, so nothing about the strategies' returns has been measured in the lab's records. The sentiment filter in the mean reversion test is a placeholder function, and the news and video ingestion scripts only print messages. The order loop is configured for an exchange test network; the records do not show whether it was run, or whether any orders were sent from a live or a test account. Whether the gap signal carries predictive value remains open.
Status
Prototype. Strategy backtests, a data ingestor and an asynchronous order loop exist as code, with no recorded backtest results or evaluation.
Simulator
A made-up series, and a rule that fires when a point lies far from the average of the points before it. Set how far, and how many points it looks back over.
- synthetic data: not a record of any market
- score: distance from the average, in units of the spread
- Times the rule fired
- 18
- Points outside the band
- 25%
- Longest stretch without firing
- 37 points
- The series
- Synthetic
Narrow the band and the rule fires on noise; widen it and it misses moves. A longer window makes the band slower to follow.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Bitcoin fair value gap backtest
Runs the fair value gap rule with a 50-period moving average trend filter over cached bitcoin klines, trading a fixed quantity per signal.
Gold-proxy gap backtest
Applies the same gap and trend logic to a gold-backed token pair, fetching klines from a public market-data feed and sizing trades as a fraction of balance.
London session variant
A version of the gold-proxy backtest that admits trades only inside the London session window parsed from each kline's timestamp.
Z-score mean reversion backtest
Trades deviations of price from its rolling mean on bitcoin closes, gated by a placeholder sentiment value.
Historical data ingestor
Downloads 1000 hourly bitcoin klines into a local JSON matrix used by the backtests.
Asynchronous trading loop
The
VeraceAGI_HFTengine inverace_hft_core.pystreams 1-minute klines over a websocket, applies the gap and session logic, and builds signed market orders addressed to an exchange test network.Placeholder ingestion scripts
Two scripts that print progress messages for news, sentiment and trading video ingestion; they perform no data ingestion.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Three-candle fair value gap detection
- In
smc_orderflow_model.pya bullish gap is flagged when for three consecutive candles; the bearish case mirrors it with the first candle's low above the third candle's high. A buy of 0.05 quantity is taken when the middle candle closed up and price is above the 50-period simple moving average, and sells mirror this for bearish gaps. - End-of-data inventory liquidation
- The bitcoin gap backtest closes any remaining position at the final bar, so the reported balance reflects a flat position rather than open inventory.
- Balance-proportional position sizing
xauusd_smc_backtest.pyuses the same gap and moving average logic as the bitcoin backtest but sizes each trade at 25% of current balance instead of a fixed quantity.- London killzone session filter
xauusd_smc_london.pyandverace_hft_core.pyparse the UTC hour from each kline's timestamp and accept signals only when the hour lies between 8 and 16, the London and New York overlap. Signals from the Asian session are rejected, which the code treats as low-density chop.- Rolling z-score signal
symplectic_strategy_backtest.pycomputes a rolling mean and standard deviation over 20 closes and forms . It buys 0.02 quantity when and sentiment exceeds 0.5, and sells when and sentiment is below -0.5.- Sinusoidal placeholder sentiment
- The sentiment gate in the mean reversion backtest is of the bar index , a deterministic stand-in with no relation to market data.
- Kline download to JSON matrix
historical_ingestor.pyrequests 1000 bitcoin klines at a 1-hour interval and writes them to a local JSON file read by the backtests. It then prints news and sentiment ingestion messages that correspond to no computation.- HMAC-SHA256 order signing
- The trading loop in
verace_hft_core.pysigns each market order request with an HMAC-SHA256 digest of its parameters before submission to the exchange test network endpoint, inside an asynchronous websocket loop over 1-minute klines.
Concepts
- Fair value gap
- A price region left untraded across three candles, where the first candle's high is below the third candle's low (bullish) or the reverse (bearish). The strategy treats a return of price into the gap as a trade signal.
- Smart money concepts orderflow
- A discretionary trading vocabulary, labelled SMC and ICT in the code, built around patterns such as fair value gaps and session timing. The code turns its gap rule into a fixed algorithm.
- Killzone
- A time-of-day window regarded as high-activity. Here it is UTC hours 8 to 16, covering the London session and its overlap with New York.
- Moving average trend filter
- Trades are allowed only in the direction indicated by price relative to its 50-period simple moving average, so gap signals against the prevailing trend are discarded.
- Z-score mean reversion
- A rule that assumes price returns toward its recent average: a close far below the rolling mean, measured in standard deviations, is a buy, and far above it a sell.
- Kline
- A candlestick record holding open, high, low and close prices and volume for one fixed interval, such as 1 minute or 1 hour.
- Backtest
- A replay of a trading rule over historical price data to compute the balance it would have produced. No result from the backtests here is recorded.
- Placeholder signal
- A stand-in value that occupies the place of a real input. The sentiment gate and the printed ingestion messages are placeholders, so any result from the mean reversion backtest does not reflect sentiment data.
- Exchange test network
- A sandbox endpoint that accepts orders in the same format as a production venue without settling real trades. The trading loop is configured to address one.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
Market results here are backtests and logs kept by the lab. Nothing on this page is financial advice.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.