Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /
avatar image
Question by Takeshi.Matsuda · Oct 09, 2020 at 10:37 AM · eikondataapieikonapieikonexceleikon_historical_data eikon_vs_python limitation_historical

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)

samplecoderesult.jpg (292.5 KiB)
pythonforfinance-csv-data.jpg (121.4 KiB)

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by jason.ramchandani · Oct 09, 2020 at 11:03 AM

@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)
Comment
Takeshi.Matsuda

People who like this

1 Show 3 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Takeshi.Matsuda · Oct 12, 2020 at 09:09 AM 1
Share

The result is what I want !

Thank you for providing the code quickly and accurately.

avatar image
Takeshi.Matsuda · Oct 12, 2020 at 09:27 AM 0
Share

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

avatar image
REFINITIV
jason.ramchandani ♦♦ Takeshi.Matsuda · Oct 12, 2020 at 11:18 AM 0
Share

@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.

avatar image
REFINITIV
Answer by pierre.faurel · Oct 09, 2020 at 12:41 PM

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 ?

Comment
Takeshi.Matsuda

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Takeshi.Matsuda · Oct 12, 2020 at 09:10 AM 0
Share

It is the latest one.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

Query to retrieve average FX Rates

Company trees don't match in Eikon online tool and the Eikon Proxy API

Retrieve all broker esitmates for a given RIC/instrument

I would like to know whether the Data Limits of Eikon API may change if I subscribe to a "larger" (and costlier?) account

How can I get historical ESG data?

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges