Historic Tick by tick data

Hi guy,

I am looking for a script that can download all the ticks for some symbol.
I an not interested in candle sticks, rather than the entire tick data. In python.

I couldn’t find an example for this anywhere.

Thanks you
Erez

Hi Erez,
to get tick data you have to options ( depends on your account type)
if you have a funded account, you can use the polygon API (https://polygon.io/docs/#get_v2_ticks_stocks_nbbo__ticker___date__anchor)

if you don’t have a funded account, you can’t get historic quotes. what you can do is start a streamer and start receiving tick data from now and then store them locally. you can do it with the free alpaca data service (check this readme to learn how: https://github.com/alpacahq/alpaca-trade-api-python)

Hi Shlomi,
Thanks for your answer.
But I am not sure still how this can be done - can you direct me to some example?

which solution do you want?
each has a different approach (the first solution, you need a paid account)

I have a paid account

so you could do this:

api = tradeapi.REST(key_id=ALPACA_API_KEY,
                    secret_key=ALPACA_SECRET_KEY)
quotes = api.polygon.historic_quotes_v2("AAPL", "2020-08-05")

Is there a way to specify the time - minute/seconds for which it will start the data grab from? for eaxmple ‘2020-08-05 09:46:28’ I would like my data to begin at 9:46 but it always starts at 4 am

I am not 100%, but I believe epoch time in nanoseconds might work (something like ‘15477876089991258’) in the date field.

when I grab tick trade data, from polygon. I can get the 50k ticks but that ends at 10-11 am and I need the next 50k ticks until there is nothing left or end of day! does anyone know how i can do that?

‘?timestamp={startTime1}&timestampLimit={endTime1}’

The above string shows a segment of the API URL you will need to use. Both startTime1 and endTime1 are in epoch (nanosecond)

Create a while loop where results = 50000. At the tail end of this while loop, adjust your startTime1 to be the last results’ timestamp - do a request again.

When you’re out of the above loop, you know you are in your last ‘batch’ of results.

Hope that helps.

1 Like

lol, I cam here for a quick dirty way to pick and chose the data I want out of the JSON format. Looks Like I have to do some work!

You can use the new Alpaca historical data API, which is more user-friendly than Polygon.

Also, Polygon via Alpaca is deprecated now.

1 Like

I am new to Alpaca. I see little activity here.
I am looking for high-quality real-time tick by tick (meaning trade by trade) data, and if there is also order-by-order market depth (“order book”) data that matches in time to the same clock.
Can anyone speak to the quality reliability and speed of such? And does that clock match the clock at Tradestation to within how many nanoseconds?

How far back does Alpace tick data go?

From what I recall, about 5 years.