以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 高级功能研发区 (http://weistock.com/bbs/list.asp?boardid=5) ---- C++如何获取更多的历史数据和历史指标数据 (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=149940) |
-- 作者:kooex -- 发布时间:2017/3/31 8:39:50 -- C++如何获取更多的历史数据和历史指标数据 如下代码,我需要获取15分钟K线的数据和MACD,SAR指标数据,但最多只能获取到14个,请问有什么办法能获取更多的吗?
STKINDIEX_EXTFUN_ST stFormulaData = {0};
stFormulaData.m_nMarket = \'JZ\';
strcpy(stFormulaData.m_szLabel,"IF06"); //调用浦发银行数据
memset(stFormulaData.m_szIndiName, 0, 256);
//strcpy(stFormulaData.m_szIndiName,"MA.MA2(5,10,20,60)"); //调用MA指标的MA2指标线
strcpy(stFormulaData.m_szIndiName,"SAR.SARV"); //调用MA指标的MA2指标线
stFormulaData.m_nCoType = 0;
stFormulaData.m_nPeriod = 2;
//stFormulaData.m_nPower = 1;
stFormulaData.m_nDataNum = 1000; //调用最近1000周期数据
//通过扩展函数调用
STKINDIEX_EXTFUN_DATA_RET * pSARData = (STKINDIEX_EXTFUN_DATA_RET*)g_pMainFormework->ExpandFunction(&stFormulaData,STKINDIEX_EXTFUN);
memset(stFormulaData.m_szIndiName, 0, 256);
strcpy(stFormulaData.m_szIndiName,"MACD.DEA"); //调用MA指标的MA2指标线
STKINDIEX_EXTFUN_DATA_RET * pMACDData = (STKINDIEX_EXTFUN_DATA_RET*)g_pMainFormework->ExpandFunction(&stFormulaData,STKINDIEX_EXTFUN);
PCALCINFO stData = {0};
stData.m_dataType = MIN15_DATA;//日线
//stData.m_bIsPow = 1; //是否复权
stData.m_wMarket = \'JZ\';
strcpy(stData.m_szLabel,"IF06"); //读取600000 浦发银行数据
if(g_pMainFormework->GetDataInfo(&stData)==0 || pSARData->m_nDataCount <= 0 || pMACDData->m_nDataCount <= 0)
{
AfxMessageBox("调用失败。");
return;
}
CString strMsg;
strMsg.Format("%d, %d, %d",stData.m_nNumData,pSARData->m_nDataCount,pMACDData->m_nDataCount);
AfxMessageBox(strMsg);
int nSize = pSARData->m_nDataCount;
if(nSize > pMACDData->m_nDataCount) nSize = pMACDData->m_nDataCount;
if(nSize > stData.m_nNumData) nSize = stData.m_nNumData;
CString strAllData;
for(int i=0; i<nSize; i++)
{
CString strOneData;
COleDateTime time = pSARData->m_pValues[i].m_timeDate;
strOneData.Format("%s,%f,%f,%f,%f,%f,%f,%f\\n",time.Format("%Y/%m/%d %H:%M:%S"),stData.m_pMainData[i].m_fOpen, stData.m_pMainData[i].m_fHigh, stData.m_pMainData[i].m_fLow, stData.m_pMainData[i].m_fClose, stData.m_pMainData[i].m_fVolume, pSARData->m_pValues[i].m_dbValues, pMACDData->m_pValues[i].m_dbValues);
strAllData += strOneData;
}
CFile file;
file.Open("D:\\\\data.txt",CFile::modeCreate|CFile::modeReadWrite);
file.Write(strAllData,strAllData.GetLength());
file.Close();
AfxMessageBox("OK");
return; |
-- 作者:yukizzc -- 发布时间:2017/3/31 10:07:02 -- 打开图表看下本地数据是否齐全。 |