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

7 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.

  3. Hi Community,


    Im getting following error when I run startegyEngine.bat :



    C:\Windows\system32>C:\Marketcetera\Marketcetera-3.0.12\strategyengine\bin\strat
    egyengine.bat
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; sup
    port was removed in 8.0
    2018-01-14 11:30:35,861 INFO [main] ? (:) - Strategy Engine version '3.0.12' (b
    uild 743 17592 20180114T060033144Z)
    2018-01-14 11:30:41,232 ERROR [main] ? (:) - Unable to initialize application be
    cause of error: 'Unable to create the client module because the underlying clien
    t initialization failed. Look at the underlying cause for more details on the er
    ror. (Unable to connect to the server using the URL 'tcp://dare.marketcetera.com
    :61616', user name 'sujay', host name 'dare.marketcetera.com' and port number '9
    ,000'. Ensure that you have provided correct URL, user name, host name, port num
    ber and password to connect to the server and retry operation. (Remote exceptio
    n; see cause for details))'. Exiting...
    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'sa' defined in URL [file:C:/Marketcetera/Marketcetera-3.0.12/strategyeng
    ine/conf/sa/strategyengine.xml]: Invocation of init method failed; nested except
    ion is java.lang.RuntimeException: org.marketcetera.module.ModuleCreationExcepti
    on: Unable to create the client module because the underlying client initializat
    ion failed. Look at the underlying cause for more details on the error.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
    ject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
    an(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finish
    BeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refres
    h(AbstractApplicationContext.java:542)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<
    init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<
    init>(FileSystemXmlApplicationContext.java:106)
    at org.marketcetera.core.ApplicationContainer.generateContext(Applicatio
    nContainer.java:287)
    at org.marketcetera.core.ApplicationContainer.start(ApplicationContainer
    .java:216)
    at org.marketcetera.core.ApplicationContainer.main(ApplicationContainer.
    java:98)
    Caused by: java.lang.RuntimeException: org.marketcetera.module.ModuleCreationExc
    eption: Unable to create the client module because the underlying client initial
    ization failed. Look at the underlying cause for more details on the error.
    at org.marketcetera.strategyagent.StrategyAgent.start(StrategyAgent.java
    :243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1758)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1695)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 14 more
    Caused by: org.marketcetera.module.ModuleCreationException: Unable to create the
    client module because the underlying client initialization failed. Look at the
    underlying cause for more details on the error.
    at org.marketcetera.client.ClientModuleFactory.create(ClientModuleFactor
    y.java:49)
    at org.marketcetera.module.ModuleManager.createModule(ModuleManager.java
    :1931)
    at org.marketcetera.module.ModuleManager.initialize(ModuleManager.java:1
    718)
    at org.marketcetera.module.ModuleManager.init(ModuleManager.java:555)
    at org.marketcetera.strategyagent.StrategyAgent.init(StrategyAgent.java:
    335)
    at org.marketcetera.strategyagent.StrategyAgent.start(StrategyAgent.java
    :236)
    ... 21 more
    Caused by: org.marketcetera.client.ConnectionException: Unable to connect to the
    server using the URL 'tcp://dare.marketcetera.com:61616', user name 'sujay', ho
    st name 'dare.marketcetera.com' and port number '9,000'. Ensure that you have pr
    ovided correct URL, user name, host name, port number and password to connect to
    the server and retry operation.
    at org.marketcetera.client.ClientImpl.connect(ClientImpl.java:1102)
    at org.marketcetera.client.ClientImpl.<init>(ClientImpl.java:650)
    at org.marketcetera.client.ClientManager$1.getClient(ClientManager.java:
    199)
    at org.marketcetera.client.ClientManager.init(ClientManager.java:87)
    at org.marketcetera.client.ClientModuleFactory.create(ClientModuleFactor
    y.java:47)
    ... 26 more
    Caused by: org.marketcetera.util.ws.wrappers.RemoteException: Remote exception;
    see cause for details
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshallException(JAXBEncode
    rDecoder.java:521)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.
    java:665)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:179)
    at org.apache.cxf.interceptor.ClientFaultConverter.processFaultDetail(Cl
    ientFaultConverter.java:155)
    at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientF
    aultConverter.java:82)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
    orChain.java:308)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
    age(AbstractFaultChainInitiatorObserver.java:112)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleM
    essage(CheckFaultInterceptor.java:69)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleM
    essage(CheckFaultInterceptor.java:34)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
    orChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:801)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleR
    esponseInternal(HTTPConduit.java:1680)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleR
    esponse(HTTPConduit.java:1559)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(H
    TTPConduit.java:1356)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:5
    6)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:653)

    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndi
    ngInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
    orChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:13
    9)
    at com.sun.proxy.$Proxy78.login(Unknown Source)
    at org.marketcetera.util.ws.stateful.Client.login(Client.java:171)
    at org.marketcetera.client.ClientImpl.connectWebServices(ClientImpl.java
    :933)
    at org.marketcetera.client.ClientImpl.connect(ClientImpl.java:1075)
    ... 30 more
    Caused by: org.marketcetera.util.except.I18NException: Login credentials were re
    jected
    at org.marketcetera.util.ws.stateful.AuthServiceImpl.loginImpl(AuthServi
    ceImpl.java:85)
    at org.marketcetera.util.ws.stateful.AuthServiceImpl.access$000(AuthServ
    iceImpl.java:22)
    at org.marketcetera.util.ws.stateful.AuthServiceImpl$1.call(AuthServiceI
    mpl.java:126)
    at org.marketcetera.util.ws.stateful.AuthServiceImpl$1.call(AuthServiceI
    mpl.java:120)
    at org.marketcetera.util.ws.stateless.StatelessRemoteCaller.execute(Stat
    elessRemoteCaller.java:81)
    at org.marketcetera.util.ws.stateful.AuthServiceImpl.login(AuthServiceIm
    pl.java:120)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(Abst
    ractInvoker.java:180)
    at org.apache.cxf.jaxws.JAXWSMethodInvoker.performInvocation(JAXWSMethod
    Invoker.java:66)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
    .java:96)
    at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSM
    ethodInvoker.java:232)
    at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.jav
    a:85)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
    .java:74)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
    okerInterceptor.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
    1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInv
    okerInterceptor.java:126)
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecu
    tor.java:37)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
    rviceInvokerInterceptor.java:131)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
    orChain.java:308)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
    ationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
    HTTPDestination.java:262)
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(Je
    ttyHTTPDestination.java:234)
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTP
    Handler.java:76)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
    er.java:1129)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
    r.java:1065)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
    ava:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Cont
    extHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
    .java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:499)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
    a:258)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
    :544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
    l.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
    .java:555)
    at java.lang.Thread.run(Thread.java:748)




    Please help me out.


    Regards,

    Sujay

    1. Is this still a problem for you? I see this in the DARE log:

      14 Jan 2018 07:21:46,664  INFO [ActiveMQ Transport: tcp://x.x.x.x:56171@9600] ors.security.ORSLoginModule (:) - User 'sujayh1988' successfully logged in.
      
      
      1. Colin its no more an issue. Thanks!!.. I had given wrong user name