Skip to content
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