2015-01-07 01:26:14 +08:00
|
|
|
|
/*
|
|
|
|
|
* Performance.h
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2013-4-23
|
|
|
|
|
* Author: fasiondog
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef PERFORMANCE_H_
|
|
|
|
|
#define PERFORMANCE_H_
|
|
|
|
|
|
2016-07-09 22:37:42 +08:00
|
|
|
|
#include <boost/function.hpp>
|
2015-01-07 01:26:14 +08:00
|
|
|
|
#include "TradeManager.h"
|
|
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
|
2017-10-04 00:34:24 +08:00
|
|
|
|
/**
|
2015-01-07 01:26:14 +08:00
|
|
|
|
* 简单绩效统计
|
2017-10-04 00:34:24 +08:00
|
|
|
|
* @ingroup Performance
|
2015-01-07 01:26:14 +08:00
|
|
|
|
*/
|
|
|
|
|
class HKU_API Performance {
|
|
|
|
|
public:
|
|
|
|
|
Performance();
|
|
|
|
|
virtual ~Performance();
|
|
|
|
|
|
2017-10-04 00:34:24 +08:00
|
|
|
|
/** 复位,清除已计算的结果 */
|
2015-01-07 01:26:14 +08:00
|
|
|
|
void reset();
|
|
|
|
|
|
2017-10-04 00:34:24 +08:00
|
|
|
|
/** 按指标名称获取指标值,必须在运行 statistics 或 report 之后生效 */
|
2017-06-13 02:35:52 +08:00
|
|
|
|
double get(const string& name) const;
|
2017-10-04 00:34:24 +08:00
|
|
|
|
|
|
|
|
|
/** 同 get */
|
2017-06-13 02:35:52 +08:00
|
|
|
|
double operator[](const string& name) const { return get(name); }
|
|
|
|
|
|
2017-10-04 00:34:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 简单的文本统计报告,用于直接输出打印
|
|
|
|
|
* @param tm
|
|
|
|
|
* @param datetime 指定的截止时刻
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2016-04-03 00:08:31 +08:00
|
|
|
|
string report(const TradeManagerPtr& tm,
|
2015-01-07 01:26:14 +08:00
|
|
|
|
const Datetime& datetime = Datetime::now());
|
|
|
|
|
|
2017-10-04 00:34:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 根据交易记录,统计截至某一时刻的系统绩效, datetime必须大于等于lastDatetime,
|
2015-01-07 01:26:14 +08:00
|
|
|
|
* 以便用于计算当前市值
|
2017-10-04 00:34:24 +08:00
|
|
|
|
* @param tm 指定的交易管理实例
|
|
|
|
|
* @param datetime 统计截止时刻
|
2015-01-07 01:26:14 +08:00
|
|
|
|
*/
|
2017-10-04 00:34:24 +08:00
|
|
|
|
void statistics(const TradeManagerPtr& tm,
|
|
|
|
|
const Datetime& datetime = Datetime::now());
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef map<string, double> map_type;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
list<string> m_name_list; //保存指标顺序
|
|
|
|
|
map_type m_result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} /* namespace hku */
|
|
|
|
|
#endif /* PERFORMANCE_H_ */
|