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]: #411

Open
2 tasks done
kenchambers opened this issue Feb 12, 2024 · 1 comment
Open
2 tasks done

[Bug]: #411

kenchambers opened this issue Feb 12, 2024 · 1 comment

Comments

@kenchambers
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I don't seem to be able to get the stream to work. i am correctly instantiating DataStreamClient with valid keys from live import.

from dotenv import dotenv_values

from alpaca.data.enums import DataFeed
from alpaca.data.live import StockDataStream



# Load environment variables from .env file
config = dotenv_values(".env")

API_KEY = config['APCA_API_KEY_ID']
SECRET_KEY = config['APCA_API_SECRET_KEY']

# Instantiate the StockDataStream
stream = StockDataStream(
    api_key=API_KEY,
    secret_key=SECRET_KEY,
    feed=DataFeed.IEX,  # or DataFeed.SIP if you have access
)

print(stream)

# Define your callback function to handle incoming data
async def handle_bar(bar):
    # Process the bar data (this is just a placeholder, adjust according to your data structure)
    print(bar)

# Subscribe to live updates for a symbol, e.g., "AAPL"
stream.subscribe_bars(handle_bar, "AAPL")

# Start streaming
stream.run()

Expected Behavior

Expecting candles to come through, but only seeing:

<alpaca.data.live.stock.StockDataStream object at 0x11939f0b0> which is the print from instantiating client.

SDK Version I encountered this issue in

Name: alpaca-trade-api
Version: 3.2.0
Summary: Alpaca API python client
Home-page: https://github.com/alpacahq/alpaca-trade-api-python
Author: Alpaca

Steps To Reproduce

1. follow code example provided above

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?

thats it.

@hiohiohio
Copy link
Contributor

@kenchambers could you please try this again when market is open when you have a chance?

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

2 participants