Retrieving pre-market quote

I have typed in “premarket” and “pre-market” in the search box but I just wasn’t able to find any directions on how to obtain a premarket quote on, say “AAPL”, at 9:20am Eastern time. I have had great success so far with scalping on the open ( as much as a small investor can I suppose ) and I have almost my entire process automated in Python3 except for this part.
If I wanted a quote on AAPL ( or any other stock ) at 9:20am Eastern time ( for example ) is that a current quote or a specific API reference to “pre-market” ? So many thanks folks. I have tried every API and Alpaca is truly wonderful

1 Like

have you looked in the docs?

1 Like

Yes. That’s how I got the other aspects coded without a problem ( entry, trailing, etc )… I’m going to test just requesting the bar data before 930a and verify it against another resource. It’s quite possibly just the last quoted price in that case. If I solve it I’ll update this question for others that may have this same question.

OK, the digging continues. At 9:15a, the pre-market on PLTR is 24.60 . When I get the latest quote using the code below I get… If I find an answer to this I will post it for future posterity. ( FYI: not on the premium plan but that’s my next step )

python3 get_last_quote
Quote({   'askexchange': 15,
    'askprice': 25,
    'asksize': 1,
    'bidexchange': 15,
    'bidprice': 23.9,
    'bidsize': 1,
    'timestamp': 1615986783532253365})




#API endpoint URL
url = "https://paper-api.alpaca.markets"

#api_version v2 refers to the version that we'll use
#very important for the documentation
api = tradeapi.REST(key, sec, url, api_version='v2')

positions = api.get_last_quote("PLTR")
print(positions)

OK folks ( again just trying to solve this problem in case someone else has this question in the future )…

I was thinking that retrieving the one minute bars may yield a pre-market result but grepping the epoch seconds settings shows a jump from 4p/EDT to 935a/EDT ( line numbers at the beginning are a grep -n artifact ) when grabbing bar data shortly after the open using aapl = api.get_barset(‘AAPL’, ‘1Min’, limit=30)

70:    't': 1615924740,
75:    't': 1615987800

Hey, I’m also trying to figure this out. Hrm.

1 Like

It only occurred to me after that since I also have an Interactive Brokers account that I can very easily get the pre-market gainers/losers very easily from their market scanner. In the meantime I also wrote some python code that would scrape Yahoo Finance pages like if you wanted a list of most actives and wanted to parse out those stocks or wanted to scrape a particular stock. I am more than happy to post that somewhere and just give it away.

get_bars support a time period, my way to quote pre market data is to set start_time=8:30 and end_time = 9:29.