Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Update v2_example.py to add paper credentials instruction comment#391

Open
nickjohnson22 wants to merge 1 commit into
alpacahq:masterfrom
nickjohnson22:websockets-v2-paper-comment
Open

Update v2_example.py to add paper credentials instruction comment#391
nickjohnson22 wants to merge 1 commit into
alpacahq:masterfrom
nickjohnson22:websockets-v2-paper-comment

Conversation

@nickjohnson22

Copy link
Copy Markdown

This stumped me for a while. Hopefully, the comment helps others who want to test with their paper credentials.

from alpaca_trade_api.stream import Stream

# Uncomment URL import to test with paper credentials
# from alpaca_trade_api.common import URL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this import, you can simply use a string for base_url

feed = 'iex' # <- replace to SIP if you have PRO subscription
stream = Stream(data_feed=feed, raw_data=True)

stream = Stream(data_feed=feed, raw_data=True) # <- add base_url=URL('https://paper-api.alpaca.markets') for paper

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would wrap it like this:

Suggested change
stream = Stream(data_feed=feed, raw_data=True) # <- add base_url=URL('https://paper-api.alpaca.markets') for paper
stream = Stream(
data_feed=feed,
# base_url='https://paper-api.alpaca.markets', # uncomment for paper
raw_data=True)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants