Backend/Database/GAnalysis.cpp
/*!
 * @brief calculates rate of change
 * @details rate of change calculation
 * @param input the stock prices in a vector
 * @param period the length of a period
 */
@brief calculates rate of change
@details rate of change calculation
@param input the stock prices in a vector
@param period the length of a period
@brief calculates rate of change @details rate of change calculation @param input the stock prices in a vector @param period the length of a period
std::vector<float> GAnalysis::RateofChange(const std::vector<float>& input, unsigned int period)
{
	std::vector<float> roc;
	unsigned int count = 0;
	unsigned int length = input.size();
	for (unsigned int i = period - 1; i <= length - 1; ++i)
	{
		roc.push_back(((input[i] - input[count]) / input[count]) * 100);
		++count;
	}
	return roc;
}
std :: vector < float > GAnalysis :: RateofChange ( const std :: vector < float > & input , unsigned int period ) { std :: vector < float > roc ; unsigned int count = 0 ; unsigned int length = input . size ( ) ; for ( unsigned int i = period - 1 ; i <= length - 1 ; ++ i ) { roc . push_back ( ( ( input [ i ] - input [ count ] ) / input [ count ] ) * 100 ) ; ++ count ; } return roc ; }
@brief calculates rate of change
 @details rate of change calculation
 @param input the stock prices in a vector
 @param period the length of a period
@brief calculates rate of change @details rate of change calculation @param input the stock prices in a vector @param period the length of a period