report

Published

src/Client/StkLib/Src/Report.cpp

BOOL CReport::GetMMLD(int nIndex, double* pdVolBuy, double* pdVolSell, double* pdVolDiff)
{
	SP_ASSERT(nIndex >= 0 && nIndex < GetSize());
	if (nIndex < 0 || nIndex > GetSize() - 1)
		return FALSE;

	double	dVolBuy = 0;
	double	dVolSell = 0;
	REPORT& rpt = ElementAt(nIndex);
	for (int k = 0; k < sizeof(rpt.m_fBuyVolume) / sizeof(rpt.m_fBuyVolume[0]); k++)
		dVolBuy += rpt.m_fBuyVolume[k];
	for (int k = 0; k < sizeof(rpt.m_fSellVolume) / sizeof(rpt.m_fSellVolume[0]); k++)
		dVolSell += rpt.m_fSellVolume[k];

	if (pdVolBuy)	*pdVolBuy = dVolBuy;
	if (pdVolSell)	*pdVolSell = dVolSell;
	if (pdVolDiff)	*pdVolDiff = (dVolBuy - dVolSell);
	return TRUE;
}

 

2.

src/Client/StkUI/View/RealTime.cpp

float	fSellPrice[8], fSellVolume[8], fBuyPrice[8], fBuyVolume[8];
	m_CurStock.GetReport().StatBuySellEx(fSellPrice, fSellVolume, fBuyPrice, fBuyVolume, 8);

G:\stock\TskingVS2019\src\Client\StkLib\Src\Report.cpp

 

//显示8档行情
BOOL CReport::StatBuySellEx(float* fSellPrice, float* fSellVolume, float* fBuyPrice, float* fBuyVolume, int nSize)
{
	int k;
	for (k = 0; k < nSize; k++)
	{
		fSellPrice[k] = 0.;
		fSellVolume[k] = 0.;
		fBuyPrice[k] = 0.;
		fBuyVolume[k] = 0.;
	}

	CSPDWordArray	adwSellPrice, adwSellVolume, adwBuyPrice, adwBuyVolume;
	REPORT	rpt;
	memset(&rpt, 0, sizeof(rpt));

	//得出数组个数 by freeman
	int	nBSCount = sizeof(rpt.m_fBuyPrice) / sizeof(float);

	//分笔成交明细长度 by freeman
	for (k = 0; k < GetSize(); k++)
	{
		REPORT& report = ElementAt(k);

		// Insert
		for (int i = nBSCount - 1; i >= 0; i--)
		{
			if (report.m_fSellPrice[i] > 1e-4)
			{
				adwSellPrice.InsertAt(0, DWORD(report.m_fSellPrice[i] * 1000));
				adwSellVolume.InsertAt(0, DWORD(report.m_fSellVolume[i]));
			}
			if (report.m_fBuyPrice[i] > 1e-4)
			{
				adwBuyPrice.InsertAt(0, DWORD(report.m_fBuyPrice[i] * 1000));
				adwBuyVolume.InsertAt(0, DWORD(report.m_fBuyVolume[i]));
			}
		}

		// Remove 
		DWORD	dwSellMin = 0;
		for (int i = 0; i < adwSellPrice.GetSize(); i++)
		{
			if (adwSellPrice[i] < dwSellMin + 1e-4)
			{
				adwSellPrice.RemoveAt(i);
				adwSellVolume.RemoveAt(i);
				i--;
			}
			else
			{
				dwSellMin = adwSellPrice[i];
			}
		}

		DWORD	dwBuyMax = 0;
		for (int i = 0; i < adwBuyPrice.GetSize(); i++)
		{
			if (0 != dwBuyMax && adwBuyPrice[i] > dwBuyMax - 1e-4)
			{
				adwBuyPrice.RemoveAt(i);
				adwBuyVolume.RemoveAt(i);
				i--;
			}
			else
			{
				dwBuyMax = adwBuyPrice[i];
			}
		}
	}

	// Store
	for (k = 0; k < nSize && k < adwSellPrice.GetSize(); k++)
	{
		fSellPrice[k] = float(0.001 * adwSellPrice[k]);
		fSellVolume[k] = float(adwSellVolume[k]);
	}
	for (k = 0; k < nSize && k < adwBuyPrice.GetSize(); k++)
	{
		fBuyPrice[k] = float(0.001 * adwBuyPrice[k]);
		fBuyVolume[k] = float(adwBuyVolume[k]);
	}

	return TRUE;
}

 

   REPORT& rpt = aReport.GetAt(k);

					   //计算算卖5-卖1总量之和
					   for (int i = 0; i < sizeof(rpt.m_fSellVolume) / sizeof(rpt.m_fSellVolume[0]); i++)
						   dVolSell += rpt.m_fSellVolume[i];