Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Market orders placed after limit order timeout were not being tracked, causing websocket updates to log warnings for "unknown orders" and preventing the UI from showing final fill status.

Changes

Modified order tracking logic (HyperliquidBroker.cs):

  • Removed IsCompleted() check from AddOrderTracker() to allow tracking already-filled orders
  • Added tracker registration for market orders created during timeout processing

Market orders fill immediately and have terminal status upon creation, but still receive websocket updates that need to be matched for UI updates and proper lifecycle management.

// Before: Skipped completed orders
if (!result.Success || result.Order == null || result.Order.IsCompleted())
    return;

// After: Track all successful orders including market orders
if (!result.Success || result.Order == null)
    return;
// In timeout processing, after placing market order
if (marketTradeResult.Success && marketTradeResult.Order != null)
{
    // Track the market order to handle websocket updates
    orderTrackers.TryAdd(orderId, new OrderTracker(...));
    updateChannel.Writer.TryWrite(new OrderUpdate(...));
}

This ensures websocket updates are matched to trackers, allowing the UI to display correct order status before exit.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix Log Warnings For Market Orders</issue_title>
<issue_description>Currently market orders are not tracked in the app, which has two consequences:

  1. we get a bunch of warnings in the logs (see below)
  2. the app exits without showing that the orders actually successfully filled (or not)

We should change this so that market orders are tracked and status updates returned to the client code in Program, so that the screen can be updated and the app shows the correct order status before exiting.

Log extract follows:

2025-11-12T09:30:07.0693674+00:00  [INF] ("ADA"): no action - delta is within trade buffer (current weight: -0.007, target weight: -0.024, delta: -0.017) (3b834db0)
2025-11-12T09:30:07.0697401+00:00  [INF] ("AVAX"): no action - delta is within trade buffer (current weight: 0.000, target weight: 0.035, delta: 0.035) (3b834db0)
2025-11-12T09:30:07.0697776+00:00  [INF] ("BNB"): no action - delta is within trade buffer (current weight: -0.008, target weight: 0.000, delta: 0.008) (3b834db0)
2025-11-12T09:30:07.0773976+00:00  [INF] ("BTC"): market positions... ["ProjectedPosition { Market = MarketInfo { Name = BTC, BaseAsset = BTC, QuoteAsset = USDC, AssetType = Future, TimeStamp = 12/11/2025 09:30:07, PriceStep = 1, QuantityStep = 0.00001, MinProvideSize = 0.00010, Ask = 104791.0, Bid = 104774.0, Last = , Mid = 104782.5, Expiry = , Key = BTC-Future, Spread = 17.0 }, Position = -0.0009, Nominal = 2350, Trades = , ProjectedWeight = -0.0401327234042553191489361702, HasPosition = True }"] (d0ba6b7e)
2025-11-12T09:30:07.0818444+00:00  [INF] ("BTC"): new "Trade { Symbol = BTC, AssetType = Future, Amount = -0.00030, LimitPrice = 104783, OrderType = Limit, PostPrice = True, Expiry = , ClientOrderId = , AbsoluteAmount = 0.00030, OrderSide = Sell }" (delta: -0.013) (2bdf2a95)
2025-11-12T09:30:07.0828178+00:00  [INF] ("DOGE"): no action - delta is within trade buffer (current weight: 0.000, target weight: 0.004, delta: 0.004) (3b834db0)
2025-11-12T09:30:07.0829391+00:00  [INF] ("ETH"): market positions... ["ProjectedPosition { Market = MarketInfo { Name = ETH, BaseAsset = ETH, QuoteAsset = USDC, AssetType = Future, TimeStamp = 12/11/2025 09:30:07, PriceStep = 0.1, QuantityStep = 0.0001, MinProvideSize = 0.0029, Ask = 3480.9, Bid = 3480.8, Last = , Mid = 3480.85, Expiry = , Key = ETH-Future, Spread = 0.1 }, Position = -0.0324, Nominal = 2350, Trades = , ProjectedWeight = -0.0479919829787234042553191489, HasPosition = True }"] (d0ba6b7e)
2025-11-12T09:30:07.0829688+00:00  [INF] ("ETH"): new "Trade { Symbol = ETH, AssetType = Future, Amount = -0.0249, LimitPrice = 3480.9, OrderType = Limit, PostPrice = True, Expiry = , ClientOrderId = , AbsoluteAmount = 0.0249, OrderSide = Sell }" (delta: -0.037) (2bdf2a95)
2025-11-12T09:30:07.0830227+00:00  [INF] ("LINK"): market positions... ["ProjectedPosition { Market = MarketInfo { Name = LINK, BaseAsset = LINK, QuoteAsset = USDC, AssetType = Future, TimeStamp = 12/11/2025 09:30:07, PriceStep = 0.001, QuantityStep = 0.1, MinProvideSize = 0.7, Ask = 15.713, Bid = 15.712, Last = , Mid = 15.7125, Expiry = , Key = LINK-Future, Spread = 0.001 }, Position = -4.6, Nominal = 2350, Trades = , ProjectedWeight = -0.0307573617021276595744680851, HasPosition = True }"] (d0ba6b7e)
2025-11-12T09:30:07.0830332+00:00  [INF] ("LINK"): new "Trade { Symbol = LINK, AssetType = Future, Amount = -0.2, LimitPrice = 15.712, OrderType = Market, PostPrice = False, Expiry = , ClientOrderId = , AbsoluteAmount = 0.2, OrderSide = Sell }" (delta: -0.001) (2bdf2a95)
2025-11-12T09:30:07.0864759+00:00  [INF] ("LINK"): no action - delta too small to trade (delta: -0.0011) (bec11ac4)
2025-11-12T09:30:07.0865340+00:00  [INF] ("SOL"): no action - delta is within trade buffer (current weight: -0.021, target weight: -0.045, delta: -0.024) (3b834db0)
2025-11-12T09:30:07.0865902+00:00  [INF] ("TRX"): market positions... ["ProjectedPosition { Market = MarketInfo { Name = TRX, BaseAsset = TRX, QuoteAsset = USDC, AssetType = Future, TimeStamp = 12/11/2025 09:30:07, PriceStep = 0.00001, QuantityStep = 1, MinProvideSize = 34, Ask = 0.2993, Bid = 0.29919, Last = , Mid = 0.299245, Expiry = , Key = TRX-Future, Spread = 0.00011 }, Position = 1190.0, Nominal = 2350, Trades = , ProjectedWeight = 0.1515047234042553191489361702, HasPosition = True }"] (d0ba6b7e)
2025-11-12T09:30:07.0866051+00:00  [INF] ("TRX"): new "Trade { Symbol = TRX, AssetType = Future, Amount = 219, LimitPrice = 0.29924, OrderType = Limit, PostPrice = True, Expiry = , ClientOrderId = , AbsoluteAmount = 219, OrderSide = Buy }" (delta: 0.028) (2bdf2a95)
2025-11-12T09:30:07.0866245+00:00  [INF] ("XRP"): no action - delta is within trade buffer (current weight: 0.027, target weight: 0.029, delta: 0.002) (3b834db0)
2025-11-12T09:30:07.0866527+00:00  [INF] ("TON"): market positions... ["ProjectedPosition { Market = MarketInfo { Name = TON, BaseAsset = TON, QuoteAsset = USDC,...

</details>

- Fixes moconnell/yolo#54

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

- Remove IsCompleted check in AddOrderTracker to track market orders even when filled
- Add market order tracking after timeout conversion from limit to market
- Market orders now tracked properly so websocket updates are matched
- UI will show correct order status for market orders before app exit

Co-authored-by: moconnell <640958+moconnell@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix log warnings for market orders Track market orders to prevent unknown order warnings and update UI Nov 12, 2025
Copilot AI requested a review from moconnell November 12, 2025 12:43
@moconnell moconnell marked this pull request as ready for review November 12, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants