Help with Matrices and Stack Size

Sean Cooper smcjb at yahoo.com
Thu Jan 21 21:45:52 CET 2010


Greetings, new member here.
 
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. 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.
 
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.
 
Example 1
If I enter into console
-> A=[1;2;3]
-> B=[4;5;6]
-> C=[A,B]
I get the expected response
C =
 1,  4,
 2,  5,
 3,  6,
 
But when I execute the following in the text editor
 
clear;
sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')
s1=sheets(1)
tday=s1(:,1)
cls=s1(:,$)
mydata=[tday,cls]
 
I get “mydata=[tday,cls]  !—error 144  Undefined operation for the given operands. Check or define function %1_c_1 for overloading.
 
I get the same error if I execute…
 
clear;
sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')
s1=sheets(1)
mydata=[s1(:,1),s1(:,$)] 
 
Anybody tell me what I am missing here?
 
Jumping ahead if I run the following
 
clear
sheets=readxls('C:\Program Files\scilab-5.2.0\myscilab\IGE.xls')
s1=sheets(1)
s1=s1(2:$,:)
mydata=gsort(s1,'lr','i')
dailyret=(mydata(1:$-1,$)-mydata(2:$,$))/mydata(2:$,$)
excessret=dailyret-.04/252
sharperatio=sqrt(252)*mean(excessret)/stdev(excessret)
 
I get a !—error 17 stack size exceeded. Now I have no idea what to do?
 
If I shorten the amount of data (its 1505x7) by changing line 4 to
 
s1=s1(2:10,:)
 
I can see that line 6 (dailyret=) isn’t doing what I expected it to do.
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!
 
Thanks, Sean  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20100121/6bbe970a/attachment.htm>


More information about the users mailing list