I missed the earlier part of the thread, and aren't sure why you're looking 
at VB code, though hopefully you're trying to port it to Lingo (otherwise, 
why be here? :)

I'll try to help as best as I can.  I first used BASIC in 1976 (!), though 
I eventually stopped using it as a primary language about 5 to 10 years 
later.  I don't recall there being negative indexes at the time, but I'm 
not surprised if there are now, so we'll assume it's okay.

Here's my dissection:

>---segment code of the VB program
>
>  ReDim v(-n To n) As Double    ' option price
>  ReDim s(-n To n) As Double    ' stock price

This is making two arrays of double's, meaning floating point 
variables.  If they're just stock prices I think they could just be listed 
as float or real or whatever it is nowadays, unless double is the only 
thing they offer... at any rate, the important thing is that the array runs 
from -n to n, whatever n is.  For the purposes of this discussion, let's 
say that n=10.  Therefore, the range of acceptable values is [-10..10] for 
indexes.  The variables themselves hold floating point values, so s[-8] 
could be equal to 4.302103.

Lingo does not have a concept of a negative index, so you will have to 
compensate, either via property lists populated with props that range from 
-n to n, or via a linear list with 1..(n*2)+1 entries, using n+1 as the 
center point (0).

>  --this is the part where the problem starts
>
>  s(0) = spot

This establishes the baseline for whatever they're doing.  I don't know 
what value spot is, perhaps the 'spot' price of the stock.  At any rate, it 
proceeds to populate the list based on whatever's in s(0).

It loops through and populates the positive and negative index areas 
progressively, by doing math on the one before it, starting with spot and 
working its way up.

The 'step 1' is superfluous, since it's step 1 by default.

Knowing that j =1 the first time through, it basically makes s(j), which is 
s(1), equal to s(0) * up, whatever 'up' is, presumably some positive 
multiplier.  This makes s(1) a little different than s(0), presumably 
higher, given the terminology used.  Likewise, while it's at it, it 
populates s(-1) with a variation of s(0) multiplied by dn, whatever 'dn' 
is, presumably 'down', and therefore presumably a negative 
multiplier.  Thus, on one pass, s(0) is populated, and s(-1) and s(1) are 
populated.  The rest are undefined.  The loop continues, and fills the 
values in both directions, radiating from the center, s(0).

>  For j = 1 To n Step 1
>    s(j) = s(j - 1) * up
>    s(-j) = s(-j + 1) * dn
>  Next j


Now, on this next section, instead of starting at the center s(0) and 
radiating out, it starts at the bottom, looking to populate every other v() 
with some number based on the value of s() at that matching spot.  The 
every other value is handled by the step 2.  I have no idea what phi, 
strike, or the dmax function are, so I couldn't speculate as to what the 
effect is, other than to say that every other v() will be given a 
value.  The other ones will not be filled in, and thus will be undefined.


>  For j = -n To n Step 2
>    v(j) = dmax(phi * (s(j) - strike), 0)
>  Next j

This is all doable in Lingo; the big challenge is to figure out what the 
heck they were doing in BASIC! :)

Keep learning...

- Tab


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to