Repository navigation
Return requested orders over TCP/JSON (#711) - #712
Conversation
A worker answers each group with zero or more strategy.Order requests: an instrument, action, direction, type and decimal-string prices. The root adapter maps each onto the trader's own order and validates every one before any is processed, so the existing handleOrder, account sizing and broker path decide what happens. Replies decode strictly, so units, id, state and any other field the worker may not set fail the run. The example worker opens then closes a long. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Reviewed #712 ( I would address two correctness details before merging:
Otherwise the scope is right. I haven't independently executed |
…st (#711) An order for an instrument with no bar in the group takes the time the group became available instead of another instrument's opening time. An answer without an orders list, or with null, is an error; [] stays valid. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Addressed both items in eab2569 (not merged).
|
|
Re-reviewed updated commit
The overall mapping still uses one public request DTO and Trader's existing order validation, Account sizing and Broker lifecycle, with in-process/remote parity tests. No further blocking findings in this review; I recommend merging #712 provided CI/checks pass. Good focused increment—keep registration, feedback and journaling for later issues. |
Closes #711. Part of #690. Follows the plan posted on #711 and the owner's clarification there (no instrument-membership check).
What
A worker can now answer each group of bars with zero or more requested orders. Trader maps them onto its own
orderand runs them through the existinghandleOrder→order.validate→ account sizing → broker path. There is no second order lifecycle.Public type mapping (the narrow boundary)
strategycannot importtrader, andorderis unexported, so there is one transport DTO in the public package:strategy.Order. It is a request, not a lifecycle model, and no domain types are exposed.instrumentorder.instrumentaction(open,add,close,reduce)order.action(amendis refused)direction(long,short; open only)order.directiontype(marketby default,limit,stop)order.orderTypeprice,stop_loss,take_profit(decimal strings,num.Price)price,stopLoss,takeProfitDisallowUnknownFields), so any such field, or any unknown one, fails the run with an explicit error.Time(the delivered bar of that instrument if the group has one, else the group's first bar),decidedAt,accountID, id, units and state, in the existing code.strategy_remote.govalidates every requested order (order.validate, the same rules as in-process) before returning any, so one bad order fails the callback and none of the group is processed. An open without a stop fails there.Changes
strategy/strategy.go:Order; the answer holds[]Order.strategy/frame.go: strict decoding (the 16 MiB cap stays).strategy/client.go:Client.OnBarsreturns([]Order, error).strategy/server.go:Serve/ListenAndServecallbacks return orders; deadline, cancel and loopback behaviour are unchanged.strategy_remote.go:toOrders/toOrderandparseAction/parseDirection/parseOrderType.examples/remote-strategy: a tiny deterministic rule. It opens a long on the 3rd group with a stop 0.015 below the close and closes on the 6th.Tests
strategy: wire form ofOrder; orders arrive in order with exact prices; zero orders is[], never null; a field the worker may not send (units,id,state,account,fill_price, unknown) is an error; malformed answers are errors;Servecarries orders; the existing deadline, cancel and loopback tests still pass.amend, unknown action/direction/type, no time); times by instrument; an instrument outside the group is accepted; a bad second order returns none.a-reversal-exitfixture: the same rule in-process and over TCP gives identical orders, sizes, fills, lifecycle, balance and trades (open filled, close filled, the broker's stop cancelled). The real example binary, run as a separate process, matches too. Bad orders (no stop,amend, a bad order after a good one) fail the run, and nothing of that group reaches the broker, the account orrejected.make checkpasses; the EMAX md5 is unchanged (195e457a…).Deferred
trail / expires / amend, registration and RunID, a Trader-side listener, broker feedback (#698), journal (#702), REST (#700), auth/TLS, binary transport.
🤖 Generated with Claude Code