[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: Corr Matrix via Gfx functions



PureBytes Links

Trading Reference Links

Hi Nicolas. Thanks and that's more or less where I am. I have an article here from Chaitin based on the compression criterion for randomness. He claims that financial time series are more or less ALL random. 'Only one series in 1.000 can be compressed'. Meaning that in practice you can find only 1 non-random time series in 1.000. I just cannot believe this because if that's true what about technical analysis ? So I am missing something ...
 
Anyway, you are saying that you did some testing on the NAS100 stocks with the Lempel-Ziv algorithm (?). Do you have any code for me or an URL where I can find it ?
 
Regards, Ton.
 
----- Original Message -----
Sent: Tuesday, May 29, 2007 12:04 PM
Subject: [amibroker] Re: Corr Matrix via Gfx functions

Hello Ton,

>How to calculate the degree of randomness. I want to be able to
>separate random from 'non' random time series and got stuck in the
>scientific background ..

The problem you raised is very difficult imho (there is a ton of
literature on the subject), and I would like to know a definite answer
: )

Anyway, something practical that can be done, and imho give a
reasonnable answer to your question, is to estimate the entropy rate
of the time series. The entropy rate of a dynamic process measures the
uncertainty that remains in the next information produced by the
process given complete knowledge of the past (and thus fully random
time series maximize the entropy rate). It is thus a natural measure
of the difficulty to predict the evolution of the process.

They are two main classes of entropy rates estimators: Lempel-Ziv
based algorithms and Context-Tree Weighting algorithms. The former are
simple to implement (a few lines of code), the latter usually a bit
better (i.e. need less data to be accurate) but much more involved.

I have made some experiments on NYSE US 100 stocks and it turned out
that all these stocks are highly unpredictable, some are even more
unpredictable (in the sense of the entropy rate) than the random
generator of the C library : )

Regards,

Nicolas

>
> Regards and thanks again, Ton.
>
>
> ----- Original Message -----
> From: vlanschot
> To: amibroker@xxxxxxxxxps.com
> Sent: Monday, May 28, 2007 1:46 PM
> Subject: [amibroker] Corr Matrix via Gfx functions
>
>
> Thought I'd share the following code.
>
> PS
>
> //Simple application of the new Gfx functions, basically calculating
> //the correlation matrix of any WL of choice. You can easily adjust
> //this code to move to Var-Covar matrix, etc.
> // PS 28/05/07
>
> GfxSetOverlayMode(2); // Show Only Matrix
>
> function NrSecs(ListType,ListNr)
> {
> global NrPosPrices;
>
> if(ListType==1) ExtrList = CategoryGetSymbols
> (categoryGroup,ListNr);
> else if(ListType==2)ExtrList = CategoryGetSymbols
> (categoryWatchlist,ListNr);
> else if(ListType==3)ExtrList = CategoryGetSymbols
> (categoryIndustry,ListNr);
>
> NrSecurs=0;
> NrPosPrices=0;
>
> for( n=0; (Ticker=StrExtract( ExtrList, n))!= ""; n++)
> {
> NrSecurs=NrSecurs+1;
> SetForeign(Ticker);
> Prijs=C;
> RestorePriceArrays();
> NrPosPrices=NrPosPrices+IIf(Prijs!=Null AND
> Prijs>0,1,0);
> }
> return NrSecurs;
> }
>
> function PrintTxtInCell( Str, row, Col, CellWidth, CellHeight,
> HorzAdj, VertAdj, Formaat )
> {
> GfxDrawText( Str, Col * CellWidth + HorzAdj, row * CellHeight +
> VertAdj, (Col + 1 ) * CellWidth, (row + 1 ) * CellHeight, Formaat);
> }
>
> function PrintInCell( val, row, Col, CellWidth, CellHeight, HorzAdj,
> VertAdj )
> {
> GfxDrawText( NumToStr(val), Col * CellWidth + HorzAdj, row *
> CellHeight + VertAdj, (Col + 1 ) * CellWidth, (row + 1 ) *
> CellHeight, 1|32|4);
> }
>
> //CH = Param("CellH",20,10,100,5);
> //CW = Param("CellW",100,10,300,5);
> HA=0;
> VA=0;
>
> String = "" ;
> for ( x = 0 ; x < 200 ; x++ )
> {
> WList = CategoryGetName( categoryWatchlist, x );
> if (WList != "" )
> {
> String = String + WList +"," ;
> // Creates a list of WatchLists, NOT symbols !!!
> }
> }
> WatchList = ParamList ( "Watch List", String );
>
> WLnr=CategoryFind(WatchList,categoryWatchlist);
> WLSymbols = CategoryGetSymbols(categoryWatchlist,WLnr);
>
> NrSymbs = NrSecs(2,WLNr);
>
> CW= Status("pxwidth")/(NrSymbs+1);// In order to allow Rowheadings
> CH = Status("pxheight")/(NrSymbs+1);//Colheadings
>
> //GfxSetTextAlign(6 | 24);
>
> RetLB = Param("RetLB",1,1,100);
> CorrLB = Param("CorrLB",30,5,256);
>
> Start = BarCount-RetLB;
>
> ActBar = Min(BarCount-1,LastValue(SelectedValue(BarIndex())));
> ActD = LastValue(SelectedValue(DateTime()));
>
> GfxSelectFont( "MS Serif", CH/4,800);
> PrintTxtInCell( "CorrM @:\n"+NumToStr(ActD,formatDateTime), 0, 0,CW,
> CH, HA, VA, 1);
>
> for ( x = 0 ; (Ticker = StrExtract ( WLSymbols, x ))!="" ; x++ )
> {
> SetForeign(Ticker);
> RetTick = ROC(C,RetLB);
> FN = FullName();
> RestorePriceArrays();
>
> GfxSelectFont( "MS Serif", CH/4,800);
> PrintTxtInCell( Ticker, 0, x+1 ,CW, CH, HA, VA,1|32|4 );
>
> GfxSelectPen( colorBlue );
>
> for( i = 0; (Ticker2 = StrExtract ( WLSymbols, i))!="" ; i++ )
> {
> SetForeign(Ticker2);
> RetTick2 = ROC(C,RetLB);
> FN2 = FullName();
> RestorePriceArrays();
>
> if (Ticker2 == Ticker) Corr=1;
> else Corr = Correlation(RetTick, RetTick2, CorrLB);
>
> GfxSelectFont( "MS Serif", CH/4,800);
> PrintTxtInCell( Ticker2, i+1, 0, CW, CH, HA,
> VA,1|32|4);
> GfxSelectFont( "MS Serif", CH/4);
> Kleur = IIf(Corr[ActBar]>=0, colorGreen,colorRed);
> GfxSetTextColor(Kleur);
> PrintInCell( Corr[ ActBar ], i+1, x+1, CW, CH, HA,
> VA);
> //PrintInCell( Corr[ ActBar ] , i+1, x+1);
> GfxSetTextColor(colorBlack);
>
> GfxMoveTo( 0, (i+1) * CH);
> GfxLineTo( (x+2) * CW, (i+1) * CH );// Columns
> }
>
> GfxMoveTo( 0, (x+1)*CH); // Move to end of last column
> //GfxLineTo( 6 * CW, i * CH );
> }
>
> for( Col = 1; Col < NrSymbs+2; Col++ )
> {
> GfxMoveTo( Col * CW, 0);
> GfxLineTo( Col * CW, (NrSymbs+1) * CH );
> }
>
>
> Title="";
>

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___