I am trying to understand a portion of code from the Interactive Brokers sample in their API. It is about processing data from incoming messages, and while I understand the general flow of event handling, I don't understand this one part:
ibClient.ScannerData += (reqId, rank, contractDetails, distance, benchmark, projection, legsStr) =>
HandleMessage(new ScannerMessage(reqId, rank, contractDetails, distance, benchmark, projection, legsStr));
What is happening in this line of code? I understand what is going on in the grander scheme of things, but not what is happening with the ibClient.ScannerData += ([params]) => f(g([params]))
The HandleMessage
method is responsible for obviously handling incoming messages, and since this line of code is only run once, I believe this is telling ibClient.ScannerData
information how to handle ScannerData
information that is sent to ibClient
.
This is what ibClient
looks like in the backend -
public event Action<int, int, ContractDetails, string, string, string, string> ScannerData;
void EWrapper.scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
{
var tmp = ScannerData;
if (tmp != null)
tmp(reqId, rank, contractDetails, distance, benchmark, projection, legsStr);
}
Where EWrapper.scannerData
is -
void scannerData (int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
provides the data resulting from the market scanner request.