mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-03 12:27:48 +08:00
Condition addValid 支持直接给予一个特定的值
This commit is contained in:
parent
2352a565dd
commit
01edee9a94
@ -77,10 +77,10 @@ void ConditionBase::setTO(const KData& kdata) {
|
||||
}
|
||||
}
|
||||
|
||||
void ConditionBase::_addValid(const Datetime& datetime) {
|
||||
void ConditionBase::_addValid(const Datetime& datetime, price_t value) {
|
||||
auto iter = m_date_index.find(datetime);
|
||||
HKU_IF_RETURN(iter == m_date_index.end(), void());
|
||||
m_values[iter->second] += 1.;
|
||||
m_values[iter->second] += value;
|
||||
}
|
||||
|
||||
bool ConditionBase::isValid(const Datetime& datetime) {
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
* 加入有效时间,在_calculate中调用
|
||||
* @param datetime 系统有效日期
|
||||
*/
|
||||
void _addValid(const Datetime& datetime);
|
||||
void _addValid(const Datetime& datetime, price_t value = 1.0);
|
||||
|
||||
typedef shared_ptr<ConditionBase> ConditionPtr;
|
||||
/** 克隆操作 */
|
||||
|
@ -87,7 +87,8 @@ void export_Condition(py::module& m) {
|
||||
|
||||
以指标的形式获取实际值,与交易对象等长,0表示无效,1表示系统有效)")
|
||||
|
||||
.def("_add_valid", &ConditionBase::_addValid, R"(_add_valid(self, datetime)
|
||||
.def("_add_valid", &ConditionBase::_addValid, py::arg("datetime"), py::arg("value") = 1.0,
|
||||
R"(_add_valid(self, datetime)
|
||||
|
||||
加入有效时间,在_calculate中调用
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user