Condition addValid 支持直接给予一个特定的值

This commit is contained in:
fasiondog 2024-02-23 02:28:13 +08:00
parent 2352a565dd
commit 01edee9a94
3 changed files with 5 additions and 4 deletions

View File

@ -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) {

View File

@ -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;
/** 克隆操作 */

View File

@ -87,7 +87,8 @@ void export_Condition(py::module& m) {
01)")
.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中调用