Azzera filtri
Azzera filtri

Specifying input parameters when calling a python function from Matlab

3 visualizzazioni (ultimi 30 giorni)
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)?

Risposte (1)

Pratyush
Pratyush il 28 Lug 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

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by