<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:verdana, helvetica, sans-serif;font-size:12pt"><DIV>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="times new roman, new york, times, serif">Greetings, new member here.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="times new roman, new york, times, serif"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="times new roman, new york, times, serif">A little bit of background, I just finished reading Ernest Chan’s Quantitative Trading book which included several Matlab code sections which I am trying to reproduce in Scilab. </FONT></o:p><FONT face="Times New Roman">Recently downloaded and installed Scilab and I must say I was pleasantly surprised how hassle free it was. Unfortunately I’m now running into what I guess are some rudimentary user errors.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">In summary I’m trying to load 1505 lines of a spreadsheet called IGE.xls, sort them in date order and then perform some calculations. I’ve tried this several ways and keep getting stuck. In some places I can get code to work in the console but not when I execute from the text editor.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">Example 1</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">If I enter into console</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">-> A=[1;2;3]</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">-> B=[4;5;6]</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">-> C=[A,B]</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I get the expected response</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">C =</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> </SPAN>1,<SPAN style="mso-spacerun: yes"> </SPAN>4,</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> </SPAN>2,<SPAN style="mso-spacerun: yes"> </SPAN>5,</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> </SPAN>3,<SPAN style="mso-spacerun: yes"> </SPAN>6,</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">But when I execute the following in the text editor</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">clear;</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">s1=sheets(1)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">tday=s1(:,1)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">cls=s1(:,$)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">mydata=[tday,cls]</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I get “mydata=[tday,cls]<SPAN style="mso-spacerun: yes"> </SPAN>!—error 144<SPAN style="mso-spacerun: yes"> </SPAN>Undefined operation for the given operands. Check or define function %1_c_1 for overloading.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I get the same error if I execute…</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">clear;</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">s1=sheets(1)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">mydata=[s1(:,1),s1(:,$)] </FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">Anybody tell me what I am missing here?</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">Jumping ahead if I run the following</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">clear<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">s1=sheets(1)<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">s1=s1(2:$,:)<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">mydata=gsort(s1,'lr','i')<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">dailyret=(mydata(1:$-1,$)-mydata(2:$,$))/mydata(2:$,$)<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">excessret=dailyret-.04/252<o:p></o:p></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">sharperatio=sqrt(252)*mean(excessret)/stdev(excessret)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I get a !—error 17 stack size exceeded. Now I have no idea what to do?</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">If I shorten the amount of data (its 1505x7) by changing line 4 to</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">s1=s1(2:10,:)</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I can see that line 6 (dailyret=) isn’t doing what I expected it to do.</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">I was expecting to calculate a new matrix of the percentage returns of the data in the last column based upon the previous row. ie for rows 1 through end-1, last column subtract rows 2 through end, last column. The answer matrix has 8 columns though, not the single column I expected. Any help appreciated!</FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face="Times New Roman">Thanks, Sean <SPAN style="mso-spacerun: yes"> </SPAN></FONT></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT face="Times New Roman"> </FONT></o:p></P></DIV><!-- cg5.c1.mail.mud.yahoo.com compressed/chunked Thu Jan 21 10:50:41 PST 2010 --></div></body></html>