Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
20 Nov 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

Hi Sahinder,

HAve a look in matlab help files. There you can find all the information about importing xls data into matlab.

Cheers.
Marcelo.

19 Nov 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin ?ahinder

Hello Marcelo,
I am student in Turkey, at Istanbul Technical University.And I have a problem about to create mat-file . I must to use my excell data .How can I solve this problem. I think that "Creating Mat file in C "; but I can not solve my problem because I don't have enough source . Could you help me?? Thanks for your all attention.

Şahinder Kaya
İstanbul Technical University

Mathematics Engineering
kayasah@itu.edu.tr

19 Nov 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin ?ahinder

And I have a problem about to creating mat-file . I must to use my excell data .How can I solve this problem. I think that "Creating Mat file in C "; but I can not solve my problem because I don't have enough source . Could you help me?? Thanks for your all attention.

Şahinder Kaya
İstanbul Technical University

Mathematical Engineer

kayasah@itu.edu.tr

09 Nov 2009 Get Trading Data, from Yahoo, in your Matlab Workpace (or Excel) This package provides scripts and functions for downloading trading data from Yahoo server. Author: Marcelo Perlin Perlin, Marcelo

Hi Michele, the benchmark asset is not downloaded. If you want it, just include the ticker in example_ticker.txt.

Marcelo.

03 Nov 2009 Get Trading Data, from Yahoo, in your Matlab Workpace (or Excel) This package provides scripts and functions for downloading trading data from Yahoo server. Author: Marcelo Perlin Costola, Michele

Great Work!
Sorry for my question but where do you place the benchmark in the data?

29 Oct 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

Oi Felipe,

Agradeco pelo interesse no programa.
Favor entrar em contato pelo meu email.

Abraco.
Marcelo.

27 Oct 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Felipe

Ola Marcelo,
gostei muito do seu trabalho, e como trabalho no mercado, gostaria de saber mais sobre sua metodolgia de aplicacao. Como estou apenas comecando a me aprofundar nos estudos talvez precise de sua ajuda futuramente. Tenho interesse em aplicar seus estudos na pratica.
Se tiver interesse de discutir algumas ideias ficaria grato.

Obrigado,

Felipe
felipecfreitas@hotmail.com

23 Sep 2009 Get Trading Data, from Yahoo, in your Matlab Workpace (or Excel) This package provides scripts and functions for downloading trading data from Yahoo server. Author: Marcelo Perlin Teng, Ted

Great stuff, worked like a charm! thank you!!

19 Sep 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Hosseinkouchack, MehdiHK

Dear Marcelo,

I would like thank myself from your side for finding a little bug in your code. It is, however, excellent! I appreciate your efforts.

Best of Wishes
MehdiHK

09 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Hosseinkouchack, MehdiHK

Dear Marcelo,

This still does not solve the problem. I had a check on the probabilities: for k=2 I was checking if sum of the elements of the transition matrix adds up to 2, and it was not! well transposed or not transposed, rows or columns, does not matter now ...

For comment B decreasing search space based on my comment is agreed then.

Best of Wishes
MehdiHK

08 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

MehdiHK,

For A), from what you wrote it seems that the the transition matrix in the reference you used has a different notation than mine. In short, my transposed transition matrix will be equal to yours. Therefore, for my code, you should be looking at columns for the full process in each state (and not rows).

For B), I was not clear. I meant the decrease of one element in each state. So we agree.

Regards.

07 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Hosseinkouchack, MehdiHK

Dear Marcelo,

A) I am pretty sure that the probabilities do not sum up to the correct value. As a check: for a k=2 case, try to check if sum of all the elements in Coeff.p always is equal to 1 in all the cases!

B) About the search space, for a case of k=2, not that ONE parameters are more than enough, but that TWO are more than enough b/c P=[p11 p12; p21 p22] is identified if from each ROW exactly ONE element is know so 2 element is enough not 3. (you mentioned that 4 can be decreased by 1!!!)

C) ROWS should sum up to ONE not columns.

I closely looked into all of your codes. They are neat, but you have some mistakes that should be fixed.

Thanks a lot
Mehdi

07 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

Dear MehdiHK, regarding your first comment, the way I coded the optimization problem was jsut a matter of simplicity in the algorithm. I'm fully aware that the search space could be decreased by one elemente by conducting it as a inequality optimization problem, as opposed to an equality one.

For your second comments, the p values of the coefficients are fine and so is the way I coded the transition matrix.
If you look closelly in MS_Regress_Fit, you'll see that I'm using constrained estimation so that the each column of Coeff.p is summing to 1, according to my choice of numerical convergence.

If you have any further question, feel free to drop me an email.
Marcelo.

07 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Hosseinkouchack, MehdiHK

Well, I decided to recode things from the beginning. I think that the p-values are wrong which is because of the problem I mentioned before with the way you enter the probabilities into the search space. This is not just a dimension problem. When you calculate a numerical gradient, for the probability param's for example (for k=2), you change p11 while p12 is constant! In this case even if p11+p12 was 1, it will not be one when feeding it to the likelihood function!!
Another point is that you need to make sure that sum of the probabilities for state j (j=1,2,...,k) is 1. This is not guaranteed in your program.

06 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Hosseinkouchack, MehdiHK

Nice file, thanks. Although, there are cases for which the algorithm does not work. You need to impose more structure on transition prob matrix Also if there are 2 states then there are only 2 prob's entering the search space not 4. Having more states increases the dimensions very fast.

03 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

Hi gajd, fell free to contact me in my email.
Cheers.

01 Aug 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin gajd

Hi, Marcelo,

I've tried the R-package. It shows a mistake. Can we discull the mistake here or is there a special R-forum for that?

Regards, Gajd

03 May 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

Hi V,

Thanks for you comment.

Sorry for the late reply. I just realized you comment on file.

Yes, this would speed up the algorithm, but, it also degenerates the Qdist matrix with respect of the infomration I need to find the pairs with the pairs(:,1)=n; command. .

So, I employed a quick fix based on your idea. See new updated file for details.

Again, thanks.
Cheers.
Marcelo.

04 Apr 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Salman

01 Apr 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin V

edited your "pairs.m" file. noticed that when you use the least-squares sum method, the matrix you get is symmetric. therefore, I calculated the lower triangular only, 'nan' on diagonals, and copied over the transpose cell pair. When I set ut very low, this speedup really shows:

for i=1:n2
    for j=1:(i-1)
        Qdist(i,j)=sum((x(:,i)-x(:,j)).^2);
        Qdist(j,i)=Qdist(i,j);
    end
    Qdist(i,i)=nan;
end

last note: i don't think you use pairs(:,2)=m'; anywhere in the parent scripts, maybe you could eliminate it.

16 Mar 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

Hi Elena,

Currently the package can't handle TVTP models as the transition matrix is assumed constant.

You'll have to modify the original code for this setup.

Regards.
Marcelo.

14 Mar 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Dumitrescu, Elena

Hi, I'm new in using matlab, but I would need to use a Markov switching model with time varying probabilities, evolving as logistic functions of the independent variables (as in Diebold and Weinbach 1994) . Can you, please, tell me how can I use your program in order to do that?
Thank you!

02 Feb 2009 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Bongju

your program is useful. How can I draw the picture which compare realized y and predicted y according to data sequence?

05 Jan 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

Hi Bob,

Thanks for you comment.

Sorry for the late reply (vacation was great!).

I agree with you that the way I normalized the time series of prices is not realistic. At the time I wrote the paper (which produced the matlab code) that seemed to be a good way of bringing all stock prices to the same unit but, today, I can see the drawbacks.

I cannot change the paper (it is already published) but I'm going to add another option of normalization to the algorithm.

Regards,
Marcelo.

23 Dec 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin bob

hello everybody,

marcelo you normalise equities values by ''(value-mean)/std deviation'' it seems to me it's not realistic since all equities do not follow a normal distribution.

how can you justify such a behavior ??

nevertheless the technical code are very well done, congratulations.

maxime

12 Dec 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Jonathan

thanks for the quick response. Generally speaking, the code is already very useful, good work.

12 Dec 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

Hi Jonathan,
The parameters are estimated by standard maximum likelihood procedure so, currently, the EM algorithm is not implemented.
I'll keep it in mind for the future.

Regards.
Marcelo.

11 Dec 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Jonathan

Hi, what kind of parameter evaluation approach you are using in this package? is it the EM algorithm?

22 Sep 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin ramzi, knani

06 Aug 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin song, leo

great!thanks your

23 Jun 2008 Estimation and Simulation of State Space (Kalman Filter) Models with Matlab Functions and Scripts for Simulation and Estimation of State Space models Author: Marcelo Perlin deboucha, abdelhakim

23 Jun 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Perlin, Marcelo

Hi Anton,

I'm the author.
Thanks for your comments, I really apreciate it.

Regarding your question, no I haven't tried endogenous switching.

Cheers.
Marcelo.

21 Jun 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin Shishkin, Anton

This is really great. Thank you very much. Have you tried models with endogenous switching?

15 Jun 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin FEI, LONG

Thanks!!!

10 Jun 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin fan, tt

thanks!

07 May 2008 Nearest Neighbour Algorithm for Stock Prices Forecasts. Creates a vector with forecasted values of a time series based on the nearest neighbour algorithm. Author: Marcelo Perlin Catcher, Bug

Bugs where? Squash them! Fast, before they multiply!

07 May 2008 Estimation and Simulation of State Space (Kalman Filter) Models with Matlab Functions and Scripts for Simulation and Estimation of State Space models Author: Marcelo Perlin P., Marcelo

I agree with some of your points. When it comes to compare it to SSM toolbox, there is really no comparison at all. SSM is much more complete and far more developed than mine. My point with this submission was just to publish a simple, self contained, user friendly toolbox for simulation and estimation of linear state space models in matlab.
When it comes to expanding the package for MS effects and heterokesdasticity, I have no plans for doing it in the moment but, I'll keep it in mind. Cheers.

06 May 2008 Estimation and Simulation of State Space (Kalman Filter) Models with Matlab Functions and Scripts for Simulation and Estimation of State Space models Author: Marcelo Perlin Firoozye, Nick

I have to agree with the first commenter. What's the point? There are much more complete Kalman filter packages around (e.g., The SSM Toolbox). This merely does the same in a more limited way.
At the same time, the author is quoting Kim and Nelson. The only justification for using this package would be that it actually implements all of the Gauss codes from Kim-Nelson (i.e., SSMs with Regime Shift and heteroskedasticity, and the same in a Bayesian framework).

Unfortunately, there is a significant amount of work to be done (i.e., only about 20% of the total task has been completed).

03 May 2008 Nearest Neighbour Algorithm for Stock Prices Forecasts. Creates a vector with forecasted values of a time series based on the nearest neighbour algorithm. Author: Marcelo Perlin lee, yamtazi

can not be used, more bugs

12 Apr 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin xhui, rao

thank you! it is useful to me!

06 Apr 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Kgomari, Modiri

01 Apr 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Geng, Jia

Hey, Marcelo,
 this is a great program. And I am working on this topic too. I always have a question about the data. As Gatev mentioned in his paper, he used the data covering from 1962 to 2002. How did he(how did you)handle the missing values? There got to be some missing values(for example, trading closed for a particular stock). Thanks again for your grogram.

31 Mar 2008 MS_Regress - A Package for Markov Regime Switching Models in Matlab Functions to Estimate, Simulate and Forecast a markov switching model in Matlab Author: Marcelo Perlin A, Han

Thank you. Very useful to start my own model.

20 Feb 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

Hi Jon,

You're right. I wrote this function for using it in the ssrn paper. In there I didn't used the correlation method. And I never bother to check if it was working. The 'correlation' method is not even an option to the main algortihm. If you wanted to change it, you would had to go to the m file and write it.

Somehow the line corr(idx1,idx2)=0; doesn't take the diagonal out as it should be. Your approach will work, but I'm changing it to corr(corr==1)=0; which I think its a little more intuitive. The new files whould be up tomorrow.

Thanks for your message and rating. I really appreciate it.

Cheers.
Marcelo.

19 Feb 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Zimmerman, Jon

I think there is an error in pairs.m when the correlation method is used as many stocks seem to be paired with themselves.

you may want to replace:

    corr=corrcoef(x);
    [idx1,idx2]=find(corr==1);
    corr(idx1,idx2)=0;

with corr = corr - diag(diag(corr)) to zero out the diagnol;
    

11 Feb 2008 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Jo, Gabri

Excellent

29 Jan 2008 Estimation and Simulation of State Space (Kalman Filter) Models with Matlab Functions and Scripts for Simulation and Estimation of State Space models Author: Marcelo Perlin P, Miles

And the point is??? One is better off downloading the Kalman filter tutorial script here on file exchange. Dont waste your time with this.

26 Nov 2007 Estimation and Simulation of ACD models in MatLab Functions and Scripts for Simulation and Estimation of ACD models Author: Marcelo Perlin Khan, Zahid

Thank you Marcelo! It was indeed very helpful in understanding those papers.

20 Nov 2007 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy over a matrix of prices. Author: Marcelo Perlin Perlin, Marcelo

The data is from the brazilian equity Market (the paper at SSRN).

But not the full period of the research, just a small part and for a portion of the assets.

Honestly, this was a long time ago. I don't remember which period and which assets were included, but the data is from real assets (not simulated).

20 Nov 2007 Estimation and Simulation of ACD models in MatLab Functions and Scripts for Simulation and Estimation of ACD models Author: Marcelo Perlin pal, si

Very useful. Thanks for sharing the codes.

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com