Closed windowshopr closed 4 years ago
Hey,
Just wondering why I'm getting a 404 response when trying to request the "last quote" for AAPL. Is it not accessible on the weekend, or is there something wrong with my syntax? I'm using paper trading. My code looks like this:
base_url = "https://paper-api.alpaca.markets" quotes_url = "{}/v1/last_quote/stocks/".format(base_url) # ticker defined later api_key = "API_GOES_HERE" secret_key = "SECRET_KEY_GOES_HERE" headers = {"APCA-API-KEY-ID": api_key, "APCA-API-SECRET-KEY": secret_key} def get_latest_bid_ask_prices(ticker): r = requests.get(quotes_url + str(ticker), headers=headers) results = json.loads(r.content) print(results['askprice']) print(results['bidprice']) return get_latest_bid_ask_prices("AAPL")
404 means the ticker is unavailable? Thanks!
Nevermind, I was using the wrong baseurl. Baseurl should have read:
quotes_base_url = "https://data.alpaca.markets/v1"
Hey,
Just wondering why I'm getting a 404 response when trying to request the "last quote" for AAPL. Is it not accessible on the weekend, or is there something wrong with my syntax? I'm using paper trading. My code looks like this:
404 means the ticker is unavailable? Thanks!