Example #1
0
double TechUtils::CalulateAMA(const std::vector<KData>& data, const KData& current, size_t mins){
	double totalExchangePrice = current.TurnOver();
	long long totalVolume = current.Volume();

	long long leftedge = current.Timestamp() - mins * 60 - 1;
	for (auto it = data.rbegin(); it != data.rend(); it++)
	{
		if (it->Timestamp() > leftedge){
			totalExchangePrice += it->TurnOver();
			totalVolume += it->Volume();
		}
		else{
			break;
		}
	}

	//assert(totalVolume != 0);
	//assert(totalExchangePrice >= 0.0);

	return totalExchangePrice / totalVolume;
}
Example #2
0
double TechUtils::CalulateAMA(const std::vector<TickWrapper>& data, const TickWrapper& current, size_t seconds)
{
	double totalExchangePrice = current.TurnOver();
	long long totalVolume = current.Volume();

	long long leftedge = current.toTimeStamp() - seconds * 2;
	for (auto it = data.rbegin(); it != data.rend(); it++)
	{
		if (it->toTimeStamp() > leftedge){
			totalExchangePrice += it->TurnOver();
			totalVolume += it->Volume();
		}
		else{
			break;
		}
	}

	//assert(totalVolume != 0);
	//assert(totalExchangePrice >= 0.0);

	return totalExchangePrice / totalVolume;
}
Example #3
0
int main()
{
	unsigned int x = 0x12345678;
	x = TurnOver(x);
	return 0;
}