OptimalLeverage: Optimal Leverage

Description Usage Arguments Details Author(s) References Examples

Description

Tools for calculating optimal leverage.

Usage

1
2
3
4
OptimalF(payoffs, prob=NULL, by=.01)
Kelly(odds, prob)
GambleGrowth(payoffs, f, prob=NULL)
GambleGrowthBin(odds, prob, f=Kelly(odds, prob))

Arguments

payoffs

vector of gamble payouts.

odds

odds expressed as a ratio of win/loss.

prob

probability of a win.

by

resolution of "optimal f" solution.

f

fixed fraction of capital as value between 0 and 1.

Details

Constant equity fraction trade sizing starts from the premise that we are playing a gamble with a positive expectation–an "edge"–and that our goal is to maximise geometric mean returns on that gamble (which is the same thing as maximising terminal wealth).

In the 1950's John Kelly proved that for a binary gamble geometric growth is maximised when the equity fraction f equals the quantity k, defined in words as "edge over odds", in algebra as

k = (pw - 1) / (w - 1)

where w = b + 1, your winning payout (odds plus your initial stake). The growth function of such a gamble is

G(f) = (1 - f + fw)^p (1 - f)^(1-p) - 1

Kelly proved that this function is maximised when G(f=k).

Kelly computes k and GambleGrowthBin computes G for a binary gamble.

When payouts are not binary (as in trading) we need a more general solution. One method is to specify a probability distribution. The growth function is then:

G(f) = prod([1 + f(-xi / min(x1, x2, ..., xn))]^pi)

where xi is the i-th payoff and pi is its probability, where p1 + p2 + ... + pn. In other words, the term gives a return for each gamble i on the assumption that the largest loss is f percent of equity. Instead of a discrete probability distribution we could simulate x_{i} from some process (or take them from historical data). When this is desired set prob=NULL and p_{i} will equal 1/n.

The generalised analog to kelly has been dubbed "optimal f", which we solve by calculating G(f) for a sequence of f's between 0 and 1 and taking the maximum. by specifies the resolution of this iteration.

Author(s)

Robert Sams robert@sanctumfi.com

References

"A New Interpretation of the Information Rate", J.L. Kelly, Jr., AT&T Bell Labs Journal, July 1956

The Mathematics of Money Management, Ralph Vince, 1992, John Wiley & Sons, Inc.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(stats)

## Optimal F limits to Kelly in the binomial case
binomial.simulation <- function(x){
  payoffs <- rbinom(x, 1, .5) * 2
  payoffs[which(payoffs == 0)] <- -1
  OptimalF(payoffs)
}
summary(sapply(rep(1000, 100), binomial.simulation))
Kelly(2, .5)

## Reconciles with Vince p.33
payoffs <- c(9,18,7,1,10,-5,-3,-17,-7)
OptimalF(payoffs)
GambleGrowth(payoffs, c(.16,.24))^9

tradesys documentation built on May 2, 2019, 4:53 p.m.