Strategies

A trading strategy in Cyan Spring ATS is composed of two parts Subject to the functionality and usage, Cyan Spring supports three types of strategies in its framework. Details are as below.


Multi-instrument Strategy

What is

A Multi-instrument strategies involves in trading multiple instruments which may or may not be correlated. They can trade bi-direction (buy and sell). The goal is to make profit with means of "buy low and sell high", through taking position and flatting position at the right price and right time.

Who are interested in

Hedge funds, proprietary trading business in i-bank and individual traders - whoever believe they have some winning strategies...

Parameters
Multi-instrument strategy parameters are organised in
  • Strategy level parameters - only one set of parameters per strategy
  • Instrument level parameters - one set per instrument. Depends on how many instruments traded by strategy, strategy can have multiple sets of instrument level parameters
Example: Dollar Neutral

Dollar Neutral Strategy trades with two groups of instruments which prices are correlated. We start with Pair Trading Strategy, the simpliest form of Dollar Neutral Strategy.

To describe the idea behind this strategy, we pick a pair of instruments that are correlated(or at least you believe so!). Some examples are:
  • A stock dual-listed in different exchanges
  • A stock holds some large share of another stock
  • An option and its underlying stock

We call these two instruments as leg 1 and leg 2 respectively. We calculate the average price of leg1 instrument as AP1 and average price of leg2 instrument as AP2 over certain period from the historical data captured.

We define a factor called Average Ratio as below:

AR = AP1/AP2

We capture real time market price of both legs as MP1 and MP2, and define a factor called Market Ratio as below:

MR = MP1/MP2

The following is the idea of how we make profit:
  • When MR > AP1, we short leg1 and long leg2. If what we believe turns out right, MR will go back down eventually, and we will flat the position to take profit
  • When MR < AP1, we long leg1 and short leg2. If what we believe turns out right, MR will go back up eventually, and we will flat the position to take profit

When we take position, we take the short side and the long side in the same dollar value - hence dollar neutral. The merit of dollar neutral strategy is immune to market risk in theory. The risk lies at whether the stocks prices are really correlated.

As a super set to Pairs strategy, Dollar Neutral Strategy allows more than one instrument per leg. The following are strategy parameters for Dollar Neutral Strategy

Strategy level parameters
  • Value
  • High stop
  • High take
  • High flat
  • Low flat
  • Low take
  • Low stop
Instrument level parameters
  • Symbol
  • Leg
  • Weight
  • Ref price
  • Value(calculated)
  • Ref qty(calculated)
Value parameter at instrument level is calculated as

instrument.Value = instrument.Weight / sum(instrument.Weight) * strategy.Value

Ref qty parameter at instrument level is calculated as

instrument.Ref qty = instrument.value / instrument.Ref price

Assuming instrument.Price is the current price for a instrument in our strategy, the current market factor MF is defined as

MF = (Strategy.Value - SUM(instrument.Price * instrument.Ref qty)) / Value

The strategy logic goes like this
  • When there is no position
    • if MF > strategy.High take, short leg1 and long leg2
    • if MF < strategy.Low take, long leg1 and short leg2
  • When posistion is taken
    • if MF > strategy.High stop, flat position, cut loss
    • if MF < strategy.High flat, flat position, take profit
    • if MF < strategy.Low stop, flat position, cut loss
    • if MF > strategy.Low flat, flat position, take profit
From the above logic, you can figure out we should difine the strategy parameters as following

High stop > High take > High flat > Low flat > Low take > Low stop

For software implementation, please refer to classes in package com.cyanspring.strategy.multiinstrument.dollarneutral. Here is a xml dump of a Dollar Neutral Strategy parameters:

<com.cyanspring.common.event.strategy.NewMultiInstrumentStrategyEvent>
  <priority>NORMAL</priority>
  <txId>20120626-130244-297-0505T</txId>
  <strategy>
    <entry>
      <string>Low stop</string>
      <string>-0.05</string>
    </entry>
    <entry>
      <string>High stop</string>
      <string>0.05</string>
    </entry>
    <entry>
      <string>Value</string>
      <string>50000</string>
    </entry>
    <entry>
      <string>Low flat</string>
      <string>-0.01</string>
    </entry>
    <entry>
      <string>High flat</string>
      <string>0.01</string>
    </entry>
    <entry>
      <string>High take</string>
      <string>0.02</string>
    </entry>
    <entry>
      <string>Strategy</string>
      <string>DOLLAR_NEUTRAL</string>
    </entry>
    <entry>
      <string>Low take</string>
      <string>-0.02</string>
    </entry>
    <entry>
      <string>Allow diff</string>
      <string>100</string>
    </entry>
  </strategy>
  <instruments>
    <map>
      <entry>
        <string>Leg</string>
        <string>1</string>
      </entry>
      <entry>
        <string>Weight</string>
        <string>1</string>
      </entry>
      <entry>
        <string>Ref price</string>
        <string>55</string>
      </entry>
      <entry>
        <string>Symbol</string>
        <string>RIO.AX</string>
      </entry>
    </map>
    <map>
      <entry>
        <string>Leg</string>
        <string>1</string>
      </entry>
      <entry>
        <string>Weight</string>
        <string>2</string>
      </entry>
      <entry>
        <string>Ref price</string>
        <string>20.5</string>
      </entry>
      <entry>
        <string>Symbol</string>
        <string>WBC.AX</string>
      </entry>
    </map>
    <map>
      <entry>
        <string>Leg</string>
        <string>2</string>
      </entry>
      <entry>
        <string>Weight</string>
        <string>1</string>
      </entry>
      <entry>
        <string>Ref price</string>
        <string>37</string>
      </entry>
      <entry>
        <string>Symbol</string>
        <string>BHP.AX</string>
      </entry>
    </map>
    <map>
      <entry>
        <string>Leg</string>
        <string>2</string>
      </entry>
      <entry>
        <string>Weight</string>
        <string>2</string>
      </entry>
      <entry>
        <string>Ref price</string>
        <string>21.6</string>
      </entry>
      <entry>
        <string>Symbol</string>
        <string>ANZ.AX</string>
      </entry>
    </map>
  </instruments>
</com.cyanspring.common.event.strategy.NewMultiInstrumentStrategyEvent>