12
12
account = api .get_account ()
13
13
print (account )
14
14
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? '''
17
16
conn = tradeapi .stream2 .StreamConn (api_key , api_secret , base_url )
18
17
19
18
@conn .on (r'^account_updates$' )
@@ -34,33 +33,12 @@ def ws_start():
34
33
'''Data Examples - How do I get historical data from the Alpaca API?
35
34
36
35
aapl = 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)
44
39
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)
51
40
'''
52
41
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
- '''
64
42
65
43
''' How do I set a stop loss or take profit?
66
44
api.submit_order(symbol='TSLA',
0 commit comments