Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
35 1 2 3

How to get the same CSV data as the sample file of the book?

Please tell me the contents of the following csv file introduced in this book and the EIKON API Code to get the same data. This book does not describe how to obtain the data, but instead provides EIKON data as a sample file. With "get_timeseries" I couldn't reproduce the exact same data.

  • Book Name : Python for Finance, 2nd Edition [Book] - O'Reilly
  • CSV : tr_eikon_eod_data.csv (Data excerpt)

  • Code I created (The date data is slightly different from the sample.)
data = ek.get_timeseries(['AAPL.O', 'MSFT.O', 'INTC.O', 'AMZN.O', 'GS.N',' SPY', '.SPX', '.VIX', 'EUR=', 'XAU=', 'GDX', 'GLD'],
                         ['CLOSE'],
                         '2010-1-1','2020-10-1')
data
  • Result (Where should I modify the code to get the same result as this?)
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().


  • Related code & Result (Add column)

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

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

Upvote
Accepted
10.2k 18 6 9

@Takeshi.Matsuda You should be aware of the API limits - you can find these in this document. You will notice that the get_timeseries API call has a limit of '3,000 data points (rows) for interday intervals and 50,000 data points for intraday intervals. This limit applies to the whole request, whatever the number of requested instrument.'

Please try this code which iterates across the instrument list to get the correct data without truncation due to limits.

import eikon as ek
import pandas as pd
import numpy as np

instruments = ['AAPL.O', 'MSFT.O', 'INTC.O', 'AMZN.O', 'GS.N',' SPY', '.SPX', '.VIX', 'EUR=', 'JPY=', 'GDX', 'GLD']

s = '2010-01-01'
e = '2020-10-1'
inv = 'daily'
data1 = pd.DataFrame()
for i in instruments:
    df1 = ek.get_timeseries(i,  # RICs
              fields=['CLOSE'],  # fields to be retrieved
              start_date=s,  # start time
              end_date=e,  # end time
              interval=inv)
    df1.rename(columns = {'CLOSE': i}, inplace = True)
    if len(data1):
        data1 = pd.concat([data1, df1], axis=1)
    else:
        data1 = df1

data1

I hope this can help.


1602241415685.png (205.2 KiB)
icon clock
10 |1500

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

The result is what I want !

Thank you for providing the code quickly and accurately.

How do you get around the restrictions? Are you narrowing down the data to be acquired each time (that is, dividing the data)?

@Takeshi.Matsuda If you look at the code you will see that we are iterating over each RIC (for i in instruments:) - so each RIC is being requested in its own API call, thereby having its own limit of 3000 rows. Then we are just concatenating each of these to our desired dataframe so we end up with the complete dataframe you see at the end.

Upvote
4.3k 2 4 5

Hi @Takeshi.Matsuda,

Regarding the second issue:

  • Result (Where should I modify the code to get the same result as this?)
                
  1. ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Could you detail which version of eikon lib you are using ?

icon clock
10 |1500

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

It is the latest one.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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