Market增加开闭市时间

This commit is contained in:
fasiondog 2020-10-30 00:03:43 +08:00
parent 6bc79b79ed
commit 966391af01
7 changed files with 68 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -57,6 +57,26 @@ 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;
@ -66,6 +86,10 @@ private:
string m_description; // 描述信息
string m_code; // 市场对应的指数代码,用于获取交易日历
Datetime m_lastDate; // 当前市场最后日期
TimeDelta m_openTime1; // 上午开市时间
TimeDelta m_closeTime1; // 上午闭市时间
TimeDelta m_openTime2; // 下午开市时间
TimeDelta m_closeTime2; // 下午闭市时间
};
/**

View File

@ -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<KRecord>();

View File

@ -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<Data> m_data;

View File

@ -17,6 +17,7 @@
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/vector.hpp>
#include "TimeDelta_serialization.h"
namespace boost {
namespace serialization {