当前位置: 首页>>代码示例>>C++>>正文


C++ CKData::SetSize方法代码示例

本文整理汇总了C++中CKData::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CKData::SetSize方法的具体用法?C++ CKData::SetSize怎么用?C++ CKData::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CKData的用法示例。


在下文中一共展示了CKData::SetSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DayToMonth

int CKData::DayToMonth( CKData &kdday, CKData &kdmonth )
{
	// convert day k line to month k line
	SP_ASSERT( ktypeDay == kdday.GetKType() );
	SP_ASSERT( ktypeMonth == kdmonth.GetKType() );

	kdmonth.SetSize( 0, kdday.GetSize() / 20 + 5 );
	
	int nStart		=	kdday.GetSize() % 3;
	int	nCount		=	0;
	KDATA	dataDest;
	memset( &dataDest, 0, sizeof(dataDest) );
	int	nYearCur = 0, nMonthCur = 0 ;
	for( int pos=nStart; pos<kdday.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdday.ElementAt( pos );

		CSPTime	tm;
		if( !tm.FromStockTimeDay(dataSrc.m_date) )
			continue;
		int nYear	=	tm.GetYear();
		int nMonth	=	tm.GetMonth();

		if( nYear != nYearCur || nMonth != nMonthCur )	// a new month
		{
			if( 0 != pos )
				kdmonth.Add( dataDest );				// add a month

			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );	// begin a new month
			nYearCur	=	nYear;
			nMonthCur	=	nMonth;
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}

		if( pos == kdday.GetSize()-1 )	// the latest one
			kdmonth.Add( dataDest );
	}

	return kdmonth.GetSize();
}
开发者ID:darwinbeing,项目名称:trade,代码行数:47,代码来源:KData.cpp

示例2: DayToWeek

int CKData::DayToWeek( CKData &kdday, CKData &kdweek )
{
	// convert day k line to week k line
	SP_ASSERT( ktypeDay == kdday.GetKType() );
	SP_ASSERT( ktypeWeek == kdweek.GetKType() );

	kdweek.SetSize( 0, kdday.GetSize() / 5 + 5 );
	
	int nStart		=	kdday.GetSize() % 3;
	int	nCount		=	0;
	KDATA	dataDest;
	memset( &dataDest, 0, sizeof(dataDest) );
	for( int pos=nStart; pos<kdday.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdday.ElementAt( pos );

		CSPTime	tm;
		if( !tm.FromStockTimeDay(dataSrc.m_date) )
			continue;

		if( tm.GetDayOfWeek() == 2 )	// a new week
		{
			if( 0 != pos )
				kdweek.Add( dataDest );				// add a week

			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );	// begin a new week
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}

		if( pos == kdday.GetSize()-1 )	// the latest one
			kdweek.Add( dataDest );
	}

	return kdweek.GetSize();
}
开发者ID:darwinbeing,项目名称:trade,代码行数:42,代码来源:KData.cpp

示例3: ConvertKData

/////////////////////////////////////////////////////////////////////////////
// Private Operations
int CKData::ConvertKData( CKData &kdSrc, CKData &kdDest, int multiple )
{
	// convert kdSrc k line to kdDest k line accordding to their multiple
	SP_ASSERT( multiple > 1 );
	if( multiple < 2 )	return 0;

	kdDest.SetSize( 0, kdSrc.GetSize() / multiple + 5 );
	
	int nStart		=	kdSrc.GetSize() % multiple;
	int	nCount		=	0;
	KDATA	dataDest;
	for( int pos=nStart; pos<kdSrc.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdSrc.ElementAt( pos );

		nCount	++;
		if( 1 == nCount )
		{
			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}
		
		if( multiple == nCount )	// new dataDest is over
		{
			nCount	=	0;
			kdDest.Add( dataDest );
		}
	}
	
	return kdDest.GetSize();
}
开发者ID:darwinbeing,项目名称:trade,代码行数:40,代码来源:KData.cpp


注:本文中的CKData::SetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。