Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the max product of numbers

Status
Not open for further replies.

alh1002

Technical User
Mar 27, 2006
41
US
I have a column of dates and monthly percentages. To find the maximum drawdown I would (in excel) make another column of numbers which is the running total of percentages and then I would locate anywhere the running total goes down. The largest drawdown would be measured from running total down, and I would look at the largest spread.

Example

if the string of percentages (note: 1% = 1.01, -1%=0.99)

1.01
.95
.99
1.02
.91

so in this string of dates it up, down, down, up, down

the drawdown would 12.8 %, because the running total is seen in second column, never gets back to 1.01.
1.01 1.01
0.95 0.9595
0.99 0.949905
1.02 0.9689031
0.91 0.881701821

And the difference between 1.01 and .8817 is ~.128 or 12.8 %

I am using the following code to find maximum consecutive months down, but that is different than this, as the 1.02 would reset it

Private Sub Calculate()

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblDrawdowns")
MinProd = 1
CrtProd = 1
While Not rs.EOF
If Nz(rs!cc_rt, 1) >= 1 Then
If CrtProd <> 1 Then
If MinProd > CrtProd Then MinProd = CrtProd
End If
CrtProd = 1
Else
CrtProd = CrtProd * rs!cc_rt
End If
rs.MoveNext
Wend

If CrtProd <> 1 Then
If MinProd > CrtProd Then MinProd = CrtProd
End If

Debug.Print (MinProd - 1) * 100

End Sub

 
actually reading thru this what I really want is once in a drawdown start multipling the months together and find the max negative %, so the drawdown would be 0.8729721
which is just the percent changes of the last 4 together. In this case the numbers are similar but I was looking and when I get farther away from 1 the use of differences makes no sense

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top