本文整理汇总了C++中KData::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ KData::empty方法的具体用法?C++ KData::empty怎么用?C++ KData::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KData
的用法示例。
在下文中一共展示了KData::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AmaSpecial
Indicator HKU_API AmaSpecial(const Block& block, KQuery query,
Indicator ama) {
Indicator result;
StockManager& sm = StockManager::instance();
//计算每日股票总数
DatetimeList dateList = sm.getTradingCalendar(query, "SH");
size_t dayTotal = dateList.size();
if (dayTotal == 0) {
result = PRICELIST(PriceList());
result.name("POS");
return result;
}
vector<size_t> numberPerDay(dayTotal);
for (size_t i = 0; i < dayTotal; ++i) {
numberPerDay[i] = 0;
for (auto stk_iter = block.begin(); stk_iter != block.end(); ++stk_iter) {
if (stk_iter->startDatetime() <= dateList[i]
&& dateList[i] <= stk_iter->lastDatetime()) {
numberPerDay[i]++;
}
}
}
vector<size_t> position(dayTotal);
size_t discard = ama.discard();
for (auto stk_iter = block.begin(); stk_iter != block.end(); ++stk_iter) {
KData kdata = stk_iter->getKData(query);
if (kdata.empty())
continue;
SignalPtr sg(SG_Single(ama));
sg->setTO(kdata);
bool isHold = false;
size_t n_dis = 0;
for (size_t i = 0; i < dayTotal; ++i) {
if (isHold) {
if (sg->shouldSell(dateList[i])) {
isHold = false;
} else {
position[i]++;
}
} else {
if (sg->shouldBuy(dateList[i])) {
position[i]++;
isHold = true;
}
}
if (dateList[i] >= kdata[0].datetime) {
if (n_dis < discard) {
n_dis++;
numberPerDay[i]--;
}
}
}
}
PriceList tmp_result(dayTotal, Null<price_t>());
for (auto i = discard; i < dayTotal; ++i) {
tmp_result[i] = numberPerDay[i]
? (double)position[i]/(double)numberPerDay[i] : 1.0;
}
result = PRICELIST(tmp_result);
result.name("POS");
return PRICELIST(result);
}