Hikyuu
FundsRecord.h
浏览该文件的文档.
1 /*
2  * FundsRecord.h
3  *
4  * Created on: 2013-5-2
5  * Author: fasiondog
6  */
7 
8 #ifndef FUNDSRECORD_H_
9 #define FUNDSRECORD_H_
10 
11 #include "../DataType.h"
12 #include "../config.h"
13 
14 #if HKU_SUPPORT_SERIALIZATION
15 #include <boost/serialization/nvp.hpp>
16 #endif
17 
18 namespace hku {
19 
25 public:
26  FundsRecord();
27  FundsRecord(price_t cash,
28  price_t market_value, price_t short_market_value,
29  price_t base_cash, price_t base_asset,
30  price_t borrow_cash, price_t borrow_asset);
31 
40  //当前总资产 = 现金 + 多头市值 + 空头数量×(借入价格 - 当前价格)
41  // = cash + market_value + borrow_asset - short_market_value
42  //当前负债 = 借入的资金 + 借入的资产价值
43  // = borrow_cash + borrow_asset
44  //当前净资产 = 总资产 - 负债
45  // = cash + market_value - short_market_value - borrow_cash
46  //当前投入本值资产 = 投入本金 + 投入资产价值
47  // = base_cash + base_asset
48  //当前收益 = 当前净资产 - 当前投入本值资产
49  // = cash + market_value - short_market_value - borrow_cash - base_cash - base_asset
50 
51  //序列化支持
52 #if HKU_SUPPORT_SERIALIZATION
53 private:
54  friend class boost::serialization::access;
55  template<class Archive>
56  void serialize(Archive & ar, const unsigned int version) {
57  ar & BOOST_SERIALIZATION_NVP(cash);
58  ar & BOOST_SERIALIZATION_NVP(market_value);
59  ar & BOOST_SERIALIZATION_NVP(short_market_value);
60  ar & BOOST_SERIALIZATION_NVP(base_cash);
61  ar & BOOST_SERIALIZATION_NVP(base_asset);
62  ar & BOOST_SERIALIZATION_NVP(borrow_cash);
63  ar & BOOST_SERIALIZATION_NVP(borrow_asset);
64  }
65 #endif
66 };
67 
68 
73 HKU_API std::ostream & operator<<(std::ostream &, const FundsRecord&);
74 
75 bool HKU_API operator==(const FundsRecord& d1, const FundsRecord& d2);
76 
77 } /* namespace hku */
78 #endif /* FUNDSRECORD_H_ */
price_t borrow_asset
当前借入证券资产价值
Definition: FundsRecord.h:38
price_t cash
当前现金
Definition: FundsRecord.h:32
price_t base_asset
当前投入的资产价值
Definition: FundsRecord.h:36
price_t borrow_cash
当前借入的资金,即负债
Definition: FundsRecord.h:37
#define HKU_API
Definition: DataType.h:12
HKU_API std::ostream & operator<<(std::ostream &os, const Block &blk)
Definition: Block.cpp:13
price_t market_value
当前多头市值
Definition: FundsRecord.h:33
double price_t
Definition: DataType.h:53
bool operator==(const Datetime &, const Datetime &)
Definition: Datetime.h:201
当前资产情况记录,由TradeManager::getFunds返回
Definition: FundsRecord.h:24
price_t base_cash
当前投入本金principal
Definition: FundsRecord.h:35
Hikyuu核心命名空间,包含股票数据的管理、指标实现、交易系统框架等
Definition: Block.cpp:11
price_t short_market_value
当前空头仓位市值
Definition: FundsRecord.h:34