Avatar of JustinW
JustinW
Flag for United States of America asked on

Linear Programming / Simplex, and Stock Options | How to Set up Problem

Good morning,

I found an article online, which I thought would be fun to play along with, and replicate the results
that the author got. However, I can't seem to figure out how he set up how his problem.

http://www.durangobill.com/LP_Options.html

the gist of the article is that if you owned a brokerage firm (I don't), its possible to create a basket of stock option combinations that will guarantee profit regardless of how the underlying security moves.

Maximize p = x13
s.t.

 - 1500x1 - 1130x2 - 1020x3 + 1500x4 + 1130x5 + 1020x6 + 56920x7 + 57200x8 + 57450x9 - 56920x10 - 57200x11 - 57450x12 - 1x13 >= 0
 - 1500x1 - 1130x2 - 1020x3 + 1500x4 + 1130x5 + 1020x6 + 920x7 + 1200x8 + 1450x9 - 920x10 - 1200x11 - 1450x12 - 1x13 >= 0
 - 1000x1 - 1130x2 - 1020x3 + 1000x4 + 1130x5 + 1020x6 - 1080x7 - 1300x8 - 1050x9 + 1080x10 + 1300x11 + 1050x12 - 1x13 >= 0
 + 1500x1 + 1370x2 + 980x3 - 1500x4 - 1370x5 - 980x6 - 1080x7 - 1300x8 - 1550x9 + 1080x10 + 1300x11 + 1550x12 - 1x13 >= 0
 + 40500x1 + 40370x2 + 39980x3 - 40500x4 - 40370x5 - 39980x6 - 1080x7 - 1300x8 - 1550x9 + 1080x10 + 1300x11 + 1550x12 - 1x13 >= 0
 + 1x1 + 1x2 + 1x3 + 1x4 + 1x5 + 1x6 + 1x7 + 1x8 + 1x9 + 1x10 + 1x11 + 1x12 - 0x13 <= 1
 + 1x1 + 1x2 + 1x3 + 1x4 + 1x5 + 1x6 + 1x7 + 1x8 + 1x9 + 1x10 + 1x11 + 1x12 - 0x13 >=1

Open in new window


for the life of me, I can't get my head wrapped around how to set this up.
I can't think of how to set it up in excel for solver

I've tried dumping it as is into this web site which has a  JS solver utility, and it bombs out.
:http://www.zweigmedia.com/RealWorld/simplex.html

Any help is super appreciated.
thanks
-JW
Programming Languages-OtherProgrammingMath / Science

Avatar of undefined
Last Comment
GwynforWeb

8/22/2022 - Mon
NovaDenizen

The problem is specified in AMPL (http://en.wikipedia.org/wiki/AMPL).  So just you need to get a linear programming solver.
GwynforWeb

Your solver is fussy about the format at start of each equation. I got it to "work" for below but basically the problem is too big. You need to find a better solver. You may have to download one. All the online ones are the same code as far as I can see.

Maximize p = x13 subject to

-1500x1 - 1130x2 - 1020x3 + 1500x4 + 1130x5 + 1020x6 + 56920x7 + 57200x8 + 57450x9 - 56920x10 - 57200x11 - 57450x12 - 1x13 >= 0
-1500x1 - 1130x2 - 1020x3 + 1500x4 + 1130x5 + 1020x6 + 920x7 + 1200x8 + 1450x9 - 920x10 - 1200x11 - 1450x12 - 1x13 >= 0
-1000x1 - 1130x2 - 1020x3 + 1000x4 + 1130x5 + 1020x6 - 1080x7 - 1300x8 - 1050x9 + 1080x10 + 1300x11 + 1050x12 - 1x13 >= 0
1500x1 + 1370x2 + 980x3 - 1500x4 - 1370x5 - 980x6 - 1080x7 - 1300x8 - 1550x9 + 1080x10 + 1300x11 + 1550x12 - 1x13 >= 0
 40500x1 + 40370x2 + 39980x3 - 40500x4 - 40370x5 - 39980x6 - 1080x7 - 1300x8 - 1550x9 + 1080x10 + 1300x11 + 1550x12 - 1x13 >= 0
 1x1 + 1x2 + 1x3 + 1x4 + 1x5 + 1x6 + 1x7 + 1x8 + 1x9 + 1x10 + 1x11 + 1x12  >=1
 1x1 + 1x2 + 1x3 + 1x4 + 1x5 + 1x6 + 1x7 + 1x8 + 1x9 + 1x10 + 1x11 + 1x12  <=1
ASKER CERTIFIED SOLUTION
GwynforWeb

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
GwynforWeb

correction multiply w14 by a large number ( as big as you can) eg

Minimize p = -x13 + 1000000x14

this is to force x14 to be 0 so the equality holds. sorry about that.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck