hikyuu2/hikyuu_cpp/hikyuu/StockWeight.h

137 lines
3.6 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* StockWeight.h
*
* Created on: 2011-12-9
* Author: fasiondog
*/
#pragma once
2015-01-07 01:26:14 +08:00
#ifndef STOCKWEIGHT_H_
#define STOCKWEIGHT_H_
#include "DataType.h"
namespace hku {
/**
*
* @ingroup StockManage
*/
2019-11-10 19:45:57 +08:00
class HKU_API StockWeight {
2015-01-07 01:26:14 +08:00
public:
/** 默认构造函数返回Null<StockWeight>() */
StockWeight();
StockWeight(const Datetime& datetime);
2019-11-10 19:45:57 +08:00
StockWeight(const Datetime& datetime, price_t countAsGift, price_t countForSell,
price_t priceForSell, price_t bonus, price_t increasement, price_t totalCount,
price_t freeCount);
2015-01-07 01:26:14 +08:00
/** 权息日期 */
2019-11-10 19:45:57 +08:00
Datetime datetime() const {
return m_datetime;
}
2015-01-07 01:26:14 +08:00
/** 每10股送X股 */
2019-11-10 19:45:57 +08:00
price_t countAsGift() const {
return m_countAsGift;
}
2015-01-07 01:26:14 +08:00
/** 每10股配X股 */
2019-11-10 19:45:57 +08:00
price_t countForSell() const {
return m_countForSell;
}
2015-01-07 01:26:14 +08:00
/** 配股价 */
2019-11-10 19:45:57 +08:00
price_t priceForSell() const {
return m_priceForSell;
}
2015-01-07 01:26:14 +08:00
/** 每10股红利 */
2019-11-10 19:45:57 +08:00
price_t bonus() const {
return m_bonus;
}
2015-01-07 01:26:14 +08:00
/** 每10股转增X股 */
2019-11-10 19:45:57 +08:00
price_t increasement() const {
return m_increasement;
}
2015-01-07 01:26:14 +08:00
/** 总股本(万股) */
2019-11-10 19:45:57 +08:00
price_t totalCount() const {
return m_totalCount;
}
2015-01-07 01:26:14 +08:00
/** 流通股(万股) */
2019-11-10 19:45:57 +08:00
price_t freeCount() const {
return m_freeCount;
}
2015-01-07 01:26:14 +08:00
private:
2019-11-10 19:45:57 +08:00
Datetime m_datetime; //权息日期
price_t m_countAsGift; //每10股送X股
price_t m_countForSell; //每10股配X股
price_t m_priceForSell; //配股价
price_t m_bonus; //每10股红利
price_t m_increasement; //每10股转增X股
price_t m_totalCount; //总股本(万股)
price_t m_freeCount; //流通股(万股)
2015-01-07 01:26:14 +08:00
};
/** @ingroup StockManage */
typedef vector<StockWeight> StockWeightList;
/**
* Weight(datetime, countAsGift, countForSell,
* priceForSell, bonus, increasement, totalCount, freeCount)
* @ingroup StockManage
*/
2019-11-10 19:45:57 +08:00
HKU_API std::ostream& operator<<(std::ostream&, const StockWeight&);
2015-01-07 01:26:14 +08:00
///////////////////////////////////////////////////////////////////////////////
//
// 关系比较函数
//
///////////////////////////////////////////////////////////////////////////////
bool operator==(const StockWeight&, const StockWeight&);
bool operator!=(const StockWeight&, const StockWeight&);
bool operator>(const StockWeight&, const StockWeight&);
bool operator<(const StockWeight&, const StockWeight&);
bool operator>=(const StockWeight&, const StockWeight&);
bool operator<=(const StockWeight&, const StockWeight&);
/* 相等比较, 仅根据日期判断 */
inline bool operator==(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() == m2.datetime();
}
/* 不等比较, 仅根据日期判断 */
inline bool operator!=(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() != m2.datetime();
}
/* 大于比较, 仅根据日期判断 */
inline bool operator>(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() > m2.datetime();
}
/* 小于比较, 仅根据日期判断 */
inline bool operator<(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() < m2.datetime();
}
/* 大于等于比较, 仅根据日期判断 */
inline bool operator>=(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() >= m2.datetime();
}
/* 小于等于比较, 仅根据日期判断 */
inline bool operator<=(const StockWeight& m1, const StockWeight& m2) {
return m1.datetime() <= m2.datetime();
}
/** @} */
2019-11-10 19:45:57 +08:00
} // namespace hku
2015-01-07 01:26:14 +08:00
#endif /* STOCKWEIGHT_H_ */