Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: stockdatastream with SIP feed is providing incomplete data #458

Open
2 tasks done
julianito20 opened this issue May 21, 2024 · 2 comments
Open
2 tasks done

Comments

@julianito20
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I subscribe to trades for a large number of symbols on the streaming API (StockDataStream) using the SIP feed. I don't have any visible failures but there are full minutes where no data is received even though trading volumes are high. Example PACB delivered 20+ trades during minute 9:30 EST on May 20th 2024 but no trades during minutes 9:31 and 9:32. I am not sure if this is a problem with the feed or with the client failing silently when the async function is called.

Expected Behavior

I should receive trades during every minute or a failure to process should be logged

SDK Version I encountered this issue in

alpaca-py version v0.21.1

Steps To Reproduce

1.Subscribe to 200+ trades
2. Save a record of each trade received aggregating by minute
3. Check that there are trades being recorded every minute. 

Example script:


data_stream = StockDataStream(apikey, token, feed=DataFeed.SIP)

async def bar_callback(bar):

    
    # Get the current time rounded down to the nearest minute
    minute_rounded = bar.timestamp.replace(second=0, microsecond=0)

    # Construct the Redis key using the symbol and the current minute
    key = f"{bar.symbol}:{minute_rounded.strftime('%Y-%m-%d %H:%M')}"

    # Use the timestamp as the score in the sorted set
    # timestamp_score = now.timestamp()

    # Add the timestamp and price to the sorted set, using the price as the score as timestamps must be unique
    r.zadd(key, {bar.timestamp.timestamp():bar.price})
    
keys = ['PACB','ZTO',..., '200th symbol']


logging.basicConfig(format='%(asctime)s  %(levelname)s %(message)s',
                    level=logging.INFO)

symbol = keys

data_stream.subscribe_trades(bar_callback, *symbol)


data_stream.run()

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

No response

@gnvk
Copy link
Contributor

gnvk commented May 24, 2024

@julianito20 Could you please send me your account ID so that I can check the server logs?

@chazzmoney
Copy link

Has there been any follow up on this? Verification that it is or is not a bug?

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

No branches or pull requests

3 participants