[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/TickersRelationships CorrelationP
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-04-08 21:47:32
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6365/b4_Business/a2_Strategies/TickersRelationships Modified Files: CorrelationProvider.cs Log Message: Added showOutputToConsole for debugging. Other minor changes Index: CorrelationProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/TickersRelationships/CorrelationProvider.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CorrelationProvider.cs 12 Mar 2008 21:56:08 -0000 1.3 --- CorrelationProvider.cs 8 Apr 2008 21:47:28 -0000 1.4 *************** *** 51,56 **** protected int returnIntervalLength; protected string benchmark; ! ! private void correlationProvider_commonInitialization(string[] tickersToAnalyze, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue) --- 51,55 ---- protected int returnIntervalLength; protected string benchmark; ! private void correlationProvider_commonInitialization(string[] tickersToAnalyze, float minimumAbsoluteReturnValue, float maximumAbsoluteReturnValue) *************** *** 59,64 **** this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; ! this.numOfCombinationTwoByTwo = ! (int)((Math.Pow(this.tickers.Length, 2) - this.tickers.Length ) / 2); } --- 58,66 ---- this.minimumAbsoluteReturnValue = minimumAbsoluteReturnValue; this.maximumAbsoluteReturnValue = maximumAbsoluteReturnValue; ! int n = this.tickers.Length; ! //combinations without repetitions: ! //n_fatt /( k_fatt * (n-k)_fatt ): when k = 2, ! // it can be reduced to this simple formula: ! this.numOfCombinationTwoByTwo = n * (n - 1) / 2; } *************** *** 164,170 **** if ( Double.IsNaN(returnValue) || Double.IsInfinity(returnValue) ) ! throw new Exception( "correlation can't be computed for these two tickers: "+ ! this.tickers[indexOfFirstTicker] + " and " + ! this.tickers[indexOfSecondTicker] + "!"); return returnValue; --- 166,171 ---- if ( Double.IsNaN(returnValue) || Double.IsInfinity(returnValue) ) ! throw new MissingCorrelationException(this.tickers[indexOfFirstTicker], ! this.tickers[indexOfSecondTicker]); return returnValue; *************** *** 181,191 **** for (int j = i + 1; j < this.tickers.Length; j++) { ! this.pearsonCorrelations[index] = ! new TickersPearsonCorrelation( this.tickers[i], this.tickers[j], ! this.getOrderedTickersPearsonCorrelations_setCorrelations_getValue( i , j) ); index++; } Array.Sort(this.pearsonCorrelations); } public TickersPearsonCorrelation[] GetOrderedTickersPearsonCorrelations() --- 182,208 ---- for (int j = i + 1; j < this.tickers.Length; j++) { ! try{ ! this.pearsonCorrelations[index] = ! new TickersPearsonCorrelation( this.tickers[i], this.tickers[j], ! this.getOrderedTickersPearsonCorrelations_setCorrelations_getValue( i , j) ); ! } ! catch(MissingCorrelationException ex) ! {ex=ex;} index++; } Array.Sort(this.pearsonCorrelations); } + + private void showOutputToConsole() + { + System.Console.WriteLine("\n\rEligibles"); + for(int i = 0; i < this.tickers.Length; i++) + System.Console.WriteLine(this.tickers[i]); + System.Console.WriteLine("\n\rCorrelations"); + for(int i = 0; i < this.pearsonCorrelations.Length; i++) + System.Console.WriteLine(this.pearsonCorrelations[i].FirstTicker + " " + + this.pearsonCorrelations[i].SecondTicker + " " + + this.pearsonCorrelations[i].CorrelationValue.ToString() ); + } public TickersPearsonCorrelation[] GetOrderedTickersPearsonCorrelations() *************** *** 193,197 **** if( this.pearsonCorrelations == null ) this.getOrderedTickersPearsonCorrelations_setCorrelations(); ! return this.pearsonCorrelations; } --- 210,214 ---- if( this.pearsonCorrelations == null ) this.getOrderedTickersPearsonCorrelations_setCorrelations(); ! this.showOutputToConsole(); return this.pearsonCorrelations; } |