Book / Limen research

Interpret a prediction as a trade

A forecast does not determine a return until entry, exit, exposure, prices and costs are declared. Start from the policy used to evaluate the candidate; changing that policy changes the question.

Contents

The execution variants of the Python project and Compiled project use recorded hourly observations and a separately pinned funding history. Their ledgers state the actual policy and evaluated window.

Prerequisites

Start with the selected predictions and their declared availability. Use the unchanged recorded bars and funding input for the execution variant; changing the product, capital or trading policy creates a different comparison.

The execution engine determines the accounting model

Execution path Position and price interpretation Retained evidence
Snapshot Lagged binary positions over aligned return and OHLC evidence, with configured costs and optional barriers Twenty summary metrics and optional aligned execution tracks
Event cash spot Actual admitted intents and fills against recorded source clocks, with cash and inventory constraints States, intents, fills, episodes, and funding ledgers
Event linear perpetual Signed or fractional exposure under declared quote-settled economics and collateral The same ledger families plus configured funding recognition and settlement

Snapshot multiclass outputs require an explicit binary mapping, and multilabel outputs require an explicit selected label. The limited short/flat snapshot path has its own contract. Event signed exposure instead requests a target position under the configured sizing rules. Backtest owns the exact inputs, metric definitions, and supported policy combinations.

Decision and fill clocks preserve different observations

A decision timestamp identifies the model's row. Availability identifies when the information needed by that decision exists. Recorded source intervals also distinguish open-price availability from full-bar availability. Execution lag applies after the eligible decision becomes available.

The event engine retains pending intents until an admissible recorded fill exists. A fine execution source or formed-bar constituent history supplies its own price and availability evidence. Those clocks explain the relationship between a requested position, its eventual fill, and its measured return.

Python Research

The base experiment trades the next bar from open to close. A positive forecast takes positive exposure, a negative forecast takes negative exposure, and each nonzero decision pays two basis points round trip. The returned value is the mean net return per evaluated observation:

python · research.py
def backtest(validation, forecasts):    positions = np.sign(forecasts)    net = positions * validation["next_return"].to_numpy() - abs(positions) * 0.0002    return float(np.mean(net))

That caller-owned policy is deliberately small. The execution variant separately uses explicit event inputs, product and funding rules. It retains actual fills and account states rather than treating the forecast itself as a fill.

Compiled Research

The worked research manifest declares the product, source interval and execution assumptions alongside the model:

yaml · research.yaml
    backtest:      source_interval_seconds: 900      fee_bps: 7.0      slip_bps: 3.0      notional_rate: 0.5      execution_lag_seconds: 0.0      product:        kind: cash_spot        instrument: BTCUSDT        base_currency: BTC        quote_currency: USDT        quantity_step: 1.0e-9        min_notional: 0.0

Read the event ledger in the retained native records: each fill has a time, quantity, price and fee; account states retain exposure and equity. The execution and funded variants change the declared economics and retain their own results:

bash · run.sh
limen run --no-progress-bar \  compiled-research/execution.yaml \  compiled-research/funded.yaml

A snapshot, a cash account and a perpetual account are different interpretations. Compare returns only after the observation population, availability, policy and capital conventions agree. The execution reference preserves every supported product, clock, barrier, funding, allocation and observed-cost contract. The benchmark reference defines when retained tracks are comparable.

Signed exposure retains sizing and exit policy

Changed sizing signals target post-cost current equity subject to the configured quantity step, minimum notional, and collateral constraints. Unchanged sizing signals hold quantity. Resizes and reversals therefore differ from repeatedly restoring an unchanged percentage exposure on every observation.

Independent exits, elapsed holding limits, timers, take-profit, and stop-loss can close exposure before the model changes direction. Rearming governs later entry. The terminal policy marks remaining event exposure without forcing an invented close. The retained contract identifies those choices beside the ledger.

Funding uses its own observed schedule

Funding declares rate units, valuation conventions, schedule, phase, and recognition or cash-settlement behavior. Discrete settlement and continuous accrual have separate accounting rules. The supplied Binance history provides realized rates and mark prices for the worked perpetual case.

Binance BTCUSDT, Hyperliquid BTC, and Deribit BTC/USDC presets provide declared mechanics and scenario assumptions. Supplied historical funding replaces those scenario rates and must cover the required interval. A settled funding value is cost evidence at its recorded availability; a predictive funding feature requires its own causal source.

Observed fills can calibrate a retrospective cost comparison

The Python-only observed-cost scenario freezes a calibration artifact from pinned actual fills and reference observations. It evaluates each candidate with its original and calibrated execution policy. The admitted calibration changes slippage. Candidate fees remain the declared fee schedule.

python · scenarios.py
def observed_costs(data_dir, output):    fixture = data_dir / 'observed_costs'    expected = {'history.zip': 'df4d7776172df459ec297cbcfe8e72a4748a51ab626e3c990deec83415102093',                'benchmark.json': 'b71011697713417b21302e670abf78c0bff739ec9135c7012db02fa3b2d6ccf8'}    for name, digest in expected.items():        if hashlib.sha256((fixture / name).read_bytes()).hexdigest() != digest:            raise ValueError('Recorded execution-cost input differs: ' + name)    with ZipFile(fixture / 'history.zip') as archive:        history = output / 'history.json'        history.write_bytes(archive.read('admitted.json'))    calibration = CostCalibration.from_history(history, cutoff_ns=1785810791000000000)    artifact, specification = output / 'calibration.json', output / 'research-specification.json'    calibration.write(artifact)    specification.write_text(json.dumps({'calibration_digest': calibration.digest}))    reports = []    for mode in ('binary', 'target_exposure'):        for hour in (1, 2):            experiment, comparison = run_cost_experiment(artifact, specification, fixture / 'benchmark.json',                                                       output / f'{mode}-{hour}', mode=mode, hour=hour)            reports.append({'mode': mode, 'hour': hour, 'rounds': project.completed_log(experiment).height,                            'comparison': comparison.report()})    return {'calibration': calibration.report(), 'runs': reports,            'historical_delivery': 'unknown; retrospective stress only'}
Python Research · observed_costs · current execution
calibration.support.disposition
"retrospective_low_effective_support"
calibration.support.selected legs
363
calibration.support.admitted legs
363
calibration.support.low effective support sides
[
  "sell"
]
historical delivery
"unknown; retrospective stress only"

Limen 6.0.1 · 42593d34 · Merged source PR · Validation and result digest · Native records

Support, side concentration, source clocks, and historical delivery limits remain part of the comparison. The retained sample supports a retrospective stress comparison under its stated assumptions. Observed-cost contracts define admission, immutable calibration, comparison artifacts, and unchanged candidate identity.

Read the fills

These excerpts show the first eight native fills, with Unix nanosecond timestamps, signed quantity changes, reference prices and fees. The full ledgers remain in the native records. The two campaigns use different declared assessment populations; compare their policy and clocks before comparing a return.

Python Research ledger

Python Research · execution · current execution
time nsquantity deltareference pricefee
17040744000000000000.2344300000000000342613.576.995027329405173
1704081600000000000-0.2344300000000000342330.56.944393437285851
17040960000000000000.2330700000000000342492.466.934682137246963
1704103200000000000-0.2330700000000000342649.696.9561667975278585
17041356000000000000.2301143111.16.94628991669641
1704142800000000000-0.2301143687.857.034996682105665
17041572000000000000.22268000000000002450567.0252560007168
1704164400000000000-0.2226800000000000245378.967.071368721729313

Limen 6.0.1 · 42593d34 · Merged source PR · Validation and result digest · Native records

Compiled Research ledger

Compiled Research · execution · current execution
time nsquantity deltareference pricefee
17044164000000000000.2258444211.19.989627141411999
1704420000000000000-0.2258444029.7017115268759.938696000613964
17044236000000000000.2278800000000000343506.019.919106633579402
1704427200000000000-0.2278800000000000343465.219.899899628772603
17044308000000000000.2265500000000000343589.879.880222691024253
1704441600000000000-0.2265500000000000343777.489.912829199953004
17044452000000000000.2251800000000000243911.449.8929220482296
1704452400000000000-0.2251800000000000243711.5732194293459.838050571522325

Limen 6.0.1 · 42593d34 · Merged source PR · Validation and result digest · Native records

Carry the policy with the result

A Sensor emits a prediction with its availability and identity. Downstream trading owns order execution. Continue to linked learning stages with the declared timing and economics, then research evidence to interpret the resulting candidate scores.

Edit this sourceSource revision · 9bc8a630
Reference / keep your place
Find a passage