hikyuu2/hikyuu_cpp/hikyuu/KRecord.h
2019-11-10 19:45:57 +08:00

83 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* KRecord.h
*
* Created on: 2011-12-24
* Author: fasiondog
*/
#pragma once
#ifndef KRECORD_H_
#define KRECORD_H_
#include "DataType.h"
namespace hku {
/**
* K线数据记录
* @ingroup StockManage
*/
class KRecord {
public:
Datetime datetime; ///<日期格式YYYYMMDDHHMM 如200901010930
price_t openPrice; ///<开盘价
price_t highPrice; ///<最高价
price_t lowPrice; ///<最低价
price_t closePrice; ///<最低价
price_t transAmount; ///<成交金额
price_t transCount; ///<成交量
KRecord()
: datetime(Null<Datetime>()),
openPrice(0.0),
highPrice(0.0),
lowPrice(0.0),
closePrice(0.0),
transAmount(0.0),
transCount(0.0) {}
KRecord(const Datetime& indate)
: datetime(indate),
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)
: datetime(date),
openPrice(openPrice),
highPrice(highPrice),
lowPrice(lowPrice),
closePrice(closePrice),
transAmount(transAmount),
transCount(transCount) {}
bool isValid() const {
return datetime == Null<Datetime>() ? false : true;
}
};
/** @ingroup StockManage */
typedef vector<KRecord> KRecordList;
/** @ingroup StockManage */
typedef shared_ptr<KRecordList> KRecordListPtr;
/**
* 输出KRecord信息KRecord(datetime, open, high, low, close, transAmount, count)
* @ingroup StockManage
*/
HKU_API std::ostream& operator<<(std::ostream&, const KRecord&);
/**
* 比较两个KRecord是否相等一般仅测试时使用
* @ingroup StockManage
*/
bool HKU_API operator==(const KRecord& d1, const KRecord& d2);
} // namespace hku
#endif /* KRECORD_H_ */