diff --git a/hikyuu/data/mysql_upgrade/0003.sql b/hikyuu/data/mysql_upgrade/0003.sql new file mode 100644 index 00000000..1095e5a0 --- /dev/null +++ b/hikyuu/data/mysql_upgrade/0003.sql @@ -0,0 +1,9 @@ +ALTER TABLE `hku_base`.`market` ADD `openTime1` INT(10) UNSIGNED NULL DEFAULT NULL; +ALTER TABLE `hku_base`.`market` ADD `closeTime1` INT(10) UNSIGNED NULL DEFAULT NULL; +ALTER TABLE `hku_base`.`market` ADD `openTime2` INT(10) UNSIGNED NULL DEFAULT NULL; +ALTER TABLE `hku_base`.`market` ADD `closeTime2` INT(10) UNSIGNED NULL DEFAULT NULL; + +UPDATE `hku_base`.`market` SET `openTime1`=930, `closeTime1`=1130, `openTime2`=1300, `closeTime2`=1500 WHERE `marketid`=1; +UPDATE `hku_base`.`market` SET `openTime1`=930, `closeTime1`=1130, `openTime2`=1300, `closeTime2`=1500 WHERE `marketid`=2; + +UPDATE `hku_base`.`version` set `version` = 3; \ No newline at end of file diff --git a/hikyuu/data/sqlite_upgrade/0004.sql b/hikyuu/data/sqlite_upgrade/0004.sql new file mode 100644 index 00000000..30106d19 --- /dev/null +++ b/hikyuu/data/sqlite_upgrade/0004.sql @@ -0,0 +1,11 @@ +BEGIN TRANSACTION; +ALTER TABLE `Market` ADD `openTime1` INTEGER; +ALTER TABLE `Market` ADD `closeTime1` INTEGER; +ALTER TABLE `Market` ADD `openTime2` INTEGER; +ALTER TABLE `Market` ADD `closeTime2` INTEGER; + +UPDATE `Market` SET `openTime1`=930, `closeTime1`=1130, `openTime2`=1300, `closeTime2`=1500 WHERE `marketid`=1; +UPDATE `Market` SET `openTime1`=930, `closeTime1`=1130, `openTime2`=1300, `closeTime2`=1500 WHERE `marketid`=2; + +UPDATE `version` set `version` = 4; +COMMIT; diff --git a/hikyuu_cpp/hikyuu/MarketInfo.cpp b/hikyuu_cpp/hikyuu/MarketInfo.cpp index aca04cbe..624a50aa 100644 --- a/hikyuu_cpp/hikyuu/MarketInfo.cpp +++ b/hikyuu_cpp/hikyuu/MarketInfo.cpp @@ -31,7 +31,8 @@ string MarketInfo::toString() const { string split(", "); os << "MarketInfo(" << m_market << split << m_name << split << m_description << split << m_code - << split << m_lastDate << ")"; + << split << m_lastDate << split << m_openTime1.minutes() << split << m_closeTime1.minutes() + << split << m_openTime2.minutes() << split << m_closeTime2.minutes() << ")"; return os.str(); } diff --git a/hikyuu_cpp/hikyuu/MarketInfo.h b/hikyuu_cpp/hikyuu/MarketInfo.h index c8ccecaf..a14ead05 100644 --- a/hikyuu_cpp/hikyuu/MarketInfo.h +++ b/hikyuu_cpp/hikyuu/MarketInfo.h @@ -57,15 +57,39 @@ public: return m_lastDate; } + /** 开市时间1 */ + TimeDelta openTime1() const { + return m_openTime1; + } + + /** 闭市时间1 */ + TimeDelta closeTime1() const { + return m_closeTime1; + } + + /** 开市时间2 */ + TimeDelta openTime2() const { + return m_openTime2; + } + + /** 闭市时间2 */ + TimeDelta closeTime2() const { + return m_closeTime2; + } + /** 仅用于python的__str__ */ string toString() const; private: - string m_market; //市场标识 - string m_name; //市场名称 - string m_description; //描述信息 - string m_code; //市场对应的指数代码,用于获取交易日历 - Datetime m_lastDate; //当前市场最后日期 + string m_market; // 市场标识 + string m_name; // 市场名称 + string m_description; // 描述信息 + string m_code; // 市场对应的指数代码,用于获取交易日历 + Datetime m_lastDate; // 当前市场最后日期 + TimeDelta m_openTime1; // 上午开市时间 + TimeDelta m_closeTime1; // 上午闭市时间 + TimeDelta m_openTime2; // 下午开市时间 + TimeDelta m_closeTime2; // 下午闭市时间 }; /** diff --git a/hikyuu_cpp/hikyuu/Stock.cpp b/hikyuu_cpp/hikyuu/Stock.cpp index 492ebf06..bfccc4d9 100644 --- a/hikyuu_cpp/hikyuu/Stock.cpp +++ b/hikyuu_cpp/hikyuu/Stock.cpp @@ -525,6 +525,20 @@ bool Stock::_getIndexRangeByDateFromBuffer(const KQuery& query, size_t& out_star return true; } +void Stock::_loadNewKRecordToBuffer(const KQuery& query) { + if (!m_data || m_data->pKData.find(query.kType()) == m_data->pKData.end()) { + return; + } + + KQuery::KType ktype = query.kType(); + KRecordList& buffer = *(m_data->pKData[ktype]); + if (buffer.empty()) { + return; + } + + // auto& lastRecord = buffer.back(); +} + KRecord Stock::getKRecord(size_t pos, KQuery::KType kType) const { if (!m_data) return Null(); diff --git a/hikyuu_cpp/hikyuu/Stock.h b/hikyuu_cpp/hikyuu/Stock.h index d7648cf1..bd780cb6 100644 --- a/hikyuu_cpp/hikyuu/Stock.h +++ b/hikyuu_cpp/hikyuu/Stock.h @@ -203,6 +203,8 @@ private: bool _getIndexRangeByIndex(const KQuery&, size_t& out_start, size_t& out_end) const; bool _getIndexRangeByDateFromBuffer(const KQuery&, size_t&, size_t&) const; + void _loadNewKRecordToBuffer(const KQuery&); + private: struct HKU_API Data; shared_ptr m_data; diff --git a/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h b/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h index 41a11200..1124f41c 100644 --- a/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h +++ b/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h @@ -17,6 +17,7 @@ #include #include #include +#include "TimeDelta_serialization.h" namespace boost { namespace serialization {