Example #1
0
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;
}
Example #2
0
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 );
}
Example #3
0
BOOL AfxPrepareStockData( CStDatabase * pDatabase, CStock &stock, int nKType, int nKFormat, int nMaindataType, BOOL bFullFill, BOOL bReload )
{
	CStockInfo	info;
	if( !AfxGetStockContainer().GetStockInfo( stock.GetStockCode(), &info ) )
		info	=	stock.GetStockInfo( );

	stock.SetDatabase( pDatabase );
	stock.PrepareData( CStock::dataK, CKData::ktypeDay, bReload );
	stock.PrepareData( CStock::dataK, CKData::ktypeMin5, bReload );
	stock.PrepareData( CStock::dataDR, CKData::ktypeDay, bReload );
	if( bReload || stock.GetKDataDay().GetCurFormat() == CKData::formatOriginal )
		stock.GetKDataDay().MergeKData( &(info.m_kdata) );
	
	CKData	& kday	=	stock.GetKData(CKData::ktypeDay);
	CKData	& kdata	=	stock.GetKData( nKType );
	kdata.SetDRData( stock.GetDRData() );
	kday.SetDRData( stock.GetDRData() );
	if( bFullFill )
		kday.FullFillKData( AfxGetStockMain().GetKDataDay(), FALSE );
	kday.ChangeCurFormat( nKFormat, AfxGetProfile().GetAutoResumeDRBegin(), AfxGetProfile().GetAutoResumeDRLimit() );
	if( CKData::ktypeWeek == nKType || CKData::ktypeMonth == nKType )
	{
		// 周线和月线不能ChangeCurFormat(...)
		if( CKData::formatOriginal == nKFormat )
			stock.PrepareData( CStock::dataK, nKType, bReload );
		else
			stock.ExtractKData( nKType, TRUE );
	}
	else if( CKData::ktypeDay != nKType )
	{
		stock.PrepareData( CStock::dataK, nKType, bReload );
		kdata.ChangeCurFormat( nKFormat, AfxGetProfile().GetAutoResumeDRBegin(), AfxGetProfile().GetAutoResumeDRLimit() );
	}
	kdata.SetMaindataType( nMaindataType );
	return TRUE;
}