Effacer les filtres
Effacer les filtres

Specifying input parameters when calling a python function from Matlab

3 vues (au cours des 30 derniers jours)
Peter Winkler
Peter Winkler le 24 Juil 2023
Commenté : Peter Winkler le 31 Juil 2023
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)?

Réponses (1)

Pratyush
Pratyush le 28 Juil 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 commentaire
Peter Winkler
Peter Winkler le 31 Juil 2023
thank you very much for your support!
Modifying the code line as suggested worked perfectly!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by