2015-01-07 01:26:14 +08:00
|
|
|
|
/*
|
|
|
|
|
* KRecord.h
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2011-12-24
|
|
|
|
|
* Author: fasiondog
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-03 21:53:24 +08:00
|
|
|
|
#pragma once
|
2015-01-07 01:26:14 +08:00
|
|
|
|
#ifndef KRECORD_H_
|
|
|
|
|
#define KRECORD_H_
|
|
|
|
|
|
|
|
|
|
#include "DataType.h"
|
|
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* K线数据记录
|
|
|
|
|
* @ingroup StockManage
|
|
|
|
|
*/
|
|
|
|
|
class KRecord {
|
|
|
|
|
public:
|
2023-07-28 23:50:26 +08:00
|
|
|
|
Datetime datetime; ///< 日期,格式:YYYYMMDDHHMM 如:200901010930
|
|
|
|
|
price_t openPrice; ///< 开盘价
|
|
|
|
|
price_t highPrice; ///< 最高价
|
|
|
|
|
price_t lowPrice; ///< 最低价
|
|
|
|
|
price_t closePrice; ///< 最低价
|
|
|
|
|
price_t transAmount; ///< 成交金额(千元)
|
2024-05-07 23:09:39 +08:00
|
|
|
|
price_t transCount; ///< 成交量(手),日线以下为股数
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
KRecord()
|
2019-11-10 19:45:57 +08:00
|
|
|
|
: datetime(Null<Datetime>()),
|
|
|
|
|
openPrice(0.0),
|
|
|
|
|
highPrice(0.0),
|
|
|
|
|
lowPrice(0.0),
|
|
|
|
|
closePrice(0.0),
|
|
|
|
|
transAmount(0.0),
|
|
|
|
|
transCount(0.0) {}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2020-11-02 23:47:15 +08:00
|
|
|
|
explicit KRecord(const Datetime& indate)
|
2015-01-07 01:26:14 +08:00
|
|
|
|
: datetime(indate),
|
2019-11-10 19:45:57 +08:00
|
|
|
|
openPrice(0.0),
|
|
|
|
|
highPrice(0.0),
|
|
|
|
|
lowPrice(0.0),
|
|
|
|
|
closePrice(0.0),
|
|
|
|
|
transAmount(0.0),
|
|
|
|
|
transCount(0.0) {}
|
|
|
|
|
|
|
|
|
|
KRecord(const Datetime& date, price_t openPrice, price_t highPrice, price_t lowPrice,
|
|
|
|
|
price_t closePrice, price_t transAmount, price_t transCount)
|
2015-01-07 01:26:14 +08:00
|
|
|
|
: datetime(date),
|
2019-11-10 19:45:57 +08:00
|
|
|
|
openPrice(openPrice),
|
|
|
|
|
highPrice(highPrice),
|
|
|
|
|
lowPrice(lowPrice),
|
|
|
|
|
closePrice(closePrice),
|
|
|
|
|
transAmount(transAmount),
|
|
|
|
|
transCount(transCount) {}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
bool isValid() const {
|
|
|
|
|
return datetime == Null<Datetime>() ? false : true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** @ingroup StockManage */
|
|
|
|
|
typedef vector<KRecord> KRecordList;
|
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
/** @ingroup StockManage */
|
|
|
|
|
typedef shared_ptr<KRecordList> KRecordListPtr;
|
|
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
|
/**
|
|
|
|
|
* 输出KRecord信息,如:KRecord(datetime, open, high, low, close, transAmount, count)
|
|
|
|
|
* @ingroup StockManage
|
|
|
|
|
*/
|
2019-11-10 19:45:57 +08:00
|
|
|
|
HKU_API std::ostream& operator<<(std::ostream&, const KRecord&);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 比较两个KRecord是否相等,一般仅测试时使用
|
|
|
|
|
* @ingroup StockManage
|
|
|
|
|
*/
|
2019-11-10 19:45:57 +08:00
|
|
|
|
bool HKU_API operator==(const KRecord& d1, const KRecord& d2);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2023-10-29 18:25:06 +08:00
|
|
|
|
/**
|
|
|
|
|
* 两个KRecord不等比较
|
|
|
|
|
* @ingroup StockManage
|
|
|
|
|
*/
|
|
|
|
|
bool HKU_API operator!=(const KRecord& d1, const KRecord& d2);
|
|
|
|
|
|
2019-11-10 19:45:57 +08:00
|
|
|
|
} // namespace hku
|
2023-07-28 23:50:26 +08:00
|
|
|
|
|
|
|
|
|
#if FMT_VERSION >= 90000
|
|
|
|
|
template <>
|
|
|
|
|
struct fmt::formatter<hku::KRecord> : ostream_formatter {};
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
|
#endif /* KRECORD_H_ */
|