Specifying input parameters when calling a python function from Matlab

I am using the Python Eikon Data API from the MATLAB environment to retrieve data.
The folloding code line works fine:
K>> [pylog,datarefinitiv]= evalc('py.eikon.get_data(''CDXHY5Y=MP'',''TR.MIDSPREAD.Date,TR.MIDSPREAD'')');
K>> datarefinitiv
datarefinitiv =
Python tuple with values:
( Instrument Date Mid Spread
0 CDXHY5Y=MP 2023-07-21T00:00:00Z 419.602, None)
Use string, double or cell function to convert to a MATLAB array.
However, I would like to retrieve the entire time series and not only the latest value. The corresponding code in Python looks like this:
df, err = ek.get_data(["CDXHY5Y=MP"],
["TR.MIDPRICE","TR.MIDPRICE.Date"],
{"SDate":"2023-06-01","EDate":"2023-07-24","Frq":"D"})
Could you please help how I could adapt my existing code line in order to add the additional specifications (start and end date, daily frequency) to retrieve the full set of data (i.e. how to specify the input parameters in curled brackets)?

Antworten (1)

Pratyush
Pratyush am 28 Jul. 2023
I understand that you want to call your python function passing some arguments from the MATLAB side.
This modification in your code could help acheive your desired output:
[pylog, datarefinitiv] = evalc("py.eikon.get_data('CDXHY5Y=MP', 'TR.MIDSPREAD.Date,TR.MIDSPREAD', struct('SDate', '2023-06-01', 'EDate', '2023-07-24', 'Frq', 'D'))");
You can read more about passing parameters to python function from the following document: Pass MATLAB Data to Python - MATLAB & Simulink - MathWorks India

1 Kommentar

thank you very much for your support!
Modifying the code line as suggested worked perfectly!

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2022a

Tags

Gefragt:

am 24 Jul. 2023

Kommentiert:

am 31 Jul. 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by