docs(live-trading): add order confirmation documentation#543
docs(live-trading): add order confirmation documentation#543
Conversation
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
| OnConfirmOrder(order) | ||
| │ | ||
| ┌───┴───┐ | ||
| │ │ | ||
| true false | ||
| │ │ | ||
| ▼ ▼ | ||
| Trading Order | ||
| Provider rejected | ||
| (order (not sent to | ||
| executed) provider) | ||
| │ | ||
| ▼ | ||
| OnOrderPlaced callback |
There was a problem hiding this comment.
@copilot how to handle timeout? maybe we can add timeout configuration in the config so if confirmation timeout, reject the order
There was a problem hiding this comment.
Added confirmation_timeout configuration (default 30s) — if the callback doesn't respond within the timeout, the order is automatically rejected. Updated the config table, flow diagram (now shows timeout path), Go/YAML examples, and added a dedicated "Confirmation Timeout" section in Behavior Details. See 572790d.
There was a problem hiding this comment.
Pull request overview
Adds live-trading documentation describing an order-confirmation workflow (auto vs manual) and intended callback APIs for Go/Swift consumers, and links it from the live-trading docs index. The PR also includes some unrelated Go module + generated-code churn.
Changes:
- Add new doc:
docs/live-trading/order-confirmation.mddescribing configuration, flows, and callback usage patterns. - Link the new doc from
docs/live-trading/index.md. - Remove an indirect Go dependency (
golang.org/x/mobile) and update generated protobuf header version comments.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/strategy/strategy_vtproto.pb.go | Generated header/version comment updates |
| pkg/strategy/strategy_plugin.pb.go | Generated header/version comment updates |
| pkg/strategy/strategy_options.pb.go | Generated header/version comment updates |
| pkg/strategy/strategy_host.pb.go | Generated header/version comment updates |
| pkg/strategy/strategy.pb.go | Generated header/version comment updates |
| go.sum | Removes sums related to golang.org/x/mobile |
| go.mod | Removes indirect golang.org/x/mobile requirement |
| docs/live-trading/order-confirmation.md | New order-confirmation documentation (config, flows, Go/Swift API examples) |
| docs/live-trading/index.md | Adds related-doc link to Order Confirmation page |
| // Code generated by protoc-gen-go-plugin. DO NOT EDIT. | ||
| // versions: | ||
| // protoc-gen-go-plugin v0.1.0 | ||
| // protoc v6.33.1 | ||
| // protoc-gen-go-plugin 0.9.0 | ||
| // protoc v3.21.12 | ||
| // source: strategy.proto |
There was a problem hiding this comment.
This docs-focused PR also updates generated protobuf headers/tooling version comments. If these files weren’t intentionally regenerated, consider reverting these changes to keep the PR focused. If they were regenerated, it would help to note what tooling/version change prompted it (and ensure CI uses the same generator).
| Order confirmation is configured via the `LiveTradingEngineConfig` struct. The `OrderConfirmation` field controls the confirmation behavior. | ||
|
|
||
| ### Configuration Options | ||
|
|
||
| | Field | Type | Default | Description | | ||
| |-------|------|---------|-------------| | ||
| | `order_confirmation` | `OrderConfirmationMode` | `"auto"` | `"auto"` to auto-confirm, `"manual"` to require callback confirmation | | ||
|
|
||
| ### Go Configuration | ||
|
|
||
| ```go | ||
| config := engine.LiveTradingEngineConfig{ | ||
| MarketDataCacheSize: 1000, | ||
| EnableLogging: true, | ||
| OrderConfirmation: engine.OrderConfirmationManual, // require manual confirmation | ||
| Prefetch: engine.PrefetchConfig{ |
There was a problem hiding this comment.
The doc describes LiveTradingEngineConfig.OrderConfirmation / order_confirmation and OrderConfirmationMode constants, but the current internal/trading/engine/engine.go LiveTradingEngineConfig only has MarketDataCacheSize, EnableLogging, and Prefetch (no order-confirmation field). Please either update the documentation to match the current implementation, or explicitly label this section as “planned / not yet implemented” and avoid referencing non-existent types/constants until the feature lands.
| The `OnConfirmOrder` callback is part of the `LiveTradingCallbacks` struct: | ||
|
|
||
| ```go | ||
| // OnConfirmOrderCallback is called when an order requires confirmation. | ||
| // Return true to confirm (place the order), or false to reject it. | ||
| type OnConfirmOrderCallback func(order types.ExecuteOrder) bool | ||
|
|
||
| type LiveTradingCallbacks struct { | ||
| // ... existing callbacks ... | ||
|
|
||
| // OnConfirmOrder is called when the engine is in manual confirmation mode | ||
| // and a strategy wants to place an order. | ||
| // Return true to confirm the order, false to reject it. | ||
| // If nil and mode is "manual", the order is auto-confirmed. | ||
| OnConfirmOrder *OnConfirmOrderCallback | ||
| } |
There was a problem hiding this comment.
This callback API (OnConfirmOrderCallback and LiveTradingCallbacks.OnConfirmOrder) does not exist in the current engine callbacks struct. internal/trading/engine/engine.go defines LiveTradingCallbacks without an OnConfirmOrder field. Please align this section with the actual callback surface (or clearly mark it as future behavior).
| ### Swift API | ||
|
|
||
| In the Swift API, the `TradingEngineHelper` interface includes an `OnConfirmOrder` method: | ||
|
|
||
| ```go | ||
| // TradingEngineHelper is the callback interface for live trading lifecycle events. | ||
| type TradingEngineHelper interface { | ||
| // ... existing methods ... | ||
|
|
||
| // OnConfirmOrder is called when manual confirmation is enabled and a strategy | ||
| // wants to place an order. Return true to confirm, false to reject. | ||
| // orderJSON is the JSON representation of the ExecuteOrder. | ||
| OnConfirmOrder(orderJSON string) bool | ||
| } |
There was a problem hiding this comment.
The doc states Swift consumers can implement OnConfirmOrder(orderJSON string) bool on TradingEngineHelper, but the current Swift bridge interface in pkg/swift-argo/trading.go does not define any OnConfirmOrder method. Please update this to match the existing Swift API, or mark it as planned and point to the tracking issue/PR for when the Swift callback is introduced.
|
|
||
| ```go | ||
| onConfirm := engine.OnConfirmOrderCallback(func(order types.ExecuteOrder) bool { | ||
| fmt.Printf("Order pending: %s %s %.4f %s @ %.2f\n", |
There was a problem hiding this comment.
The fmt.Printf format string and arguments don’t match here: %s is used with order.Quantity (float64) and %.4f appears to be paired with order.Symbol (string). Please fix the placeholders and/or reorder the arguments so the example compiles and prints the intended fields.
| fmt.Printf("Order pending: %s %s %.4f %s @ %.2f\n", | |
| fmt.Printf("Order pending: %s %.4f %s %s @ %.2f\n", |
| github.com/muesli/termenv v0.16.0 // indirect | ||
| github.com/sahilm/fuzzy v0.1.1 // indirect | ||
| github.com/stretchr/objx v0.5.2 // indirect | ||
| github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect | ||
| golang.org/x/mobile v0.0.0-20260217195705-b56b3793a9c4 // indirect | ||
| gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect |
There was a problem hiding this comment.
This PR is scoped as documentation, but it also changes module dependencies (removes golang.org/x/mobile). If this is intentional, please call it out in the PR description (including why it’s safe), or split/revert it so the docs change can be reviewed and released independently.
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Reverted all |
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Documents the planned order confirmation feature (ref #521) covering auto/manual confirmation modes, confirmation timeout, the
OnConfirmOrdercallback API, and integration patterns for both Go and Swift consumers.Changes
New doc
docs/live-trading/order-confirmation.md:LiveTradingEngineConfig.OrderConfirmation("auto"/"manual") with Go and YAML examplesconfirmation_timeout(default30s) — automatically rejects orders if the callback doesn't respond in timeOnConfirmOrderCallbackinLiveTradingCallbacksOnConfirmOrdermethod onTradingEngineHelperDispatchSemaphorefor blocking the engine thread while awaiting user inputOnOrderPlaced/OnOrderFilledUpdated
docs/live-trading/index.md: added link to new doc in Related DocumentationSwift usage example
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Linked Issues:
Closes #522
Closes #523
Closes #524