📄 realtime.cpp
字号:
pDC->FillSolidRect( &m_rectMMLD, clrBK );
pDC->Draw3dRect( &m_rectMMLD, clrBorder, clrBorder );
// Draw Title
CString strMMLD;
strMMLD="买卖力道";
DrawTechTitle( pDC, m_rectMMLD.left+5, m_rectMMLD.top+1, strMMLD, TA_LEFT | TA_TOP, 14, clrBK, clrTitle );
// Draw
CStockInfo & info = m_CurStock.GetStockInfo();
CReport & aReport = m_CurStock.GetReport();
// Draw Axis
double dMin = 0, dMax = 0;
if( !aReport.GetMMLDMinMaxInfo( &dMin, &dMax )
|| !DrawAxis( pDC, m_rectMMLD, 0, 5, dMin*0.01, dMax*0.01, FALSE, FALSE, 0 ) )
return;
// Draw
DWORD secNow = CSPTime::GetCurrentTime().ToStockTimeSecOrder();
DWORD secStep = 60;
int ptr = 0;
int xPos = m_rectMMLD.left;
int yPosBuy = m_rectMMLD.top+m_rectMMLD.Height()/2;
int yPosSell = yPosBuy, yPosDiff = yPosBuy;
COLORREF clrLine1 = AfxGetProfile().GetColor(CColorClass::clrLine1);
COLORREF clrLine2 = AfxGetProfile().GetColor(CColorClass::clrLine3);
DWORD dwSeconds = CSPTime::GetTradeSecondsOfOneDay();
for( DWORD sec=0; sec<=dwSeconds; sec+=secStep )
{
BOOL bDrawed = FALSE;
for( ; ptr<aReport.GetSize(); ptr++ )
{
DWORD secTemp = CSPTime(aReport[ptr].m_time).ToStockTimeSecOrder();
if( secTemp > sec )
break;
if( (long)secTemp <= (long)sec-(long)secStep )
continue;
int xPosNew = m_rectMMLD.left+m_rectMMLD.Width()*secTemp/dwSeconds;
double dVolBuy = 0, dVolSell = 0, dVolDiff = 0;
if( !aReport.GetMMLD( ptr, &dVolBuy, &dVolSell, &dVolDiff ) )
break;
// Draw Buy Line
CPen pen1( PS_SOLID, 1, clrLine1 );
CPen * pOldPen = pDC->SelectObject( &pen1 );
pDC->MoveTo( xPos, yPosBuy );
if( dVolBuy <= dMax && dVolBuy >= dMin && dMax-dMin > 1e-4)
{
yPosBuy = (int)( m_rectMMLD.top+m_rectMMLD.Height()*(dMax-dVolBuy)/(dMax-dMin) );
if( yPosBuy <= m_rectMMLD.top ) yPosBuy = m_rectMMLD.top+1;
if( yPosBuy >= m_rectMMLD.bottom ) yPosBuy = m_rectMMLD.bottom-1;
pDC->LineTo( xPosNew, yPosBuy );
}
// Draw Sell Line
CPen pen2( PS_SOLID, 1, clrLine2 );
pDC->SelectObject( &pen2 );
pDC->MoveTo( xPos, yPosSell );
if( dVolSell <= dMax && dVolSell >= dMin )
{
yPosSell = (int)( m_rectMMLD.top+m_rectMMLD.Height()*(dMax-dVolSell)/(dMax-dMin) );
if( yPosSell <= m_rectMMLD.top ) yPosSell = m_rectMMLD.top+1;
if( yPosSell >= m_rectMMLD.bottom ) yPosSell = m_rectMMLD.bottom-1;
pDC->LineTo( xPosNew, yPosSell );
}
// Draw Diff Line
CPen pen3( PS_SOLID, 1, dVolDiff > 0 ? clrRise : clrFall );
pDC->SelectObject( &pen3 );
pDC->MoveTo( xPosNew, m_rectMMLD.top+m_rectMMLD.Height()/2 );
if( dVolDiff*0.5 <= dMax && dVolDiff*0.5 >= dMin && dMax-dMin > 1e-4 )
{
yPosDiff = (int)( m_rectMMLD.bottom-m_rectMMLD.Height()*(dVolDiff*0.5+dMax-dMin)*0.5/(dMax-dMin) );
if( yPosDiff <= m_rectMMLD.top ) yPosDiff = m_rectMMLD.top+1;
if( yPosDiff >= m_rectMMLD.bottom ) yPosDiff = m_rectMMLD.bottom-1;
pDC->LineTo( xPosNew, yPosDiff );
}
pDC->SelectObject( pOldPen );
xPos = xPosNew;
bDrawed = TRUE;
}
if( !bDrawed && sec <= secNow )
{
int xPosNew = m_rectMMLD.left+m_rectMMLD.Width()*sec/dwSeconds;
// Draw Buy Line
CPen pen1( PS_SOLID, 1, clrLine1 );
CPen * pOldPen = pDC->SelectObject( &pen1 );
pDC->MoveTo( xPos, yPosBuy );
pDC->LineTo( xPosNew, yPosBuy );
// Draw Sell Line
CPen pen2( PS_SOLID, 1, clrLine2 );
pDC->SelectObject( &pen2 );
pDC->MoveTo( xPos, yPosSell );
pDC->LineTo( xPosNew, yPosSell );
// Draw Diff Line
CPen pen3( PS_SOLID, 1, yPosDiff > m_rectMMLD.top+m_rectMMLD.Height() ? clrRise : clrFall );
pDC->SelectObject( &pen3 );
pDC->MoveTo( xPosNew, m_rectMMLD.top+m_rectMMLD.Height()/2 );
pDC->LineTo( xPosNew, yPosDiff );
pDC->SelectObject( pOldPen );
xPos = xPosNew;
}
}
}
int CRealTime::DrawBuySell( CDC * pDC, int xStart, int yStart, int nWidth )
{
DECLARE_COLOR_DEFINATION
CStockInfo & info = m_CurStock.GetStockInfo();
CString strTemp, strTempFmt;
// Draw Name And Code
CFont * pOldFont = AfxSelectDCFont( pDC, 18 );
pDC->SetTextColor( clrTitle );
pDC->TextOut( xStart+1, m_rectAll.top+3, info.GetStockName() );
pDC->SetTextColor( clrText );
pDC->TextOut( xStart+96, m_rectAll.top+3, info.GetStockCode() );
// Select Report Font
AfxSelectDCFont( pDC, 14 );
// Draw Report Names
int x = xStart+2;
int x2 = xStart+2+nWidth/2;
int y = yStart;
pDC->SetTextColor( clrText );
// 委比和委差
strTemp = "委比"; // "委比";
pDC->TextOut( x, y+2, strTemp );
strTemp = "委差"; // "委差";
pDC->TextOut( x2, y+2, strTemp );
// 委卖数
DrawLine( pDC, 1, clrBorder, xStart, y+19, xStart+nWidth, y+19 );
strTemp = "卖⑤"; // "卖⑤";
pDC->TextOut( x, y+21, strTemp );
strTemp = "卖④"; // "卖④";
pDC->TextOut( x, y+37, strTemp );
strTemp = "卖③"; // "卖③";
pDC->TextOut( x, y+53, strTemp );
strTemp = "卖②"; // "卖②";
pDC->TextOut( x, y+69, strTemp );
strTemp = "卖①"; // "卖①";
pDC->TextOut( x, y+85, strTemp );
// 委买数
DrawLine( pDC, 1, clrBorder, xStart, y+102, xStart+nWidth, y+102 );
strTemp = "买①"; // "买①";
pDC->TextOut( x, y+104, strTemp );
strTemp = "买②"; // "买②";
pDC->TextOut( x, y+120, strTemp );
strTemp = "买③"; // "买③";
pDC->TextOut( x, y+136, strTemp );
strTemp = "买④"; // "买④";
pDC->TextOut( x, y+152, strTemp );
strTemp = "买⑤"; // "买⑤";
pDC->TextOut( x, y+168, strTemp );
// 其他信息报告
DrawLine( pDC, 1, clrBorder, xStart, y+185, xStart+nWidth, y+185 );
strTemp = "成交"; // "成交";
pDC->TextOut( x, y+187, strTemp );
strTemp = "均价"; // "均价";
pDC->TextOut( x2, y+187, strTemp );
strTemp = "涨跌"; // "涨跌";
pDC->TextOut( x, y+203, strTemp );
strTemp = "开盘"; // "开盘";
pDC->TextOut( x2, y+203, strTemp );
strTemp = "幅度"; // "幅度";
pDC->TextOut( x, y+219, strTemp );
strTemp = "最高"; // "最高";
pDC->TextOut( x2, y+219, strTemp );
strTemp = "总手"; // "总手";
pDC->TextOut( x, y+235, strTemp );
strTemp = "最低"; // "最低";
pDC->TextOut( x2, y+235, strTemp );
strTemp = "现手"; // "现手";
pDC->TextOut( x, y+251, strTemp );
strTemp = "量比"; // "量比";
pDC->TextOut( x2, y+251, strTemp );
// 内外盘
DrawLine( pDC, 1, clrBorder, xStart, y+268, xStart+nWidth, y+268 );
strTemp = "外盘"; // "外盘";
pDC->TextOut( x, y+270, strTemp );
strTemp = "内盘"; // "内盘";
pDC->TextOut( x2, y+270, strTemp );
DrawLine( pDC, 1, clrBorder, xStart, y+287, xStart+nWidth, y+287 );
// 涨家数,跌家数
if( info.IsIndex() )
{
strTemp = "涨家数"; // "涨家数";
pDC->TextOut( x, y+289, strTemp );
strTemp = "跌家数"; // "跌家数";
pDC->TextOut( x2, y+289, strTemp );
DrawLine( pDC, 1, clrBorder, xStart, y+306, xStart+nWidth, y+306 );
}
// Draw Report Values
x = xStart-1+nWidth/2;
x2 = xStart+nWidth-1;
UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
pDC->SetTextColor( clrPlane );
// 价格小数位数格式串
CString strPriceFmt;
strPriceFmt.Format( "%%.%df", info.DigitBit() );
if( info.IsIndex() )
{
// 委比和委差
double dRatio = 0, dDiff = 0;
strTemp.Format( "%.2f%%", dRatio );
pDC->TextOut( x, y+2, strTemp );
strTemp.Format( "%.0f", dDiff*0.01 );
pDC->TextOut( x2, y+2, strTemp );
// 委卖数
pDC->SetTextColor( clrText );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+21, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+21, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+37, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+37, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+53, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+53, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+69, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+69, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+85, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+85, strTemp );
// 委买数
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+104, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+104, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+120, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+120, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+136, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+136, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+152, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+152, strTemp );
strTemp.Format( strPriceFmt, 0.0f );
pDC->TextOut( x, y+168, strTemp );
strTemp.Format( "%.0f", 0.0f );
pDC->TextOut( x2, y+168, strTemp );
}
else
{
// 委比和委差
double dRatio = 0, dDiff = 0;
if( info.GetSellBuyRatio( &dRatio, &dDiff ) )
{
strTemp.Format( "%.2f%%", dRatio );
pDC->TextOut( x, y+2, strTemp );
strTemp.Format( "%.0f", dDiff*0.01 );
pDC->TextOut( x2, y+2, strTemp );
}
// 委卖数
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fSellPrice[4],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fSellPrice[4] );
pDC->TextOut( x, y+21, strTemp );
strTemp.Format( "%.0f", info.m_fSellVolume[4]/100 );
pDC->TextOut( x2, y+21, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fSellPrice[3],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fSellPrice[3] );
pDC->TextOut( x, y+37, strTemp );
strTemp.Format( "%.0f", info.m_fSellVolume[3]/100 );
pDC->TextOut( x2, y+37, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fSellPrice[2],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fSellPrice[2] );
pDC->TextOut( x, y+53, strTemp );
strTemp.Format( "%.0f", info.m_fSellVolume[2]/100 );
pDC->TextOut( x2, y+53, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fSellPrice[1],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fSellPrice[1] );
pDC->TextOut( x, y+69, strTemp );
strTemp.Format( "%.0f", info.m_fSellVolume[1]/100 );
pDC->TextOut( x2, y+69, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fSellPrice[0],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fSellPrice[0] );
pDC->TextOut( x, y+85, strTemp );
strTemp.Format( "%.0f", info.m_fSellVolume[0]/100 );
pDC->TextOut( x2, y+85, strTemp );
// 委买数
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fBuyPrice[0],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fBuyPrice[0] );
pDC->TextOut( x, y+104, strTemp );
strTemp.Format( "%.0f", info.m_fBuyVolume[0]/100 );
pDC->TextOut( x2, y+104, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fBuyPrice[1],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fBuyPrice[1] );
pDC->TextOut( x, y+120, strTemp );
strTemp.Format( "%.0f", info.m_fBuyVolume[1]/100 );
pDC->TextOut( x2, y+120, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fBuyPrice[2],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fBuyPrice[2] );
pDC->TextOut( x, y+136, strTemp );
strTemp.Format( "%.0f", info.m_fBuyVolume[2]/100 );
pDC->TextOut( x2, y+136, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fBuyPrice[3],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fBuyPrice[3] );
pDC->TextOut( x, y+152, strTemp );
strTemp.Format( "%.0f", info.m_fBuyVolume[3]/100 );
pDC->TextOut( x2, y+152, strTemp );
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fBuyPrice[4],info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fBuyPrice[4] );
pDC->TextOut( x, y+168, strTemp );
strTemp.Format( "%.0f", info.m_fBuyVolume[4]/100 );
pDC->TextOut( x2, y+168, strTemp );
}
// 其他信息报告
// 成交
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fClose,info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fClose );
pDC->TextOut( x, y+187, strTemp );
// 均价
pDC->SetTextColor( clrPlane );
strTemp = "-";
if( info.m_fVolume > 0 )
{
double dAve = info.m_fAmount/info.m_fVolume;
pDC->SetTextColor( RT_DETERMINE_COLOR(dAve,info.m_fLast) );
strTemp.Format( strPriceFmt, dAve );
}
pDC->TextOut( x2, y+187, strTemp );
// 涨跌
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fClose,info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fClose-info.m_fLast );
pDC->TextOut( x, y+203, strTemp );
// 开盘
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fOpen,info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fOpen );
pDC->TextOut( x2, y+203, strTemp );
// 幅度
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fClose,info.m_fLast) );
strTemp = "-";
if( info.m_fLast > 1e-4 )
strTemp.Format( "%.2f%%", 100*(info.m_fClose-info.m_fLast)/info.m_fLast );
pDC->TextOut( x, y+219, strTemp );
// 最高
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fHigh,info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fHigh );
pDC->TextOut( x2, y+219, strTemp );
// 总手
pDC->SetTextColor( clrPlane );
strTemp.Format( "%.0f", info.m_fVolume/100. );
pDC->TextOut( x, y+235, strTemp );
// 最低
pDC->SetTextColor( RT_DETERMINE_COLOR(info.m_fLow,info.m_fLast) );
strTemp.Format( strPriceFmt, info.m_fLow );
pDC->TextOut( x2, y+235, strTemp );
// 现手
pDC->SetTextColor( clrPlane );
strTemp = "-";
double dVolNow = 0, dVolOuter = 0, dVolInner = 0;
BOOL bStatSuc = m_CurStock.GetMinute().StatVolumeInfo( &dVolNow, &dVolOuter, &dVolInner );
if( bStatSuc )
strTemp.Format( "%.0f", dVolNow/100. );
pDC->TextOut( x, y+251, strTemp );
// 量比
pDC->SetTextColor( clrPlane );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -