Specifying input parameters when calling a python function from Matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
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)?
댓글 수: 0
답변 (1개)
Pratyush
2023년 7월 28일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!