MrMarc

3163 Reputation

18 Badges

17 years, 133 days

MaplePrimes Activity


These are answers submitted by MrMarc

I managed to solve it myself :-)  

It was not that difficult just creating two separate procedures .... thanx anyway

 

Another thing that I have to ask you about :

Now the Maplet is working but I can only click on the "loadFileDialog" buton 1 time because then L becomes assigned.

I was wondering if there is a easy way to augment the code so I can click on the button and select a new file

even when the maplet is open and reassign that file to L . Now if I want to make to sequential selections then I have to

load the maplet, select a file, close the maplet, load the maplet, select a file which is not optimal .....

thanx Doug that worked great :-)   It is so easy when you point out the error but it is very difficult to find the solution myself (with

limited Maplet experience) because from my perspective there are an infinti number of things that could be wrong so my only 

method is trial and error with an infinit number of permutations.  yes, it is probably best to create many external procedures

and then call them from inside the Maplet.  I think this Maplet is going to be great. Very optimistic !

I will post the time series plot / portfolio optimization Maplet when I am done.

I would very much like to have your feadback on it  :-)

 

 

It took me exactly one hour until I ran into a new problem :-(

The code is the same as Doug suggested above with the slight modification that  onchange is included into drop1

 

drop1 := DropDownBox[DD](["Time Series"], width = 200, onchange = AC)

 

and the title in the plot corresponds to the value in the dropdownbox



Display(Maplet([[Button['Bu']("Select a csv file with data", tooltip = tool, onclick = Action(Evaluate('Bu' = 'X(1)'), Evaluate('TF1' = 'X(2)'), Evaluate('DD' = 'X(3)'))), tx1, drop1], [p1]], Action[AC](Evaluate(P = 'plot(x^2, x = 0 .. 10, title = [DD], font = [times, roman, 14], color = red, thickness = 3)'))))

 

If you load the csv file with the Maplet that I attached in the first post you will see that

the values in the drop down menu are for example:

 

["Argentina", "Brazil", "Hong Kong", "USA (S&P-500)", "USA (Nasdaq Composite)"]

 

Everything is working ok until when I comes to either "Hong Kong", "USA (S&P-500)" or  "USA (Nasdaq Composite)"

then I get an error message saying:



the expression 'plot(x^2,x=0..10, title=[args[1]], font=[times, roman, 14], color=red, thickness=3)'

does not parse when (args[1])=(USA(Nasdaq Composite))

 

it is very strange because everything is working accept for these three cases hummm....

I think it has to do with the spacing in the names but it is a string so it should be ok ?!

 

thank for your unquestionable effort Doug and pointing out my mistake :-)

Yes, you are right I am planning to plot the data as soon as I manage to solve this specific problem first :-)

probably need to write another procedure for that but I think it will be fairly straightforward

"Let us know if you have more problems and need more of our assistance"

will sure do :-)   again thanx for your support and help

+1,0,-1 represent an equal weighted portfolio which are more empirical stable than exact weights like w[5]=0.0004.

We take a long, no position or a short position in each stock with the same position size 1 .

From a Black- Litterman portfolio optimization framework you would probably assign the market cap weight

to each stock but such a model works differently from the traditional Markowitz Sharpe Treynor due to the assumption that

the market portfolio is assumed to be mean-variance optimal. You are also right about instability of the efficient frontier

this is further discussed in a MATLAB webinar:

http://www.mathworks.com/company/events/webinars/wbnr30412.html?id=30412&p1=31085&p2=31086

This was actually something I wanted to investigate. I wanted to plot the efficient frontier over time and see how it changed.

However, it is not that fun :-(  to analys an efficient fronties with 5-10 assets or

having to come up with ways of reducing dimensions (even though sector clasifications might work to a certain degree )

From my perspective it is 50 or more assets or nothing. 

Maybe I have to wait when the optical computer becomes a reality :-)  which would be in another 50 years or so ha ha

 

 

ok, let say that I wanted to do that as well....what software would I need to do that ?

( the only thing I know about c++ is  cout<< "Hello World "  )

yes, I have MATLAB already plus it is quite user friendly and powerful :-)

what software are you thinking of for 300 variables ?   GAUSS ??

 

I think I will develop the portfolio optimization in MATLAB instead which can perform numerical computations much faster.

I think global optimization is free in MATLAB  which is not the case for Maple kilo $$$$$ which I dont understand why ?!

yes unfortunately I dont know how to program C++  ( ie what software to use etc )

I took a course in c++ when I went to high school ( 15 years ago) and it was the only course I failed, ha ha

yes but I am planning to run the algorithm for 50 stocks.... I just selected an example with 2 stocks because it was

simple to post. How would such an fast optimization look like ?  I have tried permutations but it is just a

performance killer because it cant handle more than 10 stocks. The Maximize command (Lagrange ) with weights is better

because it can 40 - 50 stocks quite fast. The problem however is that some of the weights are rediculous like w[10]=0.0003

yes, it a portfolio optimization exercise for example:

 

restart :
Er[1] := .175 :
Er[2] := 0.055:
cov[1, 1] := 0.067: cov[2, 2] := 0.013:
cov[1, 2] := -0.004875:

Pr := add(w[i]*Er[i], i = 1 .. 2):

f := proc (i, j) options operator, arrow; w[i]*w[j]*cov[i, j] end proc:

C := Matrix(2, f, shape = symmetric) :

PV := add(i, `in`(i, C)) :

SR := Pr/sqrt(PV):

con := [w[1] <= 1, w[2] <= 1, w[1] >= -1, w[2] >= -1, w[1]+w[2] = 1] :

with(Optimization):

Maximize(SR, con) ;

 

[.905480875696116684, [w[1] = .359135039717650206, w[2] = .640864960282349849]]

 

The problem however is that is a quadratic optimization so I am not sure if the LPSolver can be used (linear).

I want to augment the code so weights can only be -1, 0 1   which means that we can only have 

a long position, no position or a short position in the two stocks. The reason for -1,0,1 is because

when n is large the weights just becomes ridiculous like 0.0003 in stock 1, 0.001 in stock 2 etc

 

 

How would I do that  ?

 

 

ok this is an excerpt from Hull's book. How do I prove that in Maple ?????

sorry but I have no Idea what you are doing  :-)  I do appreciate your input but I still fail to see

why the mean of the LogNormal distribution is assumed to be ( r - sigma^2 / 2 )  and not  exp(u+sigma^2 / 2) ??

It is not only Maple applications that uses this relationship I have since it in both

Hulls (Options, Futures and Other Derivaties) and McDonalds (Derivatives Markets) books.

I think it is either the solution to the stochastic differential equation or it has to do with Ito's lemma....

It can also be an approximation for the geometric mean given the arithmetric mean....hummm

First 11 12 13 14 15 16 17 Last Page 13 of 24