Child pages
  • Strategy Engine User Guide
Skip to end of metadata
Go to start of metadata

Overview

The Strategy Engine is a client application in the Marketcetera Automated Trading Platform. The Strategy Engine is responsible for the execution of modules, particularly strategies. Strategy Engines connect to an instance of DARE, the Marketcetera order routing engine and provide a web services API for control of the running modules. Multiple Strategy Engines can run at the same time, connected to the same routing engine. By default, the Strategy Engine connects to the Marketcetera cloud DARE instance. You can use this setup to test your strategies before licensing a DARE appliance for your data center or cloud installation.

The Strategy Engine is a command-line application with no UI. The Strategy Engine is considered to be a client application in the Marketcetera Automated Trading Platform in that it needs to connect to an instance of DARE to run.

Running Strategy Engine

Windows

The Strategy Engine installs a Start Menu entry. This starts the Strategy Engine with the commands located in src/commands.txt. You can modify that file to change how the Strategy Engine starts by default. Or, you may open a cmd prompt and start the Strategy Engine directly.

C:\Marketcetera-2.4.0\strategyengine>bin\strategyengine.bat
Copyright (c) 2006-2014 Marketcetera, Inc.
Strategy Engine version '2.4.0' (build 'cc.build.506')

Linux

$ bin/strategyengine.sh 
Copyright (c) 2006-2014 Marketcetera, Inc.
Strategy Engine version '2.4.0' (build 'cc.build.506')

The Strategy Engine can be run, as shown above, with no command-line arguments. In this state, no modules are running yet, the Strategy Engine is an empty container waiting for instruction. The Strategy Engine can be controlled via its web services interface (this is how Photon controls strategies).

Strategy Engine Command Files

You may start the Strategy Engine with a command file as a command-line argument. This tells the Strategy Engine to execute the commands in the file upon start. Sample commands are included with the Strategy Engine in the samples subdirectory.

colin@demeter:~/marketcetera/marketcetera-2.4.0/strategyengine$ bin/strategyengine.sh samples/java/commands/MarketData.txt 
Copyright (c) 2006-2014 Marketcetera, Inc.
Strategy Engine version '2.4.0' (build 'cc.build.506')
Running command 'createModule' with parameters 'metc:strategy:system;marketData,MarketData,JAVA,samples/java/scripts/MarketData.java,,false,metc:sink:system'...
Completed command 'createModule' with result 'metc:strategy:system:marketData'.
Running command 'startModule' with parameters 'metc:mdata:bogus:single'...
Completed command 'startModule' with result 'true'.
Running command 'startModule' with parameters 'metc:strategy:system:marketData'...
Completed command 'startModule' with result 'true'.
Data Flow ID '1' generated data 'of type org.marketcetera.event.impl.LogEventImpl and' value '20140103T171145466Z WARN event Bid Equity Bid(ADD-16 UNKNOWN) for Equity[symbol=GOOG]: 51.95 8004 Equity[symbol=GOOG] BGS1 at 20140103T171144828Z'
Data Flow ID '1' generated data 'of type org.marketcetera.event.impl.LogEventImpl and' value '20140103T171145468Z WARN event Ask Equity Ask(ADD-50 UNKNOWN) for Equity[symbol=GOOG]: 51.96 8177 Equity[symbol=GOOG] BGS1 at 20140103T171145424Z'

Modules

The unit of work of the Strategy Engine is the module. Modules are discrete units of code that can participate in data flows. Data flows are managed by the Strategy Engine and route data between two modules.

Every module has a unique identifier, called a URN (Uniform Resource Name). The module URN is used to indicate the target of module commands. 

Data Flows

A data flow is a stream of objects of arbitrary type between two started modules. A data flow must be initiated, either by a command file or from code. Data flows can also be stopped.

Part of the definition of a module is whether it's a data requester, a data receiver, a data flow requester, or all of the above.

Commands

createModule

Creates a module instance. Some modules are auto-created, some are not; this is defined when the code for the module is written. Modules that are auto-created do not need to be created as they will be created at system initialization. Whether the module is auto-created or created manually, a module must be created before it can be started.

createModule;metc:strategy:system;vwapStrategy,VWAPStrategy,JAVA,samples/java/scripts/VWAPStrategy.java,,false,metc:sink:system

The syntax for the createModule command is particular to the module being started. Here is the current list of modules and their parameters.

startModule

Starts a created module instance. Some modules are auto-started, some are not; this is defined when the code for the module is written. Modules that are auto-started can not be manually started. Modules that are not auto-started must be started before they can participate in a data flow.

startModule;metc:strategy:system:vwapStrategy

The syntax for the startModule command is: startModule;<Module Instance URN>

createDataFlow

Creates a data flow between module instances. The source module must be a DataEmitter and the target module must be a DataReceiver.

createDataFlow;metc:strategy:system:vwapStrategy;orders^metc:strategy:system:orderReceiver;all^metc:remote:receiver

The syntax for the createDataFlow command is: createDataFlow;<Module Instance URN>;<content>^<Module Instance URN>;<content>^...^<Module Instance URN>. This implies that several different modules can participate in the same data flow. If a module has entries to its left, that module must be a DataReceiver. If a module has entries to its right, that modules must be a DataEmitter. In the example above, then, the module with the URN "metc:strategy:system:orderReceiver" is both a DataReceiver and a DataEmitter. Data in a data flow moves from left to right. Data will continue to flow until the data flow is stopped.

Configuration

The Strategy Engine configuration is predominantly established in strategyengine/conf/default.properties and user.properties. There are other settings in other files, but these are the files most commonly changed. The two files work together to define a key/value properties set that the Strategy Engine uses for configuration. Values are defined in default.properties and optionally overridden in user.properties. If the same key is defined in both files, user.properties takes precedence. It is recommended to copy the key/value pair you wish to modify from default.properties to user.properties. The Strategy Engine must be restarted for configuration changes to take effect.

metc.sa.ws.host=localhost

This property defines the network interface on which the Strategy Engine listens for web services requests. The default value listens on the loopback address only. This is secure, but may not address your needs if you're running the Strategy Engine and Photon on different machines. This value can be either an IP address or a hostname. A reasonable alternative value is 0.0.0.0, which would make the Strategy Engine listen on all interfaces of the Strategy Engine.

metc.sa.ws.port=9001

This property defines the network port on which the Strategy Engine listens for web services requests. The default value is reasonable. You may need to change this if you already have something running on port 9001 on your Strategy Engine machine or if you're running more than one Strategy Engine on the same machine. Each Strategy Engine must be assigned a unique port.

metc.sa.rpc.port=8998

This property defines the network port on which the Strategy Engine listens for RPC requests. The functional contents are identical for RPC and web services. It's just another way to get at the same features.

metc.sa.recv.url=tcp://localhost:61617

This property defines the URL for the message bus over which data is pushed as opposed to polled via the web services host and port above. The same security considerations apply: you may need to change localhost to something more open. Unlike the two properties above, hostname and port are defined in the same property. If you're running more than one Strategy Engine on the same host, you'll need to change 61617 on the second Strategy Engine to a unique value.

metc.sa.recv.logLevel=WARN

This property defines the minimum level of log events to publish remotely. Events with log level less than this will not be published remotely.

metc.sa.client.URL=tcp://dare.marketcetera.com:61616

This property defines the location of DARE to connect to. If DARE is running on a different machine, this value will have to be changed.

metc.sa.client.username=user

This property defines the username as which to connect to DARE.

metc.sa.client.password=password

This property defines the password as which to connect to the order routing system DARE.

metc.sa.client.hostname=dare.marketcetera.com

This property defines the DARE web services host name.

metc.sa.client.port=9000

This property defines the DARE web services port.

metc.sa.client.idPrefix=

This property establishes the optional order ID prefix to attach to all orders from this Strategy Engine.

  • No labels

4 Comments

  1. When running the strategy engine batch file, I get the following error:

    C:\Program Files\Marketcetera\Marketcetera 2.4.1\strategyengine\bin>strategyengi
    ne.bat
    Exception in thread "main" java.lang.UnsupportedClassVersionError: org/marketcet
    era/core/ApplicationContainer : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
    1)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: org.marketcetera.core.ApplicationContainer. Prog
    ram will exit.

    Is there a particular version of java that is required for the marketcetera 2.4.1 that is installed through installer?

    1. 2.4.1 requires Java7. This installer does not provide a version of Java. You are expected to provide and maintain your own version. At a guess, I would say that your default Java version is now Java8. You need to provide a JDK Java7 version and point to that. Easiest way is to modify SetEnv.bat to set JAVA_HOME and PATH to point to a Java7 JDK installation.

  2. Am I correct in assuming that the strategy engine will run only java  code?

    Can Marketcetera support Python, R or any other language? Compiled Code? Or can one think of making it support one's favourite Analytical app (TA) scripting language, so that the strategies that one has prototyped & tested using one's favourite TA app can run unmodified on Marketcetera?

     

     

     

    1. Marketcetera, in its current state, can run strategies in Java and Ruby. We did have an implementation of Python that could be rehydrated if interest is sufficient. We have considered R in the past, and it would be feasible. Pretty much any language that has a JSR223 implementation could be implemented.