Hikyuu
OperandNode.h
浏览该文件的文档.
1 /*
2  * OperandNode.h
3  *
4  * Created on: 2015年3月30日
5  * Author: fasiondog
6  */
7 
8 #ifndef INDICATOR_OPERANDNODE_H_
9 #define INDICATOR_OPERANDNODE_H_
10 
11 #include "Indicator.h"
12 
13 namespace hku {
14 
16 public:
17  enum OPType {
18  LEAF,
19  OP,
20  ADD,
21  SUB,
22  MUL,
23  DIV,
24  EQ,
25  GT,
26  LT,
27  NE,
28  GE,
29  LE,
30  AND,
31  OR,
32  INVALID
33  };
34 
35  typedef shared_ptr<OperandNode> OperandNodePtr;
36 
37 public:
38  OperandNode();
39  OperandNode(const Indicator&);
40  virtual ~OperandNode();
41 
42  void add(OPType, OperandNodePtr left, OperandNodePtr right);
43 
44  Indicator calculate(const Indicator&);
45 
46  const string& name() const { return m_name; }
47  void name(const string& name) { m_name = name; }
48 
49  static string getOPTypeName(OPType);
50 
51 private:
52  OPType m_optype;
53  Indicator m_ind;
54  string m_name;
55  OperandNodePtr m_left;
56  OperandNodePtr m_right;
57 
58 #if HKU_SUPPORT_SERIALIZATION
59 private:
60  friend class boost::serialization::access;
61  template<class Archive>
62  void serialize(Archive & ar, const unsigned int version) {
63  ar & BOOST_SERIALIZATION_NVP(m_optype);
64  ar & BOOST_SERIALIZATION_NVP(m_ind);
65  ar & BOOST_SERIALIZATION_NVP(m_name);
66  ar & BOOST_SERIALIZATION_NVP(m_left);
67  ar & BOOST_SERIALIZATION_NVP(m_right);
68  }
69 #endif /* HKU_SUPPORT_SERIALIZATION */
70 };
71 
72 typedef shared_ptr<OperandNode> OperandNodePtr;
73 
74 } /* namespace hku */
75 
76 #endif /* INDICATOR_OPERANDNODE_H_ */
大于
Definition: OperandNode.h:25
小于
Definition: OperandNode.h:26
叶子节点
Definition: OperandNode.h:18
OPType
Definition: OperandNode.h:17
Definition: OperandNode.h:21
小于等于
Definition: OperandNode.h:29
Definition: OperandNode.h:22
const string & name() const
Definition: OperandNode.h:46
Definition: OperandNode.h:23
等于
Definition: OperandNode.h:24
指标类,具体由IndicatorImp实现,实现新指标时应继承IndicatorImp
Definition: Indicator.h:38
Definition: OperandNode.h:15
shared_ptr< OperandNode > OperandNodePtr
Definition: OperandNode.h:35
大于等于
Definition: OperandNode.h:28
#define HKU_API
Definition: DataType.h:12
Definition: OperandNode.h:19
shared_ptr< OperandNode > OperandNodePtr
Definition: OperandNode.h:72
不等于
Definition: OperandNode.h:27
Definition: OperandNode.h:31
void name(const string &name)
Definition: OperandNode.h:47
Definition: OperandNode.h:30
Hikyuu核心命名空间,包含股票数据的管理、指标实现、交易系统框架等
Definition: Block.cpp:11
OP(OP1,OP2) OP1->calcalue(OP2->calculate(ind))
Definition: OperandNode.h:20