Skip to content

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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/websockets/v2_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from alpaca_trade_api.stream import Stream

# Uncomment URL import to test with paper credentials
# from alpaca_trade_api.common import URL
Copy link
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


log = logging.getLogger(__name__)


Expand All @@ -20,7 +23,8 @@ async def print_trade_update(tu):
def main():
logging.basicConfig(level=logging.INFO)
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
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)

stream.subscribe_trade_updates(print_trade_update)
stream.subscribe_trades(print_trade, 'AAPL')
stream.subscribe_quotes(print_quote, 'IBM')
Expand Down