Skip to content

docs(live-trading): add order confirmation documentation#543

Open
Copilot wants to merge 5 commits intomainfrom
copilot/create-documentation-for-order-confirmation
Open

docs(live-trading): add order confirmation documentation#543
Copilot wants to merge 5 commits intomainfrom
copilot/create-documentation-for-order-confirmation

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Documents the planned order confirmation feature (ref #521) covering auto/manual confirmation modes, confirmation timeout, the OnConfirmOrder callback API, and integration patterns for both Go and Swift consumers.

Changes

  • New doc docs/live-trading/order-confirmation.md:

    • Configuration via LiveTradingEngineConfig.OrderConfirmation ("auto" / "manual") with Go and YAML examples
    • Confirmation timeout via confirmation_timeout (default 30s) — automatically rejects orders if the callback doesn't respond in time
    • Order placement flow diagrams for both modes (including timeout path)
    • Go API: OnConfirmOrderCallback in LiveTradingCallbacks
    • Swift API: OnConfirmOrder method on TradingEngineHelper
    • UI confirmation pattern using DispatchSemaphore for blocking the engine thread while awaiting user input
    • Edge cases: nil callback fallback, timeout behavior, interaction with OnOrderPlaced/OnOrderFilled
  • Updated docs/live-trading/index.md: added link to new doc in Related Documentation

Swift usage example

func onConfirmOrder(_ orderJSON: String) -> Bool {
    let semaphore = DispatchSemaphore(value: 0)
    var confirmed = false
    DispatchQueue.main.async {
        // Show UI confirmation dialog, then:
        confirmed = userResponse
        semaphore.signal()
    }
    semaphore.wait()
    return confirmed
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Create documentation for order confirmation configuration and API usage</issue_title>
<issue_description>Document the new configuration options for auto/manual order confirmation and the usage of the onConfirm callback in the Swift API.
This is part of the implementation for order confirmation support.

Reference: #521</issue_description>

<agent_instructions>write document on live trading confirmation.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 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

@autopilot-project-manager autopilot-project-manager bot added the documentation Improvements or additions to documentation label Feb 18, 2026
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
@autopilot-project-manager autopilot-project-manager bot added enhancement New feature or request go Pull requests that update go code labels Feb 18, 2026
Copilot AI and others added 2 commits February 18, 2026 17:16
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Copilot AI changed the title [WIP] Create documentation for order confirmation configuration and API usage docs(live-trading): add order confirmation documentation Feb 18, 2026
Copilot AI requested a review from sirily11 February 18, 2026 17:21
@sirily11 sirily11 marked this pull request as ready for review February 19, 2026 02:15
Copilot AI review requested due to automatic review settings February 19, 2026 02:15
Copy link
Collaborator

@sirily11 sirily11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix base on the comment and also remove *.pb, go.mod, and go.sum in your pr

Comment on lines +104 to +117
OnConfirmOrder(order)
┌───┴───┐
│ │
true false
│ │
▼ ▼
Trading Order
Provider rejected
(order (not sent to
executed) provider)
OnOrderPlaced callback
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot how to handle timeout? maybe we can add timeout configuration in the config so if confirmation timeout, reject the order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md describing 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

Comment on lines 1 to 5
// 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
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +40
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{
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +124 to +139
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
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +166 to +179
### 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
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

```go
onConfirm := engine.OnConfirmOrderCallback(func(order types.ExecuteOrder) bool {
fmt.Printf("Order pending: %s %s %.4f %s @ %.2f\n",
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
fmt.Printf("Order pending: %s %s %.4f %s @ %.2f\n",
fmt.Printf("Order pending: %s %.4f %s %s @ %.2f\n",

Copilot uses AI. Check for mistakes.
Comment on lines 50 to 54
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
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot fix base on the comment and also remove *.pb, go.mod, and go.sum in your pr

Reverted all *.pb.go, go.mod, and go.sum changes — the PR now only touches docs/live-trading/order-confirmation.md and docs/live-trading/index.md. Also added the timeout configuration per the review comment. See 572790d.

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request go Pull requests that update go code

Projects

None yet

3 participants