Skip to content

The OpenFeed .NET SDK incorrectly sets the trading status #3

@TradeForgeFR

Description

@TradeForgeFR

Good day team, please find here a description of an issue that I face actually.
I hope it will hekp you to improve this library.

Problem Description

The OpenFeed .NET SDK incorrectly sets the trading status of the symbol AAPL to Open when it should be PreOpen at 9:00 AM UTC.

This misrepresentation affects the logic that processes market data snapshots, potentially leading to inaccurate charting or system behavior before the true market open.

Reproduction Steps and Code Snippets

The following code demonstrates the subscription and the message handling logic where the issue is observed:

Step 1: Subscribe to AAPL.BZ

The following code subscribes to the real-time snapshot for the symbol AAPL.BZ.

var subscriptionId = _client.Subscribe(Service.RealTimeSnapshot, SubscriptionType.Quote, 1, new[] { "AAPL.BZ" }, null);

Step 2: Handle Message and Check Trading Status

The OnMessage handler processes incoming messages, including the MarketSnapshot, where the TradingStatus is checked.


        switch(data.DataCase)
        {
            // save instrument definition into a local dictionnary
            case OpenfeedGatewayMessage.DataOneofCase.InstrumentDefinition:
            
                string symbol = data.InstrumentDefinition.SubscriptionSymbol;
                long id = data.InstrumentDefinition.MarketId;
                long priceDenominator = data.InstrumentDefinition.PriceDenominator;

                if (!_marketIdToSymbolMap.ContainsKey(id))
                {
                    _marketIdToSymbolMap.Add(id, (symbol, priceDenominator));
                }
                break;

            // Handle market snapshot 
            case OpenfeedGatewayMessage.DataOneofCase.MarketSnapshot:
                var snapshot = data.MarketSnapshot;
                var tradingStatus = snapshot.InstrumentStatus.TradingStatus;
                
                // ISSUE OBSERVED HERE: tradingStatus is 'Open' at 9:00 AM UTC instead of 'PreOpen'
                if(snapshot.Last == null || tradingStatus != InstrumentTradingStatus.Open)
                    break;
                
                if (_marketIdToSymbolMap.TryGetValue(snapshot.MarketId, out (string, long) symbolInfos))
                {
                    double price = (double)snapshot.Last.Price / (double)symbolInfos.Item2; // Convert to actual price
                    var time = TimestampConverter.ConvertNanosecondsToDateTimeOffset(snapshot.Last.TransactionTime);
                   // ... other part ...
                }
                break;

            // ... other cases ...
        }
    };

Expected Behavior

At 9:00 AM UTC, the tradingStatus for AAPL.BZ should be reported as InstrumentTradingStatus.PreOpen.

The current logic, which filters based on tradingStatus != InstrumentTradingStatus.Open, prevents market data from being processed correctly during the pre-market session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions