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 ec_20_inf · May 21, 2018 at 05:45 PM · pythonpython apiget_dataget_data params

Passing a dictionary to get_data 'parameters='.

Hello,

I have the following code that produces a dictionary:

def gen_dict(a, b, c,d,f,**kwargs):
    data=dict()
    data.update(Sdate=c)
    data.update(Edate=d)
    data.update(freq=f)
    if kwargs is not None:
        data.update(kwargs)
    return data

That once given these parameters:

a=['JP3705200008']
b=['TR.CompanyMarketCap']
c='03/21/2017'
d='03/22/2017'
f='D'

The outcome is: 

data={'ShType': 'FFL', 'Frq': 'D', 'Edate': '03/22/2017', 'Curn': 'USD', 'Sdate': '03/21/2017'}

When I try to pass that to get_data(a, b, **data) I get errors, but when I hardcode the dictionary into get_data it works well.

How can I pass dictionaries as arguments to get_data function?

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.

1 Reply

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov. · May 21, 2018 at 07:20 PM

Use get_data(a, b, data) or get_data(a ,b, parameters=data).
When you use "**" notation in front of the variable name you pass to a function, Python unpacks the list or a dictionary inside the variable and provides the elements of the list or the dictionary as arguments for the function. In your example the call get_data(a, b, **data) is equivalent to get_data(a, b, ShType='FFL', Frq='D', Edate='03/22/2017', Curn='USD', Sdate='03/21/2017'), which produces "TypeError: get_data() got an unexpected keyword argument 'ShType'" because get_data method does not have a keyword argument named "ShType". To pass the dictionary as the value for the 3rd position argument of get_data method use get_data(a, b, data). To pass it as the value of the "parameters" keyword argument use get_data(a ,b, parameters=data). Both of these calls are equally valid.

Comment
ec_20_inf
Zhenya Kovalyov

People who like this

2 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
ec_20_inf · May 21, 2018 at 08:52 PM 0
Share

Thank you! It was that simple :)

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 >
7 People are following this question.

Related Questions

Miscellaneous prices

Multiple values of parameters in eikon.get_data query (Codebook, Python)

Python API - Option Adjusted Spread (get_data)

What does the 'CH':'Fd' parameter mean when using ek.get_data ?

Python: getting dates for all tickers/symbols, even for dates in which data is not available.

  • 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
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • 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