Tuesday, December 7, 2010

New release: neural networks, cash allocation

3 releases have come and gone since our last update on features. High time to let you know about them.

Access to last open price in strategies

Strategies can now programmatically access the last open price:

This can be used in conjunction with

hasNewOpen() can be especially useful when trying to take decisions only once bars for all instruments have been started. See the Using all open prices in multi-instrument strategiesarticle for details.

Cash allocation

We have introduced a mechanism to tune cash allocation. There are two main steps:
  • Write an ExecutionControl class that define whether to accept orders based on the defined allocations

  • Configure allocations in the strategy annotations

This excerpt based on the HowToControlCashAllocation sample show how it looks like:
@Instruments(futures = CAC_40)
@ExecutionConfig(control = CashControl.class, longAllocation = 50000.0, shortAllocation = 50000.0)
public class CashControlledStrategy extends AbstractStrategy {
public void onClose(Bar bar) {
// take buy or sell decisions

public static class CashControl implements ExecutionControl {
public boolean accept(Order order, Portfolio portfolio) {
boolean longAccepted = portfolio.getLongAllocation() > portfolio.getLongExposition();
boolean shortAccepted = portfolio.getShortAllocation() > portfolio.getShortExposition();

return ((order.getSide() == BUY) && longAccepted) || ((order.getSide() == SELL) && shortAccepted);

In the future, we might provide pre-built cash-management strategies. Those would be a good way of testing the compliance of a strategy with various cash-allocation scenarios. In the meantime, feel free to try with your own.

Neural networks

We have added third-party library Encog, a tool that helps implement neural networks. We first introduced Encog version 2.4.3 but swiftly upgraded to version 2.5. This later version uses JOCL for GPU-based execution. Results are impressive: Encog-based strategies now executed in 1/10th of the time needed in the previous version!

Encog seems like a great way to get started with neural networks. If you have been writing your own with Market Runner in the past, you should check it out. We have a sample called TrendPredictionWithEncog to get you started (as always, remember that you can play with samples immediately with our anonymous login).


There are many more small improvements and fixes. For example, we have started to provide quotes information, though that still needs to be rolled out on all our market data. Check out the release notes for version 1.9, version 1.9.1, and version 2.0 for more.

No comments:

Post a Comment