第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序,适合做中间变量计算用】
  
- UID
- 2
- 积分
- 2954160
- 威望
- 1427117 布
- 龙e币
- 1527043 刀
- 在线时间
- 13879 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-5-13

|
第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序,适合做中间变量计算用】
头文件声明变量:- //第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序】
- vector<double>SeriesCrossOverPeriod(string PriceType, string periodType); //返回数组形式的period期(day,min60,min30,min15,min15,min10,min5)的pricetype(close,high,low,open)相关价格数据,注意跨的周期一定要比运行周期大
- vector<double>SeriesCrossOverPeriodInst(string PriceType, string periodType,string inst); //返回数组形式的合约(rb2510等)period期(day,min60,min30,min15,min15,min10,min5)的pricetype(close,high,low,open)相关价格数据
- //跨期调用函数(结束)
- //第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序】
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|
|
|
|
|
|
  
- UID
- 2
- 积分
- 2954160
- 威望
- 1427117 布
- 龙e币
- 1527043 刀
- 在线时间
- 13879 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-5-13

|
公式模块增加:- //第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序】
- //返回数组形式的period期(day,min60,min30,min15,min15,min10,min5)的pricetype(close,high,low,open)相关价格数据,注意跨的周期一定要比运行周期大【参数数组为正序,返回数组也为正序】
- vector<double> test::SeriesCrossOverPeriod(string PriceType, string periodType)
- {
- vector<double>newprice;
- newprice.clear();
- RsqBar(periodType, sInst);
- map<string, TKVALUE >::iterator it;
- if (PriceType == "close") {
- for (it = mapK[periodType][sInst].begin(); it != mapK[periodType][sInst].end(); it++)
- {
- newprice.push_back(it->second.dClose);
- }
- }else if (PriceType == "open") {
- for (it = mapK[periodType][sInst].begin(); it != mapK[periodType][sInst].end(); it++)
- {
- newprice.push_back(it->second.dOpen);
- }
- }else if (PriceType == "high") {
- for (it = mapK[periodType][sInst].begin(); it != mapK[periodType][sInst].end(); it++)
- {
- newprice.push_back(it->second.dHigh);
- }
- }else if (PriceType == "low") {
- for (it = mapK[periodType][sInst].begin(); it != mapK[periodType][sInst].end(); it++)
- {
- newprice.push_back(it->second.dLow);
- }
- }
- return newprice;
- }
- //跨周期中品种调用数据(返回数组形式)【参数数组为正序,返回数组也为正序】
- vector<double> test::SeriesCrossOverPeriodInst(string PriceType, string periodType, string inst)
- {
- vector<double>newprice;
- RsqBar(periodType, inst);
- map<string, TKVALUE >::iterator it;
- if (PriceType == "close") {
- for (it = mapK[periodType][inst].begin(); it != mapK[periodType][inst].end(); it++)
- {
- newprice.push_back(it->second.dClose);
- }
- }
- else if (PriceType == "open") {
- for (it = mapK[periodType][inst].begin(); it != mapK[periodType][inst].end(); it++)
- {
- newprice.push_back(it->second.dOpen);
- }
- }
- else if (PriceType == "high") {
- for (it = mapK[periodType][inst].begin(); it != mapK[periodType][inst].end(); it++)
- {
- newprice.push_back(it->second.dHigh);
- }
- }
- else if (PriceType == "low") {
- for (it = mapK[periodType][inst].begin(); it != mapK[periodType][inst].end(); it++)
- {
- newprice.push_back(it->second.dLow);
- }
- }
- return newprice;
- }
- //第十一部分 跨期调用函数【参数数组为正序,返回数组也为正序】
复制代码 |
|
|
|
|
|
|