FIX Adapter Sample

This sample demonstrates the use of the Spotfire Streaming Input and Output Adapters for FIX. See FIX Adapter for details on the structure and use of these adapters.

About This Sample

This sample uses four FIX adapters (two Input-Output pairs) to simulate two separate counterparties communicating using the FIX protocol. The application uses one FIX Input adapter (FIXInput_1) and one FIX Output adapter (FIXOutput_1), linked to share their FIX connection, to act as the connection initiator. The second FIX adapter pair (FIXInput_2 and FIXOutput_2) acts as the connection acceptor.

Note

In a typical StreamBase application, both FIX counterparties would not be running in the same process as they do in this sample. A more likely scenario would have one or more FIX adapters connected to FIX venues outside your company. However, for the purpose of this sample, keeping everything in one application improves clarity and ease of use.

In the sample application, the FIXOutput_1 adapter periodically sends a New Order Single (MsgType="D") FIX message to the FIX target, FIXInput_2. On receiving this message, the target routes it to the appropriate output port based on the settings in its Message Routing Map. In this case, messages of MsgType g are routed to port 2.

Note

While this message is valid from a FIX protocol standpoint (that is, all required fields are set), it is not necessarily complete. This message is meant to demonstrate how to send messages and how to route them to specific ports on the receiving side.

When the New Order Single message is received, an Execution Report (MsgType="8") message is generated and sent back to FIXInput_1.

FIX Engines Supported by This Sample

The sample application is configured to be run using the QuickFIX/J FIX engine, but you can easily use the StreamBaseFIX FIX engine to run it instead (provided you have the appropriate license to do so). To change the application to use this engine, follow these steps:

  1. Open fix.sbapp in StreamBase Studio.

  2. Click on the FIX Output Adapter named FIXOutput_1 in the EventFlow editor.

  3. In the StreamBase Properties view's Adapter Properties tab, in the FIX Engine drop-down control, select the StreamBaseFIX engine.

  4. In the FIX Configuration File control, select StreamBaseFIX-config-1.xml.

  5. Make the same changes for the FIX Output Adapter named FIXOutput_2, this time selecting StreamBaseFIX-config-2.xml as the FIX Configuration File.

  6. Save the fix.sbapp file before running.

Importing This Sample into StreamBase Studio

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

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter fix to narrow the list of options.

  • Select FIX adapter from the StreamBase Trade Execution Adapters category.

  • Click Import Now.

StreamBase Studio creates a project for this sample.

Running This Sample in StreamBase Studio

  1. In the Project Explorer view, open the sample you just loaded.

    If you see red marks on a project folder, wait a moment for the project to load its features.

    If the red marks do not resolve themselves after a minute, select the project, right-click, and select Maven>Update Project from the context menu.

  2. Open the src/main/eventflow/packageName folder.

  3. Open the fix.sbapp file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

  4. In the SB Test/Debug Perspective, open the Output Streams view.

  5. Look for tuples emitted on the AdminMsgFromFIXAdapter_1 and AdminMsgFromFIXAdapter_2 streams to indicate that Logon messages (MsgType=A) are exchanged.

  6. Also look for tuples being emitted every five seconds on the NOSMsgFromFixOutput_1 stream, indicating that FIX messages of type D are sent from FIXOutput_1 to FIXInput_2. The messages are routed to that port instead of the first port because the FIXInput_2 adapter is configured to route all application level messages of type D to the second port (and all others to port 1.)

  7. Once a New Order Single message has been generated, look for an Execution Report (MsgType='8') response to be sent back from FIXOutput_2. You will see this message being received by the ExecutionReportMsgFromFIXAdapter_2 stream.

  8. In the Manual Input view, select the Commands stream. Enter the following values and click Send Data:

    • Command: ResetSession

    • BeginString: FIX.4.2

    • SenderCompID: FIXAdapter_1

    • TargetCompID: FIXAdapter_2

  9. Observe the Logout and Logon messages in each adapter's admin-level message stream, signifying that the connection is being reset.

  10. When done, press F9 or click the Terminate EventFlow Fragment button.

Sample Location

When you load the sample into StreamBase® Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase® Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/sample_adapter_embedded_fix

See Default Installation Directories for the default location of studio-workspace on your system.