Skip to content

AI analysis

Queued crypto signals: preserve the expiry

A queued signal passes its first check, then expires before the gateway is ready. Follow the original deadline through retries, recovery and replacement signals.

Ivory paper tickets queue through an open arch toward a closed lime-edged gate, with an hourglass between them.
Illustration for ai analysis; examples in this article are educational.

Crypto workflow queued signal expiry should preserve a deadline tied to the original signal and enforce it when a worker takes the job and again immediately before an order attempt. Time spent waiting, retrying or awaiting approval consumes the same validity window. A free worker, a new delivery or a fresh API signature must not renew an old entry; a newer signal may also make it ineligible under an explicit supersession rule.

Define what expires and when its clock starts

An entry candidate can be valid when created and obsolete when capacity becomes available. A queue preserves work; it cannot establish that the work remains worth acting on. The expiry policy needs a named action boundary: latest analysis start, latest order submission or another precisely defined milestone.

This article uses a latest-submission deadline for an entry. Research may finish after that deadline for audit purposes, but it cannot authorize the expired entry. These are reference design choices, not a claim about available KLINEO settings.

Choose the start from the signal's meaning. A rule based on a completed candle might use its verified close boundary. A rule based on a discrete market event might use that event's documented time. Starting the validity clock at local enqueueing silently excludes the delay before the message reached the queue.

The trading latency budget explains how to select and measure the full path. Here the narrower task is preserving that chosen deadline through delayed jobs. Store the source-time definition, unit, expiry instant and policy revision alongside the signal. Treat those fields as trusted decision context, not a sender-controlled instruction to extend its own validity.

Broker timers answer different questions

Queue terminology can conceal several independent clocks:

Clock or controlWhat it governsWhat it does not establish
Signal validity deadlineWhether this candidate may still reach its named action boundaryThat account and risk checks passed
Message retentionHow long the broker retains a messageThat its market evidence remains current
Delivery delayWhen the message first becomes availableA guarantee it will start at that instant
Visibility or delivery leaseWhen another consumer may receive uncompleted workAn extension of the signal's deadline
Processing timeoutHow long an attempt may runPermission to submit after signal expiry

For example, Amazon SQS queue parameters define retention, delivery delay and visibility timeout separately. None is an application assessment of a trading signal's age. Extending a processing lease can keep ownership stable while the candidate itself becomes ineligible.

RabbitMQ's TTL documentation defines message TTL around residence in a queue and preserves original expiry on requeue. It also documents a race in which expiration happens after a message is written to the socket but before it reaches the consumer. Broker expiry therefore complements application checks; it cannot cover all work after delivery.

An engine can offer another admission check. Celery's task expiration documentation supports seconds after publication or an absolute datetime, and says a worker receiving an expired task marks it revoked. That is a Celery behavior. A workflow still needs its own policy for a candidate that was eligible on receipt and ages during analysis.

Carry one deadline through every handoff

Persist an absolute expiry instant in the authoritative signal record. Each queue message should identify that record and its intended action, with a deadline copy useful for routing. If copies conflict, reject or resolve them against the authority; do not choose whichever gives more time.

At dequeue, reject an expired candidate before spending ordinary analysis capacity. Immediately before submission, check the same expiry again. Required approval, balance refreshes, risk checks, rate-limit waits and gateway queues all consume the remaining time. If the last dispatcher can hold a request, it must receive and enforce the deadline too.

Define the boundary explicitly: in the examples here, submission is eligible only when current time is strictly earlier than expiry. Equality fails. Cross-host age comparisons need compatible timestamps and a clock-uncertainty policy. If the plausible signal age reaches the limit once uncertainty is included, a conservative gate withholds the entry. The wall-clock and monotonic-clock guide covers the clock mechanics; a persisted process-relative timer is not a portable deadline after restart.

Retrying or restoring a run must reload the original expiry. Workflow checkpoint recovery is the relevant next step when the worker crashes: restoring progress must preserve decision constraints as well as completed work. A replacement worker cannot gain another validity window by receiving the same signal later.

A job passes dequeue and still expires before submission

Consider this hypothetical timeline. The source event is at 12:00:00.000 UTC and the entry has an invented five-second latest-submission window. Its absolute expiry is 12:00:05.000. Assume synchronized clocks without uncertainty for this fixture; the values are neither measured performance nor recommended trading thresholds.

ObservationUTC timeAge from source eventDecision
Received and enqueued12:00:00.2000.200 secondsPreserve the 12:00:05.000 deadline
Worker takes the job12:00:03.4003.400 secondsPass dequeue check; 1.600 seconds remain
Analysis and account checks finish12:00:04.6004.600 secondsCandidate still has 0.400 seconds
Gateway becomes ready to send12:00:05.1005.100 secondsFail final check; submit nothing
Original job is redelivered12:00:07.0007.000 secondsRecord expiry; do not restart the entry

The measured queue wait is 3.400 − 0.200 = 3.200 seconds. It is smaller than the signal's 3.400-second age at dequeue. Later work consumes 5.100 − 3.400 = 1.700 seconds, exceeding the remaining 1.600 seconds by 0.100 seconds. The expected number of entry submissions is zero.

A five-second broker TTL starting at enqueueing would end at 12:00:05.200, already 0.200 seconds later than the signal's actual deadline. Republishing at 12:00:07.000 with another full five seconds would create an erroneous 12:00:12.000 deadline. Neither operation makes the underlying event newer.

An AI branch may retrieve useful evidence near the end of the window. Retrieval relevance ranking helps select that evidence, but its relevance and recent retrieval do not renew the original candidate. A fresh decision requires current observations and a deliberately reassessed candidate, linked to the old record.

Supersession needs a decision scope

Expiry asks whether enough time remains. Supersession asks whether a newer accepted decision has replaced this one. A candidate can fail either check independently.

Suppose a strategy allows one replaceable entry snapshot for a particular account, environment, instrument and position side. Candidate generation 81 has not expired, but generation 82 becomes the accepted current snapshot. Under that declared policy, 81 is superseded and cannot submit. Generation numbers here are illustrative application versions, not exchange order identifiers.

Define that replacement scope carefully. Grouping everything by ticker could discard a protective exit because a new entry arrived. Independent strategies or accounts may need independent decisions. Preserve cleanup and exposure-management work under their own policies rather than applying an entry freshness filter to every queue.

“Last received wins” is insufficient when an old source event arrives late. Validate the source's sequence or event boundary and define a tie/conflict rule before assigning the current generation. Do not grant stale observations precedence solely because the network delivered them last.

The current-generation check also needs a shared ordering rule. Two workers can both read an old current value before either submits. A shared dispatcher should order replacement acceptance and final dispatch admission for that scope. Specify which wins when those operations compete, and retain the version observed by the winner. If a gateway queues the admitted request, enforce its deadline and applicable replacement rule there too. Document the final supersession cutoff: a database comparison alone is not atomic with an external exchange request.

This differs from trigger deduplication, which asks whether the same occurrence already has a run. Two unique occurrences can legitimately exist while the newer one supersedes the older entry. It also differs from workflow cancellation, which withdraws a run's permission and manages its remaining obligations.

Expiry cannot undo an attempted order

The final check belongs before the write attempt. If the request has already left the dispatcher, passing the local deadline does not prove rejection, cancellation or absence of fills. Keep the original action identity and use order timeout reconciliation if the outcome is unknown.

Distinguish an expired, never-attempted candidate from an attempted action awaiting recovery. Replaying an audit message about the latter should recover its status, not submit a replacement entry. Likewise, a completed analysis may be retained without being eligible to advance to execution.

If expiry occurs before any attempt, record a terminal skipped outcome and settle the queue delivery under the broker's supported procedure. Preserve the reason and timing in durable history. Repeatedly returning the same expired job to the active queue wastes capacity and obscures whether a later worker actually found new evidence.

Validate the deadline under deliberate delays

Use an isolated harness with a controllable clock and a recorded submission counter. The following acceptance cases test the lifecycle, rather than the speed of a quiet system:

Injected conditionExpected evidence
Job claimed exactly at expiryRejected; no ordinary analysis continuation
Analysis starts before expiry and finishes after itRetained result; zero entry submissions
Worker restarts or job is republishedOriginal deadline survives
A newer accepted generation arrives firstOlder candidate records supersession
An older source event arrives lastIt cannot win merely through arrival order
Submission was attempted before a crashRecovery inspects that action; no new entry attempt from expiry handling

For each case, retain source time, enqueue time, dequeue time, final gate time, current generation and outcome reason. Report expired-at-dequeue, expired-before-send, superseded and unresolved-attempt counts separately. Queue depth alone cannot explain why useful work was lost.

Start with one delayed candidate and prove that its deadline survives every handoff. Then prove that no queue redelivery, worker restart or newer approval can turn its skipped entry into permission to submit.

Keep the context with the example.

Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.