For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
0 0 1 2

How can we extract historic avg trading value or similar?

Hi there,

We are trying to extract historic avg trading volumes and or values, through the Python API – but seem to be unable to find the correct field for this. Can you help us?

  1. So far we have looked at TR.AvgDailyValTraded30D, and the related items in the date item browser – but those all seem to calculate from the latest date.
  • Ideally we would want something like AVGdailyVolume for the date 2003-01-31, 2003-02-30, 2003-03-31 and so on. The closest we get is getting the daily volume on the exact calc date using TR.Volume, but we need the avgdailyvolume for a period.
eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonhistorical
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
Accepted
3.8k 4 4 6

Hi @me39,

You can try that using an AVG function.

df, err = ek.get_data(['AAPL.O'], 
                      ['AVG(TR.VOLUME)'],
                      {'SDate': '2003-01-01', 'EDate': '2003-12-31'})
df

To check how to build that syntax and other capabilities, please check Build Formula tool in Eikon Excel.


avg.jpg (225.7 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

This calculates the averages across all dates for the entire year. We are looking to get averages on a monthly basis - i.e. for the year 2003, there should be 12 averages.

  1. One for each month, so that january 31, has the average volume for that entire month. Is this a possibility?
  2. I seem to be unable to access the formula builder via the EIKON app, is this only available through the EIKON add in in Excel?
Upvotes
4.6k 26 7 22

@me39 this is a content question, so I would recommend speaking to your local Refinitiv Support Desk first.

I am not too sure whether we have a pre-calculated daily averages since 2003, the only way I see it - get the daily historical data and calculate average values manually:

df, e = ek.get_data('AAPL.O', 
                    ['TR.Volume.date','TR.Volume'], 
                    {'Frq':'D', 'SDate':'20030101', 'EDate':'20031231'})

df['Date'] = df['Date'].apply(lambda x: datetime.strptime(x[:10], '%Y-%m-%d'))
df.set_index('Date', inplace=True)
df[df['Volume']!=0].resample('M').mean()


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

I would really prefer not to calculate theese manually, allthough that might be our only option. (?)

Upvotes
0 0 1 2

Hi again, local support desk told me to post it here, but I agree with you. It´s a content question.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@me39 apologies for the confusion :-) the api topic is quite new to them. Ask for help in modeling this in Eikon Excel, such Excel model can be easily ported into Python, since the field names and parameters are shared.

Click below to post an Idea Post Idea