AlgoTraderAlgoTrader Documentation

Appendix K. Example Strategy "NLP"

Natural Language Processing, shortened as NLP, is a branch of artificial intelligence that uses the natural language to deal with the interaction between computers and humans.

The purpose of NLP is to read, understand and analyse the human languages to make is valuable.

The idea of the strategy is to receive tweets about the chosen instrument and basing on their average sentiment enter long or short position.

The sentiment is calculated based on Standford CoreNLP library.

The main artifacts needed for the implementation of a new strategy are described in Chapter 4, Strategy Development.

The NLP Strategy consist of the following artifacts:


The strategy service class providing the main methods invoked by the application on certain events.


The service class connects to Twitter and provides tweets.


The service class uses natural language processing to calculate the overall sentiment of a tweet.


Contains parameters used by the strategy (e.g. accountId, securityId, orderQuantity, windowTimeInMinutes, openPositionFactor, closePositionFactor, consumerKey and consumerSecret)


Contains the MySQL database records. Needs to be imported into the database before running the strategy with the MySQL database.

To start the Strategy please see the explanations in Chapter 3, Starting AlgoTrader.

To setup the strategy for back testing and live trading on a development workstation please execute the following steps:

Download the Example Strategies

If you have used the Section 2.1, “Windows Installer” to setup AlgoTrader, this project is already setup in the AlgoTrader IntelliJ IDEA and you can skip this step.

Download the Examples project zip file and unpack it in a directory of your choosing:


user name and password will be provided when signing up for an AlgoTrader license

If you need an older AlgoTrader version, login to our maven repository ( and click on Browse on the left and select code-general.

Then select the AlgoTrader version you want and download:

Import/open the project nlp

To start the strategy in live trading mode on a development workstation please execute the following steps:

Initialize the database

load the db-samples script into the MySQL database: /algotrader-conf/src/main/resources/db-samples/mysql/mysql-data.sql

load the strategy specific script into the MySQL database: /nlp/src/main/resources/mysql/mysql-data.sql

Set the Twitter keys

In, set your Twitter API keys (

Start the Strategy

Use the run configuration below to start the strategy: EmbeddedStrategyStarter-nlp