FeedProc Sample

This sample demonstrates a StreamBase application, feedproc.sbapp, that processes financial tick data from three financial feeds. The application determines the fastest of the three feeds, computes useful statistics for each feed, and calculates the VWAP for the incoming tick data. A simple client user interface is provided to illustrate the output of the StreamBase application. This application and user interface are geared toward a system administrator monitoring financial feeds.

The goal of the FeedProc application is twofold:

  1. To output groomed trade data as soon as it arrives on any feed

  2. To create useful feed performance data

The application enqueues market data on three streams. Each stream represents a market feed reporting the same trade tick data. Trades are recorded and passed on to the trader if the trade arrived first for a given tick. As each trade is processed, feed performance data is extrapolated, such as the delay with respect to the first incoming trade of each tick.

About the StreamBase Studio interface:

StreamBase Studio provides a slider that lets the user determine which trades are deemed outliers based on how many standard deviations from the mean a price lies. The user can set the value for the SIGMA threshold at which trades are dropped. Therefore, any trades where the price difference from the mean is greater than SIGMA standard deviations away will be counted as outliers and not shown on the TraderView portion of the user interface. Try running the application a couple times, and notice that if the SIGMA is set sufficiently low (to 1,for example), then many trades will be filtered out. The distance from the mean of non-outliers is shown in the sigma column of the TraderView table. For further analysis, refer to the descriptions within the operators that comprise feedproc.sbapp.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top menu, click FileLoad StreamBase Sample.

  • Select operator from the Applications list.

  • Click OK.

StreamBase Studio creates a single project for the operator samples.

Sample Location

By default, the sample files are installed in:

  • On Windows: C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\feedproc

  • On UNIX: /opt/streambase/sample/feedproc

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace. StreamBase Systems recommends that you use the workspace copy of the sample, especially on UNIX, where you may not have write access to /opt/streambase. In the default installation, the path to this sample in your Studio workspace is:

UNIX:       
  ~/streambase-studio-n.m-workspace/sample_feedproc
Windows XP:
  C:\Documents and Settings\username\My Documents\StreamBase Studio n.m Workspace\
      sample_feedproc
Windows Vista:
  C:\Users\username\Documents\StreamBase Studio n.m Workspace\
      sample_feedproc

This Sample's Files

The FeedProc sample application contains:

  • The application, feedproc.sbapp.

  • A sample Java dequeuer, FeedProc.java, to view the application's output using the StreamBase Java Client API.

  • A sbfeedsim configuration file, feedproc.sbfs.

  • Three CSV files representing real-time feed data.

  • Java source code for these programs.

  • Either Microsoft Visual Studio .NET solution and project files (Windows) or a Makefile (UNIX), which can be used to build all of the sample source code. (In the Visual Studio project files, the paths to the StreamBase include files and libraries are configured for the standard default installation directory. You may need to adjust these paths for your PC.)

Running the FeedProc Sample Application

You can and should open this sample's application files in StreamBase Studio to study how the applications are assembled. However, this sample is designed to be run in UNIX terminal windows or Windows command prompt windows. On Windows, be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not a standard command prompt.

This application has timing factors that are best managed by running the feed simulations in terminal windows, and using the sbfeedsim-old command.

On UNIX

  1. Open three terminal windows. In each window, navigate to the directory where the sample is installed, or to your workspace copy of the sample, as described above.

  2. In window 1, launch a StreamBase Server on feedproc.sbapp:

    sbd feedproc.sbapp

  3. In window 2, run the output viewer by entering the following command:

    java -classpath `sb-config --classpath`:streambase-install-dir/lib/sbclient.jar:FeedProc.jar FeedProc

  4. In window 3, run the sbfeedsim-old command on the provided configuration file, suppressing the printout of tuples:

    sbfeedsim-old -q feedproc.sbfs

  5. Run sbadmin shutdown to close the server.

On Windows

  1. Open three StreamBase Command Prompt windows. In each window, navigate to the directory where the sample is installed, or to your workspace copy of the sample, as described above.

  2. In window 1, launch a StreamBase Server on feedproc.sbapp:

    sbd feedproc.sbapp

  3. In window 2, run the output viewer using this syntax:

    java -classpath "streambase_install_dir\lib\sbclient.jar;FeedProc.jar" FeedProc

    For example:

    java -classpath C:\Program Files\StreamBase Systems\StreamBase.n.m\lib\sbclient.jar;FeedProc.jar FeedProc

  4. In window 3, run the sbfeedsim-old command on the provided configuration file, suppressing the printout of tuples:

    sbfeedsim-old -q feedproc.sbfs

  5. Run sbadmin shutdown to close the server.

Note that fast-forwarding data with sbfeedsim-old -x may cause tuples to arrive out of order. This is because StreamBase does not guarantee inter-stream ordering. As a result, any Aggregate window relying on ordered values such as time (for example, the Heartbeat aggregate with windowing over time) may throw an ordering violation error. For purposes of instruction and simplicity, this sample was not designed to handle fast-forwarded market data.

Back to Top ^