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)
Best Answer
-
@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
data1I hope this can help.
0
Answers
-
Hi @Takeshi.Matsuda,
Regarding the second issue:
- 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().
Could you detail which version of eikon lib you are using ?
0 -
The result is what I want !
Thank you for providing the code quickly and accurately.
0 -
It is the latest one.
0 -
How do you get around the restrictions? Are you narrowing down the data to be acquired each time (that is, dividing the data)?
0 -
@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.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛