hikyuu2/hikyuu_cpp/hikyuu/MarketInfo.h

133 lines
3.4 KiB
C++
Raw Permalink Normal View History

2015-01-07 01:26:14 +08:00
/*
* MarketInfo.h
*
* Created on: 2011-12-5
* Author: fasiondog
*/
#pragma once
2015-01-07 01:26:14 +08:00
#ifndef MARKETINFO_H_
#define MARKETINFO_H_
#include "DataType.h"
namespace hku {
/**
*
* @ingroup StockManage
*/
class HKU_API MarketInfo {
public:
/** 默认构造函数返回Null<MarketInfo>() */
MarketInfo();
/**
* @param market
* @param name
* @param description
* @param code
* @param lastDate
2020-12-26 12:48:45 +08:00
* @param openTime1 1
* @param closeTime1 1
* @param openTime2 2
* @param closeTime2 2
2015-01-07 01:26:14 +08:00
*/
2019-11-10 19:45:57 +08:00
MarketInfo(const string& market, const string& name, const string& description,
2020-10-31 00:07:18 +08:00
const string& code, const Datetime& lastDate, TimeDelta openTime1,
TimeDelta closeTime1, TimeDelta openTime2, TimeDelta closeTime2);
2015-01-07 01:26:14 +08:00
/** 获取市场简称 */
2019-11-10 19:45:57 +08:00
const string& market() const {
return m_market;
}
2015-01-07 01:26:14 +08:00
/** 获取市场名称 */
2019-11-10 19:45:57 +08:00
const string& name() const {
return m_name;
}
2015-01-07 01:26:14 +08:00
/** 获取市场描述 */
2019-11-10 19:45:57 +08:00
const string& description() const {
return m_description;
}
2015-01-07 01:26:14 +08:00
/** 获取该市场对应的指数代码 */
2019-11-10 19:45:57 +08:00
const string& code() const {
return m_code;
}
2015-01-07 01:26:14 +08:00
/** 获取市场数据的最后更新日期 */
2019-11-10 19:45:57 +08:00
Datetime lastDate() const {
return m_lastDate;
}
2015-01-07 01:26:14 +08:00
2020-10-30 00:03:43 +08:00
/** 开市时间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;
}
2016-04-03 00:08:31 +08:00
/** 仅用于python的__str__ */
string toString() const;
2015-01-07 01:26:14 +08:00
private:
2020-10-30 00:03:43 +08:00
string m_market; // 市场标识
string m_name; // 市场名称
string m_description; // 描述信息
string m_code; // 市场对应的指数代码,用于获取交易日历
Datetime m_lastDate; // 当前市场最后日期
TimeDelta m_openTime1; // 上午开市时间
TimeDelta m_closeTime1; // 上午闭市时间
TimeDelta m_openTime2; // 下午开市时间
TimeDelta m_closeTime2; // 下午闭市时间
2015-01-07 01:26:14 +08:00
};
/**
*
2023-05-29 16:25:42 +08:00
* MarketInfo(SH, , , 000001, 2011-Dec-06 00:00:00)
2015-01-07 01:26:14 +08:00
* @ingroup StockManage
*/
2019-11-10 19:45:57 +08:00
HKU_API std::ostream& operator<<(std::ostream&, const MarketInfo&);
2015-01-07 01:26:14 +08:00
///////////////////////////////////////////////////////////////////////////////
//
// 关系比较函数
//
///////////////////////////////////////////////////////////////////////////////
bool operator==(const MarketInfo&, const MarketInfo&);
bool operator!=(const MarketInfo&, const MarketInfo&);
/** 相等比较 */
inline bool operator==(const MarketInfo& m1, const MarketInfo& m2) {
return m1.market() == m2.market();
}
/** 不等比较 */
inline bool operator!=(const MarketInfo& m1, const MarketInfo& m2) {
return m1.market() != m2.market();
}
2019-11-10 19:45:57 +08:00
} // namespace hku
2015-01-07 01:26:14 +08:00
2023-07-28 23:50:26 +08:00
#if FMT_VERSION >= 90000
template <>
struct fmt::formatter<hku::MarketInfo> : ostream_formatter {};
#endif
2015-01-07 01:26:14 +08:00
#endif /* MARKETINFO_H_ */