```java.lang.Object TradingStrategies.VectorStrategy
```
Direct Known Subclasses:
VectorStrategyDeltaHedging

public abstract class VectorStrategy
extends java.lang.Object

A trading strategy investing in a `Basket` (vector of baskets). Provides methods to compute the following statistics associated with the trading strategy:

• the maximum amount invested
• the maximum drawdown
• the total amount invested into the strategy at time T
• the return on investment
• total transaction costs

conveniently assembled into a random vector for easy analysis 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 basket held at any given time) might involve conditional expectations which necessitate branch simulations of the price path of the basket.

Each branch simulation destroys an existing price path of the basket from the time of branching forward. Consequently we cannot simply compute a full path of the basket 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.basket`) and consequently produce independent basket price paths (rather than independent groups of dependent paths).

 Constructor Summary ```VectorStrategy(double fixed_trc, double prop_trc, Basket basket, Trigger tradeTrigger)```           Constructor, full initialization. ```VectorStrategy(double fixed_trc, double prop_trc, Basket basket, 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. ` double[]` `get_B()`           Price path of riskfree bond. ` Basket` `get_basket()`           The basket invested in. ` ColtVector` `get_currentWeight()`           Current number of shares of the basket 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. ` ColtVector[]` `get_S()`           Discounted basket 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) and number of trades (return_value) at the time horizon T computed from a new and independent basket price path. ` double` `newDiscountedGainsFromTrading()`           The discounted gains from trading at the time horizon T computed from a new and independent basket price path. ` double` `newReturnFromTrading()`           The return from trading at the time horizon T computed from a new and independent basket price path. ` double[]` `newTradeStatistics()`           Computes a vector x of statistics associated with the trading strategy: ` RandomVariable` `returnsFromTrading()`           The terminal returns from trading as a random variable. `abstract  void` `setNewWeight(int t)`           Write the vector of portfolio weights at time t into the field `newWeight`. ` 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

### VectorStrategy

```public VectorStrategy(double fixed_trc,
double prop_trc,

Constructor, full initialization.

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

### VectorStrategy

```public VectorStrategy(double fixed_trc,
double prop_trc,
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.
`basket` - the basket 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 ColtVector[] get_S()`

### get_B

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

### get_fixed_trc

`public double get_fixed_trc()`

### get_prop_trc

`public double get_prop_trc()`

`public Basket get_basket()`

`public Trigger get_tradeTrigger()`

### get_currentWeight

`public ColtVector get_currentWeight()`
Current number of shares of the basket held.

`public int get_nTrades()`

### setNewWeight

`public abstract void setNewWeight(int t)`

Write the vector of portfolio weights at time t into the field `newWeight`. Do this whenever a trade takes place, that is, the portfolio is rebalanced. The field `currentWeight` contains the vector of current portfolio weights.

Parameters:
`t` - current time.

### initialInvestment

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

`public double newDiscountedGainsFromTrading()`

The discounted gains from trading at the time horizon T computed from a new and independent basket 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.

`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.

`public double[] newDiscountedGainsAndNumberOfTrades()`

The discounted gains from trading (return_value) and number of trades (return_value) at the time horizon T computed from a new and independent basket 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.

`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.

`public double newReturnFromTrading()`

The return from trading at the time horizon T computed from a new and independent basket 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.

`public RandomVariable returnsFromTrading()`

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

`public double[] newTradeStatistics()`

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

• x=maximum amount invested
• x=maximum drawdown
• x=annualized return on investment (compounded continuously)
• x=total transaction costs

during the life of the strategy. All quantities are discounted and derived from a new and independent path of the basket 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.

`public RandomVector tradeStatistics()`
The `newTradeStatistics()` as a random vector X: