本文整理汇总了C++中CStockInfo::SetStockCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CStockInfo::SetStockCode方法的具体用法?C++ CStockInfo::SetStockCode怎么用?C++ CStockInfo::SetStockCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStockInfo
的用法示例。
在下文中一共展示了CStockInfo::SetStockCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateStockContainerByREPORT
// update CStockContainer by Report data
BOOL UpdateStockContainerByREPORT( CStockContainer &container, REPORT * pReport, BOOL bAddIfNotExist, REPORT * pReportLast )
{
SP_ASSERT( pReport );
if( NULL == pReport )
return FALSE;
REPORT reportLast;
memset( &reportLast, 0, sizeof(reportLast) );
int id = 0;
if( container.GetStockInfo( pReport->m_szCode, NULL, &id ) )
{
container.Lock();
CStockInfo & info = container.ElementAt(id);
reportLast = info.m_reportLatest;
UpdateStockInfoByREPORT( info, pReport );
container.UnLock();
}
else if( bAddIfNotExist && strlen(pReport->m_szCode)>0 )
{
CStockInfo info;
info.SetStockCode( pReport->m_dwMarket, pReport->m_szCode );
if( UpdateStockInfoByREPORT( info, pReport ) )
{
container.Add( info );
}
}
if( pReportLast )
memcpy( pReportLast, &reportLast, sizeof(reportLast) );
return TRUE;
}
示例2: DeleteKData
BOOL CSetKDataDlg::DeleteKData( CString strStockCode )
{
if( strStockCode.GetLength() <= 0 )
return FALSE;
UpdateData( );
if( m_tmDate.GetTime() == -1 )
return FALSE;
CStockInfo info;
CStock stock;
if( !info.SetStockCode( CStock::marketUnknown, strStockCode ) )
return FALSE;
stock.SetStockInfo( &info );
int nKType = m_comboKType.GetSelect();
AfxPrepareStockData( &AfxGetDB(), stock, nKType, CKData::formatOriginal, CKData::mdtypeClose, FALSE, TRUE );
CKData & kdata = stock.GetKData(nKType);
CSPTime sptime = m_tmDate.GetTime();
int nIndex = kdata.GetIndexByDate( sptime.ToStockTime(CKData::IsDayOrMin(kdata.GetKType())) );
if( nIndex >= 0 && nIndex < kdata.GetSize() )
{
kdata.RemoveAt(nIndex);
AfxGetDB().InstallKData( kdata, TRUE );
return TRUE;
}
return FALSE;
}
示例3: LoadKData
void CSetKDataDlg::LoadKData( CString strStockCode )
{
if( strStockCode.GetLength() <= 0 )
return;
UpdateData();
m_strOpen.Empty();
m_strHigh.Empty();
m_strLow.Empty();
m_strClose.Empty();
m_dwVolume = 0;
m_dwAmount = 0;
if( m_tmDate.GetTime() == -1 )
{
UpdateData( FALSE );
return;
}
CStockInfo info;
CStock stock;
if( !info.SetStockCode( CStock::marketUnknown, strStockCode ) )
return;
stock.SetStockInfo( &info );
int nKType = m_comboKType.GetSelect();
AfxPrepareStockData( &AfxGetDB(), stock, nKType, CKData::formatOriginal, CKData::mdtypeClose, FALSE, TRUE );
CKData & kdata = stock.GetKData(nKType);
// 价格小数位数格式串
CString strPriceFmt;
strPriceFmt.Format( "%%.%df", info.DigitBit() );
CSPTime sptime = m_tmDate.GetTime();
int nIndex = kdata.GetIndexByDate( sptime.ToStockTime(CKData::IsDayOrMin(kdata.GetKType())) );
if( nIndex >= 0 && nIndex < kdata.GetSize() )
{
KDATA kd = kdata.ElementAt(nIndex);
m_strOpen.Format( strPriceFmt, kd.m_fOpen );
m_strHigh.Format( strPriceFmt, kd.m_fHigh );
m_strLow.Format( strPriceFmt, kd.m_fLow );
m_strClose.Format( strPriceFmt, kd.m_fClose );
m_dwVolume = (DWORD)(kd.m_fVolume/100);
m_dwAmount = (DWORD)(kd.m_fAmount/1000);
}
UpdateData( FALSE );
}
示例4: StoreKData
BOOL CSetKDataDlg::StoreKData( CString strStockCode )
{
if( strStockCode.GetLength() <= 0 )
return FALSE;
UpdateData( );
if( m_tmDate.GetTime() == -1 )
return FALSE;
if( !IsNumber(m_strOpen,FALSE) || !IsNumber(m_strHigh,FALSE) || !IsNumber(m_strLow,FALSE)
|| !IsNumber(m_strClose,FALSE) )
{
AfxMessageBox( IDS_SETKDATA_NOTNUMBER );
return FALSE;
}
DWORD dwMarket = CStock::marketUnknown;
CStockInfo info;
if( info.SetStockCode(dwMarket, strStockCode) )
dwMarket = info.GetMarket();
int nKType = m_comboKType.GetSelect();
CSPTime sptime = m_tmDate.GetTime();
KDATA kd;
memset( &kd, 0, sizeof(kd) );
kd.m_dwMarket = dwMarket;
strncpy( kd.m_szCode, strStockCode, min(sizeof(kd.m_szCode)-1,strStockCode.GetLength()) );
kd.m_time = m_tmDate.GetTime();
kd.m_date = sptime.ToStockTime(CKData::IsDayOrMin(nKType));
kd.m_fOpen = (float)atof(m_strOpen);
kd.m_fHigh = (float)atof(m_strHigh);
kd.m_fLow = (float)atof(m_strLow);
kd.m_fClose = (float)atof(m_strClose);
kd.m_fVolume = (float)m_dwVolume*100;
kd.m_fAmount = (float)m_dwAmount*1000;
CKData kdata(nKType);
kdata.Add( kd );
AfxGetDB().InstallKData( kdata );
return TRUE;
}
示例5: GetCurrentStock
BOOL CStockContainer::GetCurrentStock( CStockInfo * pInfo )
{
CSPMutex::Scoped l(m_mutex);
SP_ASSERT( pInfo );
if( m_nCurrentStock >= 0 && m_nCurrentStock < GetSize() )
{
CStockInfo & info = ElementAt(m_nCurrentStock);
if( pInfo )
* pInfo = info;
return TRUE;
}
else if( m_strCurrentStockCode.GetLength() > 0 )
{
CStockInfo info;
info.SetStockCode( CStock::marketUnknown, m_strCurrentStockCode );
if( pInfo )
*pInfo = info;
return TRUE;
}
return FALSE;
}
示例6: UpdateStockInfoByREPORT
// update CStockInfo by Report data
BOOL UpdateStockInfoByREPORT( CStockInfo & info, REPORT * pReport )
{
SP_ASSERT( pReport );
if( !pReport )
return FALSE;
// 股票市场
if( strlen(pReport->m_szCode) > 0 )
info.SetStockCode( pReport->m_dwMarket, pReport->m_szCode );
if( strlen(pReport->m_szName) > 0 )
info.SetStockName( pReport->m_szName );
if( info.GetType() == 0 )
{
if( CStock::marketSHSE == pReport->m_dwMarket )
info.SetType( CStock::typeshA );
else if( CStock::marketSZSE == pReport->m_dwMarket )
info.SetType( CStock::typeszA );
else
info.SetType( CStock::typeshA );
}
// 成交买卖价量信息
if( pReport->m_fLast > 1e-4 ) info.m_fLast = pReport->m_fLast;
info.m_fOpen = pReport->m_fOpen;
info.m_fHigh = pReport->m_fHigh;
info.m_fLow = pReport->m_fLow;
info.m_fClose = pReport->m_fNew;
info.m_fVolume = pReport->m_fVolume;
info.m_fAmount = pReport->m_fAmount;
info.m_fBuyPrice[0] = pReport->m_fBuyPrice[0];
info.m_fBuyPrice[1] = pReport->m_fBuyPrice[1];
info.m_fBuyPrice[2] = pReport->m_fBuyPrice[2];
info.m_fBuyPrice[3] = pReport->m_fBuyPrice[3];
info.m_fBuyPrice[4] = pReport->m_fBuyPrice[4];
info.m_fBuyVolume[0] = pReport->m_fBuyVolume[0];
info.m_fBuyVolume[1] = pReport->m_fBuyVolume[1];
info.m_fBuyVolume[2] = pReport->m_fBuyVolume[2];
info.m_fBuyVolume[3] = pReport->m_fBuyVolume[3];
info.m_fBuyVolume[4] = pReport->m_fBuyVolume[4];
info.m_fSellPrice[0] = pReport->m_fSellPrice[0];
info.m_fSellPrice[1] = pReport->m_fSellPrice[1];
info.m_fSellPrice[2] = pReport->m_fSellPrice[2];
info.m_fSellPrice[3] = pReport->m_fSellPrice[3];
info.m_fSellPrice[4] = pReport->m_fSellPrice[4];
info.m_fSellVolume[0] = pReport->m_fSellVolume[0];
info.m_fSellVolume[1] = pReport->m_fSellVolume[1];
info.m_fSellVolume[2] = pReport->m_fSellVolume[2];
info.m_fSellVolume[3] = pReport->m_fSellVolume[3];
info.m_fSellVolume[4] = pReport->m_fSellVolume[4];
// K线数据、日期
KDATA kd;
UpdateKDATAByREPORT( kd, pReport );
int nLen = info.m_kdata.GetSize();
if( nLen > 0 && info.m_kdata.ElementAt(nLen-1).m_date == kd.m_date )
info.m_kdata.SetAt( nLen-1, kd );
else
info.m_kdata.Add( kd );
info.m_datetech = kd.m_date;
// 保存
memcpy( &(info.m_reportLatest), pReport, sizeof(info.m_reportLatest) );
return TRUE;
}