Open beppe969 opened 3 years ago
This is rather simple.
`[buf, lh] = TWS.initBufferForEvent(TWS.Events.FUNDAMENTALDATA);
reqFundamentalData(session.eClientSocket,reqID,contract,reportType,[]) pause(3)
data = collection2cell(buf);`
reportType can be one of the following:
'ReportsFinSummary' - Financial summary
'ReportsOwnership' - Company's ownership (Can be large in size)
'ReportSnapshot' - Company's financial overview
'ReportsFinStatements' - Financial Statements
'RESC' - Analyst Estimates
'CalendarReport' - Company's calendar
A little bit annoying that the data comes in XML-format though.
Great, thanks, I'll try this!
Keep in mind that some items (like the calendar report) need special subscriptions.
Pardon my inexperience, but at some point I get data =
1×1 cell array
{1×1 com.tws.Handler$FundamentalDataEvent}
but then I have no idea on how to actually access the data from this cell array...
The API always returns java-objects. You can have a look at what you got with
fields(data{1})
in other situations you will need
methods(data{1})
because the data is often returned in form of methods.
If you issue the first you will find that the java-object has two fields, date and data. The data field has the data you requested. So if you issue
data{1}.data
you will see the XML-data the API has sent you.
got it thanks! I'll try to decode the xml-data to see how to retrieve the numbers I'm interested in. Thank you!
Hello
can someone post a script showing how to retrieve fundamental data (like price/earnings, etc.) for a contract?
Thanks! Giuseppe