Developers: Using the opentick Adapter to Build Market Data Applications

Home
Documentation
Library
Sample Code and Applications
FAQs
Articles
Community
Training
Download Center
Contact DevZone

Printer Friendly

 Library Articles

Using the StreamBase opentick Adapter to Build Market Data Applications

Authors: Jason Garbis, StreamBase Systems

Date: 01-October-2007

Applicable To: StreamBase 3.7, 5.0

Introduction

The StreamBase opentick adapter provides an easy and inexpensive way to build applications that perform market data analysis against a real, live market feed. opentick, which provides both free and low-cost access to live and historical market data. opentick is a third-party provider and requires you to register for an account and to abide by their licensing terms (see http://www.opentick.com for more information). Please note that you will need to obtain an opentick account in order to use the adapter.

While a production business application that performs market data analysis may not use opentick—such applications typically receive market data from paid-for data feed providers that offer service guarantees (which opentick does not)—opentick gives developers a chance to create a prototype application and get a feel for using StreamBase, at a very low cost.

opentick provides free access to various market feeds, including market data for most U.S. stock, option, and futures exchanges, ECNs and regional exchanges, and option chains. It also provides free historical data, including Open, High, Low, Close (OHLC) data in intra-day, inter-day, and tick based time frames, several years of historical tick data for most U.S Domestic Exchanges, and Historical Level II tick data. Many other services are available at low cost, including real-time data.

Configuring the opentick Adapter


There are two steps required prior to building an application that uses the StreamBase opentick adapter. First, the adapter must have a valid configuration file, and second, the correct number of input streams must be set up for the adapter instance. Let’s look at each of these in turn.

Each opentick adapter has a configuration file associated with it (multiple instances of the adapter in a given application can share a configuration file, if desired). The configuration file is set for each adapter instance, once it’s dragged onto the Studio canvas.

 

The configuration file, which is in XML format, drives the behavior of the adapter across four categories:

  • Server Connection Elements, which specify how to connect to an opentick server
  • Output Port Elements, which specify an adapter instance’s set of output ports and their schemas (one or more of the 8 available types)
  • Static Data Request Elements, which specify the fixed set of events to which the adapter instance is subscribed
  • Control Streams, which let you dynamically change the set of opentick events to which the adapter is subscribed.
    • After the adapter reads a valid configuration file, Studio draws the correct number of input ports for the adapter, one for each control stream specified in the config file. Once input streams with the correct schemas are connected to input ports, Studio draws the correct number of output ports and supplies the output stream schemas; streams can then be attached to these output ports.

      The following figure illustrates a very simple opentick application:

       

      The application uses StreamBase’s opentick input adapter (named opentickInput in this example) to retrieve quotes and trades from a specified exchange, and for a specified set of stock symbols. Quote and trade tuples are directed to the QuoteTickStreamOutput and TradeTickStreamOutput output streams, respectively. The configuration file controls the number of type of output ports on the adapter; this instance is configured to output Quotes and Trades.

      This application shows a single control stream (TickStreamControl), used to dynamically add or remove symbols from the list of subscribed entities. This is also controlled by the configuration file.

      Note that this simple application performs no processing on the Ticks or Quotes received; it simply passes them through to output streams. Naturally a real application would actually do something with the tuples.

      The configuration file (tick-streams.xml) for this application is:

      <sb-opentick-adapter-config>

          <username>”USERNAME”</username>

          <password>”PASSWORD”</password>

          <controlStream>TickStream</controlStream>

          <outputSchema>QUOTE</outputSchema>

          <outputSchema>TRADE</outputSchema>

          <hostAndPort 
              hostName="feed1.opentick.com" 
              port="10015"></hostAndPort>

          <loginTimeout>20000</loginTimeout>

          <tickStreamRequest 
          
      exchange="Q" symbol="GOOG"
          
      mask="OT_TICK_TYPE_ALL"></tickStreamRequest>

      </sb-opentick-adapter-config>

      (Note that the actual username and password have been replaced with “USERNAME” and “PASSWORD” in this configuration file—in order to make this example work, you must sign up for an opentick account at http://www.opentick.com and use the username/password for your account. Also note that this uses the opentick server feed1 on port 10015; this is the host & port on which opentick provides free, delayed market data. Paid accounts can receive real-time market data; see http://www.opentick.com/dokuwiki/doku.php?id=general:opentick_servers for server details)

      At startup, this app is statically configured to receive GOOG (Google) quotes and trades, from the NASDAQ market (“Q”). The TickStream control stream allows a user to dynamically add or remove exchanges, symbols, and masks supported commands are “add” and “cancel”; see (these commands are all documented in <install-dir>/doc/adaptersguide/embeddedInputopentick.html for complete details)

      Running the opentick Adapter


      When this app is launched as a local StreamBase application, the perspective changes to that of StreamBase Test/Debug, and you can view the results from the TradeTickStreamOutput and QuoteTickStreamOutput streams, as shown below:

      You can add (with the “add” with command) or remove (with the “cancel” command) exchanges, symbols, and masks in the Manual Input pane of this perspective. The following figure shows the addition of the Microsoft stock symbol (MSFT) on the NASDAQ exchange (Q), using that same mask (OT_TICK_TYPE_ALL):

      For more information about the opentick adapter, see the StreamBase Adapters Guide at <install-dir>/doc/adaptersguide/embeddedInputopentick.html .

      The opentick documentation is available at: http://www.opentick.com/dokuwiki/doku.php. Valid opentick masks can be found at: http://www.opentick.com/dokuwiki/doku.php?id=general:tick_type_constants.

      Related Topics

      The StreamBase opentick adapter documentation provides complete information on the format of the configuration file, and the schema for the control streams.

      Additional opentick information is available from http://www.opentick.com/