1212account = api .get_account ()
1313print (account )
1414
15-
16- #init websocket - How do I use WebSockets to stream data with the Alpaca API?
15+ '''init websocket - How do I use WebSockets to stream data with the Alpaca API? '''
1716conn = tradeapi .stream2 .StreamConn (api_key , api_secret , base_url )
1817
1918@conn .on (r'^account_updates$' )
@@ -34,33 +33,12 @@ def ws_start():
3433'''Data Examples - How do I get historical data from the Alpaca API?
3534
3635aapl = api.polygon.historic_agg_v2('AAPL', 1, 'day', _from='2019-01-01', to='2019-02-01').df
37- aapl = api.alpha_vantage.historic_quotes('AAPL', adjusted=True, output_format='pandas')
38- tsla = api.alpha_vantage.historic_quotes('TSLA', adjusted=True, output_format='json', cadence='weekly')
39- tsla = api.alpha_vantage.intraday_quotes ('TSLA', interval='5min', output_format='csv')
40- '''
41-
42-
43- ''' How can I use indicators with the Alpaca API?
36+ aapl = api.get_barset('AAPL', 'day')
37+ tsla = api.get_barset('TSLA', '15Min')
38+ aapl = api.get_barset('AAPL', 'day', limit=1000)
4439
45- #sma = api.alpha_vantage.techindicators(symbol='AAPL', interval='weekly', time_period='10', series_type='close')
46-
47- #rsi = api.alpha_vantage.techindicators(techindicator='RSI', symbol='AAPL', interval='weekly', time_period='14', series_type='close')
48-
49- print(sma)
50- print(rsi)
5140'''
5241
53- ''' How can I fire order in the Alpaca API?
54-
55- api.submit_order(symbol='TSLA',
56- qty=1,
57- side='buy',
58- time_in_force='gtc',
59- type='limit',
60- limit_price=400.00,
61- client_order_id='001'
62- )
63- '''
6442
6543''' How do I set a stop loss or take profit?
6644api.submit_order(symbol='TSLA',
0 commit comments