[R-SIG-Finance] Mathematical Expectation for a trading system

Mark Knecht markknecht at gmail.com
Wed Oct 14 15:31:03 CEST 2009


On Wed, Oct 14, 2009 at 1:39 AM, Mark Breman <breman.mark at gmail.com> wrote:
> Hello,
> In "The mathematics of money management" by Ralph Vince there is a formula
> for calculating the Mathematical Expectation of a game (in R pseudo code):
>
> ME  =  for(i in 1:N) { Pi * Ai}
>
> where
> P = Probability of winning or losing
> A = Amount won or lost
> N = Number of possible outcomes.
>
> Or in text: "Mathematical expectation is the amount you expect to make or
> lose, on average, each bet".
>
> Now suppose I want to know the Mathematical expectation of a trading system.
>
> I have a series of trade returns:
>
>> trades$PnL
>  [1]  -5.75  10.00  -1.25  96.00 -16.00 -35.00  29.00 -18.25  -2.25 -10.25
> -21.75  -5.50   8.50 -20.50  -6.00  14.25  18.00
> [18]   3.75  -4.25  24.00  17.75  -9.50  11.25 -33.75   6.25 -28.00   1.00
>  36.75  14.00 -30.75  -0.50   6.75  19.25   5.25
> [35] -10.00 -23.25   9.25  11.00 -33.00 -19.00 -17.50  -5.50  -5.75  -8.50
> -24.50 -24.00   2.25  -1.00   0.75  -1.75  -2.25
> [52]   9.25  15.00  -2.25  -6.75   5.25  -4.75 -10.00  -2.00  63.50 -18.00
> -18.00  58.00  -8.75   1.00 -36.75 -23.50 -64.00
> [69] -15.75 -10.00 -34.75  27.75 -57.00 204.75 -45.00 -71.00 133.75
>
> So I have A = trades$PnL and N=77, but how do I calculate P?
>
> -Mark-

Hi Mark,
   The simple answer would be:

1) Look at all the data you have today. How many trades won? How many
trades total? P = Total wins/ total trades

2) Start trading. After some fixed number of trades - say 30 more
trades - how did the win/loss ratio compare?

   Don't think only of the probability, but also how much does the
probability vary? I have systems that trade 4000 times in 6 months. I
constantly track win/loss ratios as a rolling calculation just to
watch how the system might be doing in a new market type. My system
might have a probability of winning 82% of the time over 4000 trades
but goes up and down by 5% when looking at any 100 consecutive trades.
(So 77%-87% wins) I consider that 'normal'. If it gets outside of 5% I
might stop trading it until it's back in the 'normal' range.

   Note that I do this also for what you call 'A' since the product
represents the potential for making money if everything works out
'normally'. ;-)

HTH,
Mark



More information about the R-SIG-Finance mailing list