TradingStrategies
Class TradingStrategy

java.lang.Object
  extended byTradingStrategies.TradingStrategy
Direct Known Subclasses:
StrategyAverageDown, StrategyBuyAndHold, StrategyDeltaHedging, StrategyDollarCostAverage, StrategyDoubleOrNothing

public abstract class TradingStrategy
extends java.lang.Object

A trading strategy investing in only one asset. Provides methods to compute the following statistics associated with the trading strategy:

conveniently assembled into a random vector for easy analyisis of the mean, the variance and the empirical distribution (histogram). All quantities except the number of trades are discounted amounts computed at the time horizon T.

It is assumed that the entire strategy is financed through borrowings at the riskfree rate. Thus current (disounted) borrowings are equal to the (discounted) amount invested at all times.

Transaction costs are allowed and have a fixed and a proportional component. The proportional transaction costs come from bid-ask spread etc., 0.1 is a very conservative number. Transaction costs are assumed to grow at the riskfree rate (to remain constant in todays dollars).

Note that the computation of the portfolio weight (the number of shares of the asset held at any given time) might involve conditional expectations which necessitate branch simulations of the price path of the asset.

Each branch simulation destroys an existing price path of the asset from the time of branching forward. Consequently we cannot simply compute a full path of the asset and then move the trading strategy along this path. Instead we evolve the path simultaneous with the trading strategy in single time steps.

These time steps are driven by new Z-increments (see the class Market.Asset) and consequently produce independent asset price paths (rather than independent groups of dependent paths).


Constructor Summary
TradingStrategy(double fixed_trc, double prop_trc, Asset asset, Trigger tradeTrigger)
          Constructor, full initialization.
TradingStrategy(double fixed_trc, double prop_trc, Asset asset, Trigger tradeTrigger, int currentWeightNotInitialized)
          Constructor, initializes all fields except currentWeight
 
Method Summary
 RandomVector discountedGainsAndNumberOfTrades()
          The newDiscountedGainsAndNumberOfTrades() as a random vector.
 RandomVariable discountedGainsFromTrading()
          The terminal discounted gains from trading as a random variable.
 Asset get_asset()
          The asset invested in.
 double[] get_B()
          Price path of riskfree bond.
 double get_currentWeight()
          Current number of shares of the asset held.
 double get_dt()
          Size of time step.
 double get_fixed_trc()
          Fixed transaction cost per trade.
 int get_nTrades()
          Current number of trades.
 double get_prop_trc()
          Proportional transaction cost per trade.
 double[] get_S()
          Discounted asset price path.
 int get_T()
          Number of time steps to horizon.
 Trigger get_tradeTrigger()
          Trigger triggering the trades.
 double initialInvestment()
          Amount invested at time t=0.
 double[] newDiscountedGainsAndNumberOfTrades()
          The discounted gains from trading (return_value[0]) and number of trades (return_value[1]) at the time horizon T computed from a new and independent asset price path.
 double newDiscountedGainsFromTrading()
          The discounted gains from trading at the time horizon T computed from a new and independent asset price path.
 double newReturnFromTrading()
          The return from trading at the time horizon T computed from a new and independent asset price path.
 double[] newTradeStatistics()
          Computes a vector x of statistics associated with the trading strategy:
abstract  double newWeight(int t)
          The new weight of the asset given that a trade takes place at time t (ie.
 RandomVariable returnsFromTrading()
          The terminal returns from trading as a random variable.
 RandomVector tradeStatistics()
          The newTradeStatistics() as a random vector X:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TradingStrategy

public TradingStrategy(double fixed_trc,
                       double prop_trc,
                       Asset asset,
                       Trigger tradeTrigger)

Constructor, full initialization.

Parameters:
fixed_trc - fixed transaction costs.
prop_trc - proportional transaction costs.
asset - the asset invested in.
tradeTrigger - triggers the trades.

TradingStrategy

public TradingStrategy(double fixed_trc,
                       double prop_trc,
                       Asset asset,
                       Trigger tradeTrigger,
                       int currentWeightNotInitialized)

Constructor, initializes all fields except currentWeight

Needed because the call currentWeight=newWeight(0); might make use of fields of a subclass which are not initialized yet. In this case this call is then made in the subclass constructor after the needed fields have been initialized. The variable currentWeightNotInitialized is a dummy parameter used only to differentiate the parameter signatures of the two constructors, assign any value.

Parameters:
fixed_trc - fixed transaction costs.
prop_trc - proportional transaction costs.
asset - the asset invested in.
tradeTrigger - triggers the trades.
currentWeightNotInitialized - dummy parameter, assign any value.
Method Detail

get_T

public int get_T()
Number of time steps to horizon.


get_dt

public double get_dt()
Size of time step.


get_S

public double[] get_S()
Discounted asset price path.


get_B

public double[] get_B()
Price path of riskfree bond.


get_fixed_trc

public double get_fixed_trc()
Fixed transaction cost per trade.


get_prop_trc

public double get_prop_trc()
Proportional transaction cost per trade.


get_asset

public Asset get_asset()
The asset invested in.


get_tradeTrigger

public Trigger get_tradeTrigger()
Trigger triggering the trades.


get_currentWeight

public double get_currentWeight()
Current number of shares of the asset held.


get_nTrades

public int get_nTrades()
Current number of trades.


newWeight

public abstract double newWeight(int t)

The new weight of the asset given that a trade takes place at time t (ie. the portfolio is rebalanced at time t).

If no trade takes place at time t the weight of the asset is in the member variable currentWeight. This variable is kept up to date to allow reference to the last weight in the computation of the next weight newWeight(t) at time t (eg "doubling up", "selling half" etc.).

Parameters:
t - current time.

initialInvestment

public double initialInvestment()
Amount invested at time t=0.


newDiscountedGainsFromTrading

public double newDiscountedGainsFromTrading()

The discounted gains from trading at the time horizon T computed from a new and independent asset price path.

The variable currentWeight is updated without being used explicitly. This is done to allow the definition of strategies where the next weight is defined with reference to the last weight.


discountedGainsFromTrading

public RandomVariable discountedGainsFromTrading()

The terminal discounted gains from trading as a random variable.

Warning: The time parameter t is ignored, that is, there is no possibility to condition on information available at time t. Useful only for computations at time t=0.

It is slightly more complicated to implement this ability since the computation of the portfolio weights destroys an existing path so that the current path would have to be saved up to time t. We don't need the ability to condition and so it is not implemented.


newDiscountedGainsAndNumberOfTrades

public double[] newDiscountedGainsAndNumberOfTrades()

The discounted gains from trading (return_value[0]) and number of trades (return_value[1]) at the time horizon T computed from a new and independent asset price path.

The variable currentWeight is updated without being used explicitly. This is done to allow the definition of strategies where the next weight is defined with reference to the last weight.


discountedGainsAndNumberOfTrades

public RandomVector discountedGainsAndNumberOfTrades()

The newDiscountedGainsAndNumberOfTrades() as a random vector.

Warning: The time parameter t is ignored, that is, there is no possibility to condition on information available at time t. Useful only for computations at time t=0.

It is slightly more complicated to implement this ability since the computation of the portfolio weights destroys an existing path so that the current path would have to be saved up to time t. We don't need the ability to condition and so it is not implemented.


newReturnFromTrading

public double newReturnFromTrading()

The return from trading at the time horizon T computed from a new and independent asset price path.

Return: The return of a trading stratregy is computed as a return on the maximum invested during the life of the strategy: the gains from trading are viewed as interest on the maximum amount sunk into the strategy during its lifetime.

The variable currentWeight is updated without being used explicitly. This is done to allow the definition of strategies where the next weight is defined with reference to the last weight.


returnsFromTrading

public RandomVariable returnsFromTrading()

The terminal returns from trading as a random variable. See information.


newTradeStatistics

public double[] newTradeStatistics()

Computes a vector x of statistics associated with the trading strategy:

during the life of the strategy. All quantities are discounted and derived from a new and independent path of the asset computed in this method.

Note: the variable currentWeight must be kept up to date at all times since the method newWeight(int t) might make use of it.


tradeStatistics

public RandomVector tradeStatistics()

The newTradeStatistics() as a random vector X:

during the life of the strategy. Note that the time parameter t is ignored, that is, no ability to condition on information available at time t is implemented. Useful only for computations at time t=0.