hydrosquall / tiingo-python

Python client for interacting with the Tiingo Financial Data API (stock ticker and news data)
https://pypi.org/project/tiingo/
MIT License
250 stars 52 forks source link

[Clarification] Why is there no volume data in the json response? #447

Open MyGithubNotYours opened 4 years ago

MyGithubNotYours commented 4 years ago

Description

I want to download the intraday open, close, high, low, volume data for a stock, but I don't see the volume data.

What I Did

I ran

client.get_dataframe('GOOGL',
                                      frequency='30Min',
                                      startDate='2020-04-19',
                                      endDate='2020-04-22')

Here is the output (in the form of json not a pandas dataframe):

{'date': '2020-04-21T18:30:00.000Z',
  'close': 1215.28,
  'high': 1225.98,
  'low': 1214.99,
  'open': 1225.98}

I don't see any volume data in the return. However, when I use the daily command:

client.get_ticker_price("GOOGL", frequency="daily")

I get the volume data (as well as other additional info different from the intraday data).

{"date":"2012-01-10T00:00:00.000Z",
"close":18.72,
"high":19.05,
"low":18.62,
"open":19.01,
"volume":59344400,
"adjClose":14.2957764614,
"adjHigh":14.5477853414,
"adjLow":14.2194101342,
"adjOpen":14.5172388104,
"adjVolume":61684111,
"divCash":0.0,
"splitFactor":1.0}

What am I doing wrong? .. and thanks for a very useful package so far!

hydrosquall commented 4 years ago

Hi @MyGithubNotYours ,

Thanks for taking a look! I don't think the difference is between using get_dataframe vs get_ticker_price

client.get_ticker_price("GOOGL", frequency="30Min")

, we would get the same number of fields in both responses. The main difference is in the frequency that was specified, volume is just provided when the frequency is daily or greater.

For more information about available fields for each sampling frequency, you may want to contact the support email here directly: https://api.tiingo.com/products/end-of-day-stock-price-data

GenusGeoff commented 3 years ago

To clarify, this is actually based on the Tiingo response. It seems that Tiingo has decided not to include volume in the response unless specifically requested because Tiingo is using ONLY the IEX market center data intraday which represents a modicum of trades placed/filled throughout the day (2 to 3%) such that volume will appear VERY LOW and may be misleading to someone unacquainted with the difference there. However, due to arbitrage, prices should be quite close to actual market prices across many market centers.

bionicles commented 6 months ago

I'm not using this library, just GET requests, and sorry to necro the thread here, but doesn't this screw up a bunch of the technical indicator calculations if sometimes we use correct volumes and other times we use iex volumes? plus seems like tiingo intraday volumes even as recent as 2018 are patchy, you'll find huge swaths of data with no volume whatsoever. That's a real problem during extended bull markets if you literally can't get intraday data in a bear market because it's too distant.

I noticed YF has volume data intraday, great, but it's only available for 730 days, so if we always scrape via offset, then when we stop and restart our app, we scrape a different timespan each time, that's not reproducible. Yeah, I do insert the candles into a sql table, but it seems sketchy to not be able to refetch histories easily if there's a problem with the database.

how do you guys work around these various issues with the tiingo volume data being limited to iex? are there any good alternatives out there? just buy a historical csv file?

tiingo commented 6 months ago

Hey @bionicles

So IEX became an official exchange around end of 2016, we started collecting enough volume data around 2018. We are working on backfilling data prior to then, but another reason you may find 0-volume bars is because we use the tngoLast field to determine OHLC on the data to help make the bars more fluid, update more frequently, and still represent a good reference price. Here is a description of tngoLast from the docs - in case mid is used, you will see price updates, but no volume.

Tiingo Last is either the last price or mid price. The mid price is only used if our algo determines it is a good proxy for the last price. So if the spread is considered wide by our algo, we do not use it. Also, after the official exchange print comes in, this value changes to that value. This value is calculated by Tiingo and not provided by IEX.

https://www.tiingo.com/documentation/iex

Tiingo IEX intraday data is fantastic from a licensing perspective, requiring us to keep minimal, if any, information about clients, and requiring us to pass $0 license fees. The downside is that it's 2-3% market share (NYSE/NASDAQ are around 14-19% each in comparison - most liquidity happens on dark pools). This is why we use tngoLast to keep prices updating fluidly and represent overall market, even if trades happen less frequently on the exchange. This is why our 1 minute intraday bars can look like this:

image

But if you need full-volume this solution can be difficult. I think you will need to contact a tick data service to get full-volume bars. These are generally expensive and have strict licensing requirements that make it difficult to redistribute, or sell, as a business, but they may be more friendly toward an individual for personal use - although cost may still be a barrier to entry. Unsure. But this is why we use the IEX Exchange, for references prices it can be absolutely fantastic, but for high-frequency trading, it most likely will not suit your needs.