本文整理汇总了C++中CKData::GetKType方法的典型用法代码示例。如果您正苦于以下问题:C++ CKData::GetKType方法的具体用法?C++ CKData::GetKType怎么用?C++ CKData::GetKType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKData
的用法示例。
在下文中一共展示了CKData::GetKType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateStockContainerByKData
BOOL UpdateStockContainerByKData( CStockContainer &container, LPCTSTR lpszCode, CKData & kdata )
{
container.Lock();
int id = 0;
if( CKData::ktypeDay == kdata.GetKType()
&& container.GetStockInfo( lpszCode, NULL, &id ) )
{
CStockInfo & info = container.ElementAt(id);
if( kdata.GetSize() > (int)AfxGetProfile().GetCacheDays() )
{
// 只使用AfxGetProfile().GetCacheDays()天的数据
CKData temp( kdata.GetKType() );
for( int i=kdata.GetSize()-AfxGetProfile().GetCacheDays(); i<kdata.GetSize(); i++ )
temp.Add( kdata.ElementAt(i) );
info.m_kdata.MergeKData( &temp );
}
else
info.m_kdata.MergeKData( &kdata );
// 指数涨跌家数
int nSize = info.m_kdata.GetSize();
if( nSize > 0 )
{
info.m_dwAdvance = info.m_kdata.ElementAt(nSize-1).m_dwAdvance;
info.m_dwDecline = info.m_kdata.ElementAt(nSize-1).m_dwDecline;
}
}
container.UnLock();
return TRUE;
}
示例2: FullFillKData
int CKData::FullFillKData( CKData & kdataMain, BOOL bFillToEnd )
{
SP_ASSERT( GetKType() == kdataMain.GetKType() );
if( GetKType() != kdataMain.GetKType() )
return 0;
if( GetSize() == 0 || kdataMain.GetSize() == 0 )
return 0;
DWORD dateBegin = ElementAt(0).m_date;
DWORD dateMainEnd5 = (kdataMain.GetSize() >= 5 ? kdataMain.ElementAt(kdataMain.GetSize()-5).m_date : 0);
DWORD dateEnd5 = (GetSize() >= 5 ? ElementAt(GetSize()-5).m_date : 0);
int iMain = 0, iSelf = 0;
for( iMain=0; iMain<kdataMain.GetSize(); iMain ++ )
{
if( dateBegin == kdataMain.ElementAt(iMain).m_date )
break;
}
SetSize( GetSize(), kdataMain.GetSize()-iMain-GetSize() > 0 ? kdataMain.GetSize()-iMain-GetSize() : -1 );
int nCount = 0;
for( ; iMain <= kdataMain.GetSize() && iSelf <= GetSize(); iMain++, iSelf++ )
{
if( !bFillToEnd && iSelf == GetSize() && ElementAt(iSelf-1).m_date < dateMainEnd5 )
break;
if( !bFillToEnd && iMain == kdataMain.GetSize() && kdataMain.ElementAt(iMain-1).m_date < dateEnd5 )
break;
while( iMain > 0 && iMain <= kdataMain.GetSize() && iSelf < GetSize()
&& ( iMain == kdataMain.GetSize() || kdataMain.ElementAt(iMain).m_date > ElementAt(iSelf).m_date ) )
{
// KDATA kd;
// memset( &kd, 0, sizeof(kd) );
// kd.m_date = ElementAt(iSelf).m_date;
// kd.open = kd.high = kd.low = kd.close = kdataMain.ElementAt(iMain-1).close;
// kdataMain.InsertAt( iMain, kd );
// iMain ++;
iSelf ++;
// nCount ++;
}
while( iMain < kdataMain.GetSize() && iSelf <= GetSize() && iSelf > 0
&& ( iSelf == GetSize() || kdataMain.ElementAt(iMain).m_date < ElementAt(iSelf).m_date ) )
{
KDATA kd;
memset( &kd, 0, sizeof(kd) );
kd.m_date = kdataMain.ElementAt(iMain).m_date;
kd.m_fOpen = kd.m_fHigh = kd.m_fLow = kd.m_fClose = ElementAt(iSelf-1).m_fClose;
InsertAt( iSelf, kd );
iMain ++;
iSelf ++;
nCount ++;
}
}
return nCount;
}
示例3: 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();
}
示例4: 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();
}
示例5: ConvertKData
int CKData::Min5ToMin60( CKData &kdm5, CKData &kdm60 )
{
SP_ASSERT( ktypeMin5 == kdm5.GetKType() );
SP_ASSERT( ktypeMin60 == kdm60.GetKType() );
return ConvertKData( kdm5, kdm60, 12 );
}