hikyuu2/hikyuu_cpp/hikyuu/KRecord.h

95 lines
2.2 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* KRecord.h
*
* Created on: 2011-12-24
* Author: fasiondog
*/
#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; ///< 成交金额(千元)
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;
/** @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
/**
* 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_ */