[Quantproject-developers] QuantProject/b3_Data/DataTables Quotes.cs,1.19,1.20
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-12-20 19:33:40
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16728/b3_Data/DataTables Modified Files: Quotes.cs Log Message: Updated GetTickersByPrice method Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/Quotes.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Quotes.cs 17 Nov 2005 21:34:40 -0000 1.19 --- Quotes.cs 20 Dec 2005 19:33:12 -0000 1.20 *************** *** 328,341 **** double maxStdDeviation) { ! int numRows = setOfTickers.Rows.Count; ! for(int i = 0; i<numRows; i++) { ! double averagePrice = (double)setOfTickers.Rows[i]["AverageRawOpenPrice"]; ! double stdDeviation = (double)setOfTickers.Rows[i]["RawOpenPriceStdDev"]; ! if (averagePrice < minPrice || averagePrice > maxPrice || ! stdDeviation < minStdDeviation || stdDeviation > maxStdDeviation) ! //values of rows DON'T respect given criteria ! setOfTickers.Rows[i].Delete(); ! } } --- 328,349 ---- double maxStdDeviation) { ! int currentNumRows = setOfTickers.Rows.Count; ! for(int i = 0;i<currentNumRows;i++) { ! if(setOfTickers.Rows[i].RowState != DataRowState.Deleted) ! { ! double averagePrice = (double)setOfTickers.Rows[i]["AverageRawOpenPrice"]; ! double stdDeviation = (double)setOfTickers.Rows[i]["RawOpenPriceStdDev"]; ! if (averagePrice < minPrice || averagePrice > maxPrice || ! stdDeviation < minStdDeviation || stdDeviation > maxStdDeviation) ! //values of rows DON'T respect given criteria ! { ! setOfTickers.Rows[i].Delete(); ! currentNumRows = setOfTickers.Rows.Count; ! i--;//deletion causes the new ID row ! //of the next row to be the ID row of the deleted Row ! //so, only in this way, all the rows are checked ! } ! } } } *************** *** 447,464 **** return tableToReturn; } ! public static float[] GetArrayOfCloseToCloseRatios(string ticker, DateTime firstQuoteDate, DateTime lastQuoteDate, ! int numDaysBetweenEachClose) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, firstQuoteDate, lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! returnValue = new float[allAdjValues.Length/(numDaysBetweenEachClose + 1)]; int i = 0; //index for ratesOfReturns array int lastIdxAccessed = 0; for(int idx = 0; ! (idx + numDaysBetweenEachClose) < allAdjValues.Length; idx += numDaysBetweenEachClose ) { --- 455,487 ---- return tableToReturn; } ! /// <summary> ! /// Gets an array containing close to close ratios ! /// </summary> ! /// <param name="ticker"></param> ! /// <param name="firstQuoteDate"></param> ! /// <param name="lastQuoteDate"></param> ! /// <param name="numDaysBetweenEachClose">Num of days the close to close ratio refers to</param> ! /// <param name="numOfInitialMarketDaysToJump">Num of initial market days that has not to be ! /// considered in the calculation</param> ! /// <returns></returns> public static float[] GetArrayOfCloseToCloseRatios(string ticker, DateTime firstQuoteDate, DateTime lastQuoteDate, ! int numDaysBetweenEachClose, ! int numOfInitialMarketDaysToJump) { float[] returnValue = null; Quotes tickerQuotes = new Quotes(ticker, firstQuoteDate, lastQuoteDate); float[] allAdjValues = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, "quAdjustedClose"); ! float[] adjValuesMinusInitialMarketDays = new float[allAdjValues.Length - numOfInitialMarketDaysToJump]; ! for(int k = 0;k<allAdjValues.Length - numOfInitialMarketDaysToJump;k++) ! adjValuesMinusInitialMarketDays[k] = ! allAdjValues[k + numOfInitialMarketDaysToJump]; ! ! returnValue = new float[adjValuesMinusInitialMarketDays.Length/(numDaysBetweenEachClose + 1)]; int i = 0; //index for ratesOfReturns array int lastIdxAccessed = 0; for(int idx = 0; ! (idx + numDaysBetweenEachClose) < adjValuesMinusInitialMarketDays.Length; idx += numDaysBetweenEachClose ) { *************** *** 466,471 **** //there is a discontinuity, as wanted { ! returnValue[i] = (allAdjValues[idx+numDaysBetweenEachClose]/ ! allAdjValues[idx] - 1); lastIdxAccessed = idx; i++; --- 489,494 ---- //there is a discontinuity, as wanted { ! returnValue[i] = (adjValuesMinusInitialMarketDays[idx+numDaysBetweenEachClose]/ ! adjValuesMinusInitialMarketDays[idx] - 1); lastIdxAccessed = idx; i++; *************** *** 475,478 **** --- 498,509 ---- } + public static float[] GetArrayOfCloseToCloseRatios(string ticker, + DateTime firstQuoteDate, + DateTime lastQuoteDate, + int numDaysBetweenEachClose) + { + return GetArrayOfCloseToCloseRatios(ticker, firstQuoteDate, lastQuoteDate, numDaysBetweenEachClose, + 0); + } /// <summary> /// returns tickers of a given set of tickers ordered by close to close |