hikyuu2/hikyuu_cpp/hikyuu/trade_manage/Performance.h

62 lines
1.4 KiB
C++
Raw Normal View History

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 之后生效 */
double get(const string& name) const;
2017-10-04 00:34:24 +08:00
/** 同 get */
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_ */