SECF() implementation#50
Conversation
Implementation of the terminal function 'SECF' using the instruments service
| raise RuntimeError("Expected a SERVICE_STATUS event but " | ||
| "received a %s" % ev_name) | ||
| if not opened: | ||
| logger.warning("Failed to open //blp/exrsvc") |
There was a problem hiding this comment.
I think this should be logger.warning("Failed to //blp/instruments")
| ticker = r.getElementAsString("security") | ||
| ticker = ticker.replace('<', ' ').replace('>', '').upper() | ||
| descr = r.getElementAsString("description") | ||
| if not descr.endswith('(Multiple Matches)'): |
There was a problem hiding this comment.
What exactly is the check for Multiple Matches doing? Is there a sample request you could add in the thread so I can see when this is used?
| for msg in self._receive_events(): | ||
| for r in msg.getElement("results").values(): | ||
| ticker = r.getElementAsString("security") | ||
| ticker = ticker.replace('<', ' ').replace('>', '').upper() |
There was a problem hiding this comment.
I think it is better to leave this line out. The general philosophy of pdblp is to provide a thin wrapper around blpapi and limit the data processing. If a user wants this they can do it easily enough afterwords using df.ticker.str.replace("<", "").str.replace(">", "").str.upper()
| return data | ||
| data.append((ticker, descr)) | ||
| return pd.DataFrame(data, columns=['ticker', 'description']) |
There was a problem hiding this comment.
Given that the response messages look like
InstrumentListResponse = {
results[] = {
results = {
security = "Some security"
Description = "Blah blah"
}
...
}
}
I think that columns = ['security', 'description'] would be more appropriate
| request = self.instrService.createRequest("instrumentListRequest") | ||
| request.set("query", query) | ||
| request.set("maxResults", max_results) | ||
| request.set("yellowKeyFilter", "YK_FILTER_%s" % yk_filter) |
There was a problem hiding this comment.
I think to be consistent with how parameters are set elsewhere in the library, this convenience string concatenation should not be done for the user, e.g. the user should pass YK_FILTER_EQTY and this line should be changed to request.set("yellowKeyFilter", yk_filter). Also while it does appear that YK_FILTER_NONE is supported but seems superfluous? I think it would be better stylistically to have yk_filter=None as a default parameter and then
if yk_filter:
request.set("yellowKeyFilter", yk_filter)
|
Other than those minor things all looks good, thanks for the pull request. |
Closes #49 - all tests added / passed
Returns a pd.DataFrame to be consistent with other functions.