Strategy development tools

Empirica DevTools installation package features pre-configured Integrated Development Environment (IDE) with sample projects and Empirica API documentation. IDE consists of a basic version of Eclipse and Java Development Kit (JDK). Eclipse is an extensible, widely used and freely available development platform. It features community support, detailed help and variety of training materials hosted by Eclipse foundation. JDK is provided and supported by Oracle, it is required by Eclipse for compiling source code into *.jar files.

API documentation can be browsed inside Eclipse by opening “index.html” file located in _resources project (javadoc/empirica-api-[version]). Description of classes and functions is also available inside Eclipse Java editor (ctrl + space). When creating new project, api libraries and java-docs have to be linked manually in project properties.

Installation

Install DevTools by running EmpiricaDevTools-[version].msi and following the instructions. Successful installation results in creating a desktop shortcut and installation folder in selected directory.

Installation folder contains following directories:

eclipse Configured to use provided JDK and linked by default with provided workspace. Contains eclipse.exe used to launch new Eclipse instance.
JDK Ordinary JDK 1.8 installation, it can be replaced with any other installation of the JDK of the same version.
workspace Eclipse workspace containing sample projects. Workspace is not directly connected with provided Eclipse installation, and can be used with any other Eclipse instance.

Pre-configured workspace contains three projects:

_resources Contains resources that are referenced in other projects.
strategies-custom Strategy project. Serves as template and starting point for developing custom strategies.
strategies-example Strategy project. Contains sources of example strategies that are used in TradePad application, along with demo strategies that demonstrate individual features of strategy platform.

Strategy projects share common structure:

Sample project structure
bin Working directory that contains compiled *.java files. Directory is specific to Eclipse and can be safely ignored.
dist Suggested output directory for strategy *.jar files configured inside “make.jardesc” file.
lib Suggested directory for storing Empirica API *.jar files and other libraries which are required for compilation of strategy *.jar files. Presence of libraries inside such folder is not sufficient, they also need to be added to Java Build Path in project properties.
src Contains *.java strategy source files. Source file tree can have many classes that extend “com.empirica.api.strategy.Strategy” class, and each one of them is defining individual strategy.
  Jar creation short-cut “make.jardesc” that contains configuration of *.jar export wizard form. It can be modified at double click or launched by selecting “Create JAR” from context menu.
Configuration files ”.classpath” and ”.project” are specific to Eclipse and are not intended to be directly modified.

Strategies first have to be compiled into *.jar files, ten they can be deployed into Strategy Executor and accessed from TradePad.

Once given strategy file is deployed by the user, it’s available for creating any number of new instances. Users can safely overwrite *.jar files by redeploying strategy *.jar files of the same name and which may contain same or modified content. User Strategy file must have size less than 10MB and have *.jar file extension.

Warning

It is unadvised to undeploy a JAR archive containing strategy that is currently running, and JAR archives containing external libraries for, or strategies subservient to, the currently running strategies. Doing so will result in a java.lang.NoClassDefFoundError when attempting to create new instances of strategies dependent on those undeployed classes.

Sample strategy JAR deployment & undeployment work-flow:

  1. Deploy archive 1.1.jar containing strategy A version 1.1,
  2. Run strategy A version 1.1,
  3. Develop new, better version of strategy A version 1.2,
  4. Save improved strategy A version 1.2 in archive 1.2.jar,
  5. Stop strategy A version 1.1,
  6. Undeploy archive 1.1.jar,
  7. Deploy archive 1.2.jar,
  8. Run strategy A version 1.2.

Deployment steps

Each user strategy must be deployed in TradePad in order to be tested or used in live mode.

Following steps describe how to compile, deploy and run simple strategy.

  • In DevTools create strategies-custom.jar file by right-clicking at proper make.jardesc file and choosing “Create JAR” from context menu.
  • In TradePad open “User Strategies” frame and deploy created *.jar file by clicking on “Deploy archive...” button and selecting file located in DevTools workspace at strategies-custom/dist directory.
  • Deployed JAR files must conform to the set of rules, determining dependencies that can be legally used in imported *.jar files. Rules can follow two approaches: * All dependencies are forbidden with exceptions of classes that can be safely used on server side. This approach can be recognized when classifier of all classes (asterisk - *) is present on list of forbidden dependencies. * All dependencies are allowed with exception of classes that are considered not safe. Analogically, classifier of all classes is present on list of allowed dependencies.
Strategies' import rules
  • It is possible to deploy library JAR files that do not contain any strategy implementations and use deployed JARs as dependencies in strategies. Those files are confronted against the set of allowed dependencies as well.
  • In some cases deployment of strategy *.jar file may not succeed. Possible reasons are: File is too big, file contains classes that duplicate ones that are already deployed, *.jar file is compiled with JDK other than 1.8 or classes used in strategy implementation do not comply with security policy rules. You can view the list of prohibited packages/classes by clicking “Show security policy” link.
Empty User Strategies frame
  • After strategy has been successfully deployed, open strategy frame by double clicking strategy class name or right-clicking on deployed strategy name and selecting “Open strategy frame” from context menu.
User Strategies frame with a deployed strategy
  • In opened strategy frame, click on “Start” to start a new instance of strategy. Select “Logger” tab to verify if strategy instance has been started successfully.
Creating new instance of a strategy
  • After verifying strategy instance successful creation, stop it by clicking on “Stop” button.
Stopping a strategy's instance