30 Star 78 Fork 79

liuyinghua/FastTrader

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
PV.cpp 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
liuyinghua 提交于 2018-05-08 01:05 +08:00 . 整个项目的编译
#include "PV.h"
#include "Tech.h"
#include "../FacilityBaseLib/KData.h"
//////////////////////////////////////////////////////////////////////
// CPV
CPV::CPV( )
{
SetDefaultParameters( );
}
CPV::CPV( KdataContainer * pKData )
: TechnicalIndicator( pKData )
{
SetDefaultParameters( );
}
CPV::~CPV()
{
clear( );
}
void CPV::SetDefaultParameters( )
{
}
void CPV::attach( CPV & src )
{
}
bool CPV::IsValidParameters( )
{
return true;
}
void CPV::clear( )
{
TechnicalIndicator::clear( );
}
int CPV::signal( int nIndex, UINT * pnCode )
{
if( pnCode ) *pnCode = ITSC_NOTHING;
// 无买卖信号
return ITS_NOTHING;
}
bool CPV::min_max_info(int nStart, int nEnd,
double *pdMin, double *pdMax )
{
return AfxGetMinMaxInfo1( nStart, nEnd, pdMin, pdMax, this );
}
/***
PV就是当日成交均价,成交额除以成交量
*/
bool CPV::calc( double * pValue, int nIndex, bool bUseLast )
{
STT_ASSERT_CALCULATE1( m_pKData, nIndex );
if( load_from_cache( nIndex, pValue ) )
return true;
KDATA kd = m_pKData->at(nIndex);
if( kd.Volume <= 1e-4 || kd.Turnover <= 1e-4 )
return false;
int nCount = 0;
double average = ((double)(kd.Turnover)) / kd.Volume;
while( average < kd.LowestPrice && nCount < 10 ) { average *= 10; nCount ++; }
while( average > kd.HighestPrice && nCount < 20 ) { average /= 10; nCount ++; }
if( average < kd.LowestPrice ) // 说明是指数
average = (kd.OpenPrice+kd.HighestPrice+kd.LowestPrice+kd.ClosePrice)/4;
double dPV = average;
if( pValue )
*pValue = dPV;
store_to_cache( nIndex, pValue );
return true;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mongodb_client/FastTrader.git
[email protected]:mongodb_client/FastTrader.git
mongodb_client
FastTrader
FastTrader
master

搜索帮助