Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 88ee2e2

Browse files
Updated to new API version
1 parent 65cebf9 commit 88ee2e2

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

‎Alpaca_examples.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
account = api.get_account()
1313
print(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? '''
1716
conn = 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
3635
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)
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?
6644
api.submit_order(symbol='TSLA',

‎requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
alpaca_trade_api==0.46
1+
alpaca_trade_api==0.51.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /