Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support for fetching intraday volume data in the get_dataframe method #462

Open
whyrv opened this issue May 26, 2020 · 15 comments

Comments

@whyrv
Copy link

whyrv commented May 26, 2020

For intraday prices, Tiingo can provide the IEX volume if explicitly requested as
"?columns=open,high,low,close,volume" per their docs.

Unfortunately the get_dataframe doesn't expose this, when no metric_name is provided, it passes no value for the column parameter to Tiingo's APIs

                url = self._get_url(stock, frequency)
                response = self._request('GET', url, params=params)
                df = pd.DataFrame(response.json())

I recommend providing a way to request the volume optionally so that the user can get all fields for OHLCV (and choose to discard volume as it may not be complete, or use it with that understanding)

@hydrosquall
Copy link
Owner

Hi @whyrv ,

This is great feedback, thanks for taking a look and providing this idea! When thinking about how to expose this to users, how would you feel if metric_name can be provided as either a list of strings, or as a single string (for the single metric case)? In the case where metric_name was provided as a list, we could thread that through to _get_url as you've suggested.

@hydrosquall hydrosquall changed the title No way to obtain intraday volume [Feature Request] Add support for fetching intraday volume data in the get_dataframe method Jun 3, 2020
@whyrv
Copy link
Author

whyrv commented Jun 3, 2020

Hi, your suggestion makes sense. I hacked this locally by overriding this method by passing an additional flag includeIntradayVolume as follows

def get_dataframe(self, tickers,
                    startDate=None, endDate=None, metric_name=None, frequency='daily', includeIntradayVolume=True):

#...
# append volume to columns appropriately under the right conditions: intraday and this flag is set.
params['columns'] = 'open,high,low,close,volume'

You could do this and document that volume is IEX only for intraday or flip the boolean.

thanks for looking into this.

@hydrosquall
Copy link
Owner

Hi @whyrv, happy to hear that this worked, thanks for sharing your solution. I'd be happy to review a PR if you are interested in making a PR with this adjustment, otherwise I'll leave this open for contributions / add it next time I cut a feature release .

@maxko37
Copy link

maxko37 commented Mar 1, 2021

Hello @whyrv,
could you may detail your solution a little bit more? I am unfortunaltely not able to come across with an workaround.
Thanks!

Cheers

@whyrv
Copy link
Author

whyrv commented Mar 2, 2021

Hi,

This is the relevant set of changes I had made (search for ### below) in the get_dataframe API I mentioned above.

regards.

valid_columns = {'open', 'high', 'low', 'close', 'volume', 'adjOpen', 'adjHigh', 'adjLow',
                'adjClose', 'adjVolume', 'divCash', 'splitFactor'}


if metric_name is not None and metric_name not in valid_columns:
  raise APIColumnNameError('Valid data items are: ' + str(valid_columns))

if metric_name is None and isinstance(tickers, list):
  raise MissingRequiredArgumentError("""When tickers is provided as a list, metric_name is a required argument.
                                        Please provide a metric_name, or call this method with one ticker at a time.""")

params = {
    'format': 'json',
    'resampleFreq': frequency,
}
### -> this here is key, you need to pass these as columns for getting intraday.
if includeIntradayVolume:
  params['columns'] = 'open,high,low,close,volume'

if startDate:
  params['startDate'] = startDate
if endDate:
  params['endDate'] = endDate

@maxko37
Copy link

maxko37 commented Mar 2, 2021

Hi,
thanks for the quick reply. That is really strange. Basically, I did the same but I had the if includeIntradayVolume line below the endDate, which did not seem to work.

@datatalking
Copy link

@hydrosquall I could work on getting a PR later this week.

@hydrosquall
Copy link
Owner

That would be very welcome! Thanks @datatalking

@datatalking
Copy link

So I looked for the 'get_dataframe' method, it doesn't look like anybody actually specifically named in which file since it's in three. I'm guessing you are talking about test_tingo_pandas.py?
That method is also in api.py and basic-usage-with-pandas.ipynb

@datatalking
Copy link

Ok, I think I found it and made the change, not sure if this is the exact place you were thinking so here is a screen shot.

Screen Shot 2021-08-25 at 7 32 33 PM

@datatalking
Copy link

datatalking commented Aug 26, 2021

The other part of the solution is adding the additional parameter includeIntradayVolume=True in after the fmt=json like this?

Which creates my next question, how do you have it defined?
Is it the int64 defined here? Tiingo Docs Section 2.5.3 Historical Intraday Prices Endpoint gave
https://api.tiingo.com/iex/<ticker>/prices?startDate=2019-01-02&resampleFreq=5min as an RESTendpoint

Tiingo can also provide the fmt="CSV" so would an additional documentation issue be good to add that?
https://api.tiingo.com/documentation/general/overview Section 1.14

Screen Shot 2021-08-25 at 7 59 10 PM

@rizclive
Copy link

rizclive commented May 7, 2023

@datatalking @hydrosquall Any update on this issue? I really need volume data wtih intraday, need to pass volume to the columns params as mentioned in doc,, but not sure how to do with this library?

The number of shares traded on IEX only. This value will only be exposed if explicitly passed to the "columns" request parameter. E.g. ?columns=open,high,low,close,volume

@hydrosquall
Copy link
Owner

Hey @rizclive , the #673 PR hasn't been worked on in a while.

I think you would be able to get the volume data without further code changes if you request the metric with name "volume" directly:

ticker_history = client.get_dataframe("some-iex-ticker", metric_name='volume')

@datatalking
Copy link

@rizclive and @hydrosquall I've not worked on this since OP, I could look at it this weekend if this feature still needed or available?

@rizclive
Copy link

@hydrosquall I have tried passing metric_name='volume' but its doesn't seems to be working when I specify lower timeframe then daily.
@datatalking would be good to get this feature released.

Thanks!
Riz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants