本文整理汇总了C++中CKData::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CKData::Add方法的具体用法?C++ CKData::Add怎么用?C++ CKData::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKData
的用法示例。
在下文中一共展示了CKData::Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例3: OnStkReceiverData
LRESULT CDownloadDlg::OnStkReceiverData(WPARAM wParam, LPARAM lParam)
{
PCOMMPACKET pCommPacket = (PCOMMPACKET)lParam;
switch( wParam )
{
case CStock::dataReport:
if( pCommPacket && CStock::dataReport == pCommPacket->m_dwDataType
&& pCommPacket->m_dwCount > 0 )
{
m_nReportCount += pCommPacket->m_dwCount;
for( DWORD i=0; i<pCommPacket->m_dwCount; i++ )
{
CKData kdata;
kdata.SetKType( CKData::ktypeDay );
KDATA kd;
if( UpdateKDATAByREPORT( kd, &(pCommPacket->m_pReport[i]) ) )
{
kdata.Add( kd );
AfxGetDB().InstallKData( kdata, FALSE );
}
}
CStockContainer & container = AfxGetStockContainer();
if( m_nReportRequestSent - m_nReportCount < 64 && m_nReportRequestSent < (UINT)container.GetSize() )
{
container.Lock();
m_nReportRequestSent += AfxGetStkReceiver().RequestStockData( CStock::dataReport, container.GetData()+m_nReportRequestSent, min(160,container.GetSize()-m_nReportRequestSent), 0, 0 );
container.UnLock();
}
if( !m_bReportFinished && m_nReportCount > 0.95 * m_nReportTotal )
{
m_bReportFinished = TRUE;
::SendMessage( GetSafeHwnd(), WM_USER_DOWNLOAD_PROGRESS, STKLIB_MAX_PROGRESS, NULL );
AfxBeginThread( DownloadMain, (LPVOID)m_pDownloadInfo,THREAD_PRIORITY_NORMAL);
}
else if( !m_bReportFinished && m_nReportTotal > 0 )
{
DWORD dwProgress = STKLIB_MAX_PROGRESS * m_nReportCount / m_nReportTotal;
::SendMessage( GetSafeHwnd(), WM_USER_DOWNLOAD_PROGRESS, dwProgress, NULL );
}
}
break;
}
return 0L;
}
示例4: 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();
}