Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
// Response contains the cancellation status
log.Printf("✓ Limit order cancellation initiated:")
log.Printf(" Order name: %s", orderName)
log.Printf(" Status: %s", response.Status)
log.Printf(" State: %s", response.State)

// Monitor the order until cancellation is complete
log.Printf("\n📡 Monitoring order until cancellation is complete...")
Expand All @@ -58,13 +58,13 @@ monitorOrder:
log.Fatalf("Stream error: %v", err)
}

log.Printf(" Status: %s", update.Status)
log.Printf(" State: %s", update.State)

switch update.Status {
case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_CANCELLATION_IN_PROGRESS:
switch update.State {
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_CANCELLATION_IN_PROGRESS:
log.Printf(" ⏳ Order cancellation in progress...")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_CANCELLED:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_CANCELLED:
log.Printf(" ✓ Order successfully cancelled on ledger!")
break monitorOrder
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ monitorOrder:
log.Fatalf("Stream error: %v", err)
}

log.Printf(" Status: %s", update.Status)
log.Printf(" State: %s", update.State)

switch update.Status {
case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_SUBMISSION_IN_PROGRESS:
switch update.State {
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_SUBMISSION_IN_PROGRESS:
log.Printf(" ⏳ Order submission in progress...")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_SUBMISSION_FAILED:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_SUBMISSION_FAILED:
log.Fatalf(" ❌ Order submission failed")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_OPEN:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_OPEN:
log.Printf(" ✓ Order is now open on the ledger and available for matching!")
break monitorOrder
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
log.Printf(" Account: %s", limitOrder.Account)
log.Printf(" External reference: %s", limitOrder.ExternalReference)
log.Printf(" Side: %s", limitOrder.Side)
log.Printf(" Status: %s (UNSPECIFIED when live_ledger_data=false)", limitOrder.Status)
log.Printf(" State: %s (UNSPECIFIED when live_ledger_data=false)", limitOrder.State)

// Example 2: Get with live ledger data (queries the ledger for current status)
requestWithLiveData := &limit_orderv1.GetLimitOrderRequest{
Expand All @@ -54,7 +54,7 @@ func main() {

log.Printf("\n✓ Limit order retrieved (with live ledger data):")
log.Printf(" Resource name: %s", limitOrderWithStatus.Name)
log.Printf(" Status: %s", limitOrderWithStatus.Status)
log.Printf(" State: %s", limitOrderWithStatus.State)
log.Printf(" Limit price: %s %s", limitOrderWithStatus.LimitPrice.Value.Value, limitOrderWithStatus.LimitPrice.Token.Code)
log.Printf(" Quantity: %s %s", limitOrderWithStatus.Quantity.Value.Value, limitOrderWithStatus.Quantity.Token.Code)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ func main() {
log.Printf(" Side: %s", order.Side)
log.Printf(" Limit price: %s %s", order.LimitPrice.Value.Value, order.LimitPrice.Token.Code)
log.Printf(" Quantity: %s %s", order.Quantity.Value.Value, order.Quantity.Token.Code)
log.Printf(" Status: %s", order.Status)
log.Printf(" State: %s", order.State)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ monitorOrder:
}

// Process each order update as it arrives
log.Printf("\n📡 Status update received: %s", limitOrder.Status)
log.Printf("\n📡 State update received: %s", limitOrder.State)
log.Printf(" Resource name: %s", limitOrder.Name)
log.Printf(" Account: %s", limitOrder.Account)
log.Printf(" External ref: %s", limitOrder.ExternalReference)
Expand All @@ -69,34 +69,34 @@ monitorOrder:
log.Printf(" Quantity: %s %s", limitOrder.Quantity.Value.Value, limitOrder.Quantity.Token.Code)

// Handle order state transitions
switch limitOrder.Status {
case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_SUBMISSION_IN_PROGRESS:
switch limitOrder.State {
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_SUBMISSION_IN_PROGRESS:
log.Printf(" ⏳ Order submission in progress...")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_SUBMISSION_FAILED:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_SUBMISSION_FAILED:
log.Printf(" ❌ Order submission failed")
break monitorOrder

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_OPEN:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_OPEN:
log.Printf(" ✓ Order open on ledger and available for matching")
// Order is active - continue monitoring for fills

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_COMPLETE_IN_PROGRESS:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_COMPLETE_IN_PROGRESS:
log.Printf(" ⏳ Order completion in progress...")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_COMPLETE:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_COMPLETE:
log.Printf(" 🎉 Order completed (fully filled)!")
break monitorOrder

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_CANCELLATION_IN_PROGRESS:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_CANCELLATION_IN_PROGRESS:
log.Printf(" ⏳ Order cancellation in progress...")

case limit_orderv1.LimitOrderStatus_LIMIT_ORDER_STATUS_CANCELLED:
case limit_orderv1.LimitOrderState_LIMIT_ORDER_STATUS_CANCELLED:
log.Printf(" ❌ Order cancelled")
break monitorOrder

default:
log.Printf(" ⚠️ Unexpected order status: %v", limitOrder.Status)
log.Printf(" ⚠️ Unexpected order state: %v", limitOrder.State)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
log.Printf(" Account: %s", order.Account)
log.Printf(" External ref: %s", order.ExternalReference)
log.Printf(" Side: %s", order.Side)
log.Printf(" Status: %s", order.Status)
log.Printf(" State: %s", order.State)
log.Printf(" Limit price: %s %s", order.LimitPrice.Value.Value, order.LimitPrice.Token.Code)
log.Printf(" Quantity: %s %s", order.Quantity.Value.Value, order.Quantity.Token.Code)
}
Expand Down
74 changes: 36 additions & 38 deletions go/trading/limit_order/v1/limit_order.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions go/trading/limit_order/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions proto/meshtrade/trading/limit_order/v1/limit_order.proto
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ message LimitOrder {
meshtrade.type.v1.Amount filled_quantity = 11;

/*
Order status from live ledger data.
Only populated when live_ledger_data=true in request.
Limit Order life cycle state.
*/
LimitOrderStatus status = 12;
LimitOrderState state = 12;
}

/*
Expand All @@ -152,10 +151,9 @@ enum LimitOrderSide {
}

/*
LimitOrderStatus represents the current state of a limit order.
Populated only when live_ledger_data=true in requests.
LimitOrderState represents the current life-cycle state of a limit order.
*/
enum LimitOrderStatus {
enum LimitOrderState {
// Unspecified status.
LIMIT_ORDER_STATUS_UNSPECIFIED = 0;

Expand Down
9 changes: 9 additions & 0 deletions proto/meshtrade/trading/limit_order/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,13 @@ message MonitorLimitOrderRequest {
*/
string external_reference = 2;
}

/*
When true, fetches live ledger data for order.
When false, returns only stored metadata.
Note: The streaming does not stream based on ledger events such as fill amount changes,
only limit order state changes triggers a stream update. If this is set to true
then live ledger data will populated with the updated limit order state.
*/
bool live_ledger_data = 3;
}
Loading