You can process events related to any data updates by writing a custom event handler function for use with Datafeed Toolbox™. For example, you can monitor prices before creating an order or plot interval data in a graph. Follow these basic steps to write a custom event handler.
Choose the events you want to process, monitor, or evaluate.
Decide how the custom event handler processes these events.
Determine the input and output arguments for the custom event handler function.
Write the code for the custom event handler function.
For details, see Create Functions in Files (MATLAB). For a code example
of a Bloomberg® event handler function, enter
edit v3stockticker.m at the
You can run the custom event handler function by passing the function name as an input
argument into an existing function. For Thomson
Reuters® RMDS function
fetch, specify the custom event handler as a
character vector or string. For other functions, specify the custom event handler function
name either as a character vector, string, or function handle. For details about function
handles, see Create Function Handle (MATLAB).
For example, suppose you want to retrieve real-time data from Bloomberg using
realtime with the
custom event handler function named
You can use either of these syntaxes to run
This code assumes a Bloomberg connection
s, Bloomberg data fields
f, Bloomberg subscription
and MATLAB® timer
Use a character vector or string.
[subs,t] = realtime(c,s,f,'eventhandler');
Or, use a function handle.
[subs,t] = realtime(c,s,f,@eventhandler);
This workflow summarizes the basic steps to work with a custom event handler function for any of the data service providers.
Write a custom event handler function and save it to a file.
Create a connection to the data service provider.
Subscribe to a specific security using an existing function or API syntax.
Run an existing function to receive data updates and use the custom event handler function as an input argument.
Stop data updates by using
closing the connection to the data service provider.
Close the connection to the data service provider if the connection is still open.