Skip to main content

Data Model: YU08; Execution Algo Engine

In-memory model (rebuilt from the JetStream event log, research.md Decision 4)​

ParentOrder​

FieldTypeNotes
parentOrderIdUUID stringGenerated on creation; the correlation id for every child/event.
accountIdIntegerSame field shape as OrderCreateRequest.accountId.
securityStringTicker.
sideBuy/SellSame enum as order-matcher's OrderSide.
quantityIntegerTotal parent quantity.
algoTypeTWAP/VWAPSelects the bucket-weighting strategy.
durationSecondsIntegerTotal schedule window.
bucketSecondsIntegerPer-bucket duration; default 10.
statusRUNNING/COMPLETEDCOMPLETED once every bucket is submitted and filled.
createdAtInstant
bucketsList<Bucket>Ordered by index.

Bucket​

FieldTypeNotes
indexint0-based position in the schedule.
startEpochMslongWhen this bucket becomes due for submission.
targetQuantityintFrom TWAP's equal split or VWAP's weighted split.
childOrderIdString, nullableorder-matcher's orderId, set once submitted.
clientOrderIdString<parentOrderId>:<index>; sent on the child request, not read back.
limitPriceBigDecimal, nullableSet at submission time (last price Β± 10bps).
submittedAtInstant, nullable
remainingQuantityInteger, nullableLast value observed from /accounts/*/orders.
lastExecutionPriceBigDecimal, nullableLast value observed from /accounts/*/orders.
filledbooleantrue once remainingQuantity reaches 0.

JetStream event log (TRADERX_ALGO_ENGINE stream, subject algo.events.>)​

One JSON message per event, in the order applied. Every message carries a type discriminator.

typePayload fieldsApplied as
ParentOrderCreatedparentOrderId, accountId, security, side, quantity, algoType, durationSeconds, bucketSeconds, buckets:[{index,startEpochMs,targetQuantity}], createdAtInserts a new ParentOrder (status RUNNING).
ChildOrderSubmittedparentOrderId, bucketIndex, childOrderId, clientOrderId, limitPrice, submittedAtSets the named bucket's submission fields.
ChildOrderFillObservedparentOrderId, bucketIndex, remainingQuantity, lastExecutionPrice, observedAtUpdates the named bucket's fill fields; sets filled=true when remainingQuantity=0.
ParentOrderCompletedparentOrderId, completedAtSets ParentOrder.status=COMPLETED.

Config (namespace algo.*, environment variables)​

KeyDefaultMeaning
ALGO_ENGINE_PORT18120HTTP port.
NATS_ADDRESSnats://nats-broker:4222Broker connection for JetStream events and the /accounts/*/orders subscription.
ORDER_MATCHER_URLhttp://order-matcher:18110Child-order submission target (POST /orders).
PRICE_SERVICE_URLhttp://price-publisher:18100Reference price for child limit-price derivation.
ALGO_BUCKET_SECONDS_DEFAULT10Default bucketSeconds when a parent-order request omits it.
ALGO_LIMIT_OFFSET_BPS10Aggressive offset applied to the reference price, in basis points.
ALGO_VOLUME_PROFILE_SOURCEsyntheticsynthetic or duckdb (VWAP only; TWAP ignores this).
ALGO_VOLUME_PROFILE_DUCKDB_PATHgs://traderx-501015-tick-store/ticksParquet root queried by DuckDbVolumeProfileSource; only read when the source above is duckdb.

Reused, unchanged​

  • order-matcher's POST /orders (OrderCreateRequest/OrderResponse); no schema change.
  • price-publisher's GET /prices/{ticker}.
  • /accounts/<accountId>/orders NATS subject; no publisher change, one new subscriber.
  • NATS broker (nats-broker); same connection every other JVM service uses.