I just started with Alpaca and have a couple of basic questions. I saved this code in a file and ran the file from command prompt (on Windows). It opens and runs the process in a new shell. In case of an error, it disappears before I can read it. How can I force it to not open a new shell?
Secondly, how do I get it to save the 1 min candles? I tried both get_bars() and get_barset() it saved an empty file.
#import the alpaca api
import alpaca_trade_api as tradeapi
#authentication and connection details
api_key = ‘my key’
api_secret = ‘my secret’
base_url = ‘https://paper-api.alpaca.markets’
#instantiate REST API
api = tradeapi.REST(api_key, api_secret, base_url, api_version=‘v2’)
#obtain account information
account = api.get_account()
#get last few tsla bars ‘minute’ bars
tsla = api.get_bars(‘TSLA’, ‘1Min’, limit=20)
#tsla = api.get_barset(‘TSLA’, ‘1Min’, limit=20)