hikyuu 2.1.5__cp38-none-win_amd64.whl → 2.2.1__cp38-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hikyuu/analysis/analysis.py +20 -0
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/common.py +3 -3
- hikyuu/data/mysql_upgrade/0023.sql +4 -0
- hikyuu/data/pytdx_weight_to_mysql.py +14 -15
- hikyuu/data/pytdx_weight_to_sqlite.py +14 -15
- hikyuu/data/sqlite_upgrade/0024.sql +22 -0
- hikyuu/gui/HikyuuTDX.py +3 -2
- hikyuu/gui/data/ImportHistoryFinanceTask.py +7 -0
- hikyuu/gui/data/ImportWeightToSqliteTask.py +2 -2
- hikyuu/gui/data/MainWindow.py +520 -424
- hikyuu/include/hikyuu/StockWeight.h +16 -10
- hikyuu/include/hikyuu/analysis/analysis_sys.h +42 -12
- hikyuu/include/hikyuu/data_driver/base_info/table/StockWeightTable.h +6 -4
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +5 -6
- hikyuu/include/hikyuu/indicator/crt/IC.h +7 -6
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +7 -4
- hikyuu/include/hikyuu/indicator/imp/IIc.h +1 -1
- hikyuu/include/hikyuu/serialization/StockWeight_serialization.h +5 -2
- hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +27 -25
- hikyuu/include/hikyuu/strategy/Strategy.h +1 -2
- hikyuu/include/hikyuu/trade_manage/Performance.h +3 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +16 -6
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +0 -3
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +2 -2
- hikyuu/include/hikyuu/trade_sys/condition/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/CN_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/ManualCondition.h +23 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/{AddCondition.h → logic/AddCondition.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/condition/imp/{AndCondition.h → logic/AndCondition.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/condition/imp/{DivCondition.h → logic/DivCondition.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/condition/imp/{MultiCondition.h → logic/MultiCondition.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/condition/imp/{OrCondition.h → logic/OrCondition.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +6 -6
- hikyuu/include/hikyuu/trade_sys/environment/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/EV_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/ManualEnvironment.h +23 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +3 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +3 -2
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +4 -2
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +2 -2
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +3 -1
- hikyuu/include/hikyuu/trade_sys/selector/build_in.h +2 -1
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +2 -1
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Optimal.h +26 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSelector.h → logic/OperatorSelector.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorValueSelector.h → logic/OperatorValueSelector.h} +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/MaxFundsOptimalSelector.h +27 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +86 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +42 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/ManualSignal.h +23 -0
- hikyuu/include/hikyuu/trade_sys/system/System.h +30 -13
- hikyuu/include/hikyuu/trade_sys/system/TradeRequest.h +19 -11
- hikyuu/include/hikyuu/trade_sys/system/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/system/crt/SYS_WalkForward.h +27 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +51 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +70 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +465 -0
- hikyuu/include/hikyuu/utilities/base64.h +25 -31
- hikyuu/include/hikyuu/version.h +5 -5
- hikyuu/strategy/strategy_demo1.py +2 -1
- hikyuu/trade_sys/trade_sys.py +28 -9
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/METADATA +1 -1
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/RECORD +94 -75
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/top_level.txt +3 -0
- /hikyuu/include/hikyuu/trade_sys/selector/crt/{SE_Operator.h → SE_Logic.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorAddSelector.h → logic/OperatorAddSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorAddValueSelector.h → logic/OperatorAddValueSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorDivSelector.h → logic/OperatorDivSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorDivValueSelector.h → logic/OperatorDivValueSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorInvertDivValueSelector.h → logic/OperatorInvertDivValueSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorInvertSubValueSelector.h → logic/OperatorInvertSubValueSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorMulSelector.h → logic/OperatorMulSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorMulValueSelector.h → logic/OperatorMulValueSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSubSelector.h → logic/OperatorSubSelector.h} +0 -0
- /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSubValueSelector.h → logic/OperatorSubValueSelector.h} +0 -0
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/LICENSE +0 -0
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/WHEEL +0 -0
- {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/entry_points.txt +0 -0
|
@@ -20,13 +20,13 @@ namespace hku {
|
|
|
20
20
|
class HKU_API StockWeight {
|
|
21
21
|
public:
|
|
22
22
|
/** 默认构造函数,返回Null<StockWeight>() */
|
|
23
|
-
StockWeight();
|
|
23
|
+
StockWeight() = default;
|
|
24
24
|
|
|
25
25
|
explicit StockWeight(const Datetime& datetime);
|
|
26
26
|
|
|
27
27
|
StockWeight(const Datetime& datetime, price_t countAsGift, price_t countForSell,
|
|
28
28
|
price_t priceForSell, price_t bonus, price_t increasement, price_t totalCount,
|
|
29
|
-
price_t freeCount);
|
|
29
|
+
price_t freeCount, price_t suogu);
|
|
30
30
|
|
|
31
31
|
/** 权息日期 */
|
|
32
32
|
Datetime datetime() const {
|
|
@@ -68,15 +68,21 @@ public:
|
|
|
68
68
|
return m_freeCount;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/** 扩缩股比例 */
|
|
72
|
+
price_t suogu() const {
|
|
73
|
+
return m_suogu;
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
private:
|
|
72
|
-
Datetime m_datetime;
|
|
73
|
-
price_t m_countAsGift; // 每10股送X股
|
|
74
|
-
price_t m_countForSell; // 每10股配X股
|
|
75
|
-
price_t m_priceForSell; // 配股价
|
|
76
|
-
price_t m_bonus; // 每10股红利
|
|
77
|
-
price_t m_increasement; // 每10股转增X股
|
|
78
|
-
price_t m_totalCount; // 总股本(万股)
|
|
79
|
-
price_t m_freeCount; // 流通股(万股)
|
|
77
|
+
Datetime m_datetime; // 权息日期
|
|
78
|
+
price_t m_countAsGift{0.}; // 每10股送X股
|
|
79
|
+
price_t m_countForSell{0.}; // 每10股配X股
|
|
80
|
+
price_t m_priceForSell{0.}; // 配股价
|
|
81
|
+
price_t m_bonus{0.}; // 每10股红利
|
|
82
|
+
price_t m_increasement{0.}; // 每10股转增X股
|
|
83
|
+
price_t m_totalCount{0.}; // 总股本(万股)
|
|
84
|
+
price_t m_freeCount{0.}; // 流通股(万股)
|
|
85
|
+
price_t m_suogu{0.}; // 扩缩股比例
|
|
80
86
|
};
|
|
81
87
|
|
|
82
88
|
/** @ingroup StockManage */
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
|
|
14
14
|
namespace hku {
|
|
15
15
|
|
|
16
|
-
struct HKU_API
|
|
16
|
+
struct HKU_API AnalysisSystemOutput {
|
|
17
17
|
string market_code; ///< 证券代码
|
|
18
18
|
string name; ///< 证券名称
|
|
19
19
|
PriceList values; ///< 统计各项指标值
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
AnalysisSystemOutput() = default;
|
|
22
|
+
AnalysisSystemOutput(const AnalysisSystemOutput& other) = default;
|
|
23
|
+
AnalysisSystemOutput(AnalysisSystemOutput&& rv)
|
|
24
24
|
: market_code(std::move(rv.market_code)),
|
|
25
25
|
name(std::move(rv.name)),
|
|
26
26
|
values(std::move(rv.values)) {}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
AnalysisSystemOutput& operator=(const AnalysisSystemOutput&) = default;
|
|
29
|
+
AnalysisSystemOutput& operator=(AnalysisSystemOutput&& rv) {
|
|
30
30
|
HKU_IF_RETURN(this == &rv, *this);
|
|
31
31
|
market_code = std::move(rv.market_code);
|
|
32
32
|
name = std::move(rv.name);
|
|
@@ -35,12 +35,42 @@ struct HKU_API AnalysisSystemWithBlockOut {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
/**
|
|
39
|
+
* 统计所有指定系统策略, 系统列表中的每一个系统都应该是独立的系统实例
|
|
40
|
+
* @note 系统实例列表和证券列表是一一对应,不是两两组合
|
|
41
|
+
* @param sys_list 系统策略实例列表
|
|
42
|
+
* @param stk_list 证券列表,须与系统策略列表一一对应
|
|
43
|
+
* @param query 查询条件
|
|
44
|
+
* @return vector<AnalysisSystemOutput>
|
|
45
|
+
*/
|
|
46
|
+
vector<AnalysisSystemOutput> HKU_API analysisSystemList(const SystemList& sys_list,
|
|
47
|
+
const StockList& stk_list,
|
|
48
|
+
const KQuery& query);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 以指定的 stock 统计执行所有的系统策略
|
|
52
|
+
* @param sys_list 系统策略思路列表,每一个都应是单独的实例
|
|
53
|
+
* @param stk 指定证券
|
|
54
|
+
* @param query 查询条件
|
|
55
|
+
* @return vector<AnalysisSystemOutput>
|
|
56
|
+
*/
|
|
57
|
+
vector<AnalysisSystemOutput> HKU_API analysisSystemList(const SystemList& sys_list,
|
|
58
|
+
const Stock& stk, const KQuery& query);
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
/**
|
|
61
|
+
* 以指定的 stock 统计执行所有的系统策略,并按指定的统计项返回统计项最高或最低的系统实例及其统计值
|
|
62
|
+
* @param sys_list 系统策略思路列表,每一个都应是单独的实例
|
|
63
|
+
* @param stk 指定证券
|
|
64
|
+
* @param query 查询条件
|
|
65
|
+
* @param sort_key Performance 中的统计项名称,按该统计项返回
|
|
66
|
+
* @param sort_mode 0 为取统计最高值的系统,其他值为取统计最低值的系统
|
|
67
|
+
* @return std::pair<double, SYSPtr>
|
|
68
|
+
*/
|
|
69
|
+
std::pair<double, SYSPtr> HKU_API findOptimalSystem(const SystemList& sys_list, const Stock& stk,
|
|
70
|
+
const KQuery& query, const string& sort_key,
|
|
71
|
+
int sort_mode = 0);
|
|
45
72
|
|
|
73
|
+
std::pair<double, SYSPtr> HKU_API findOptimalSystemMulti(const SystemList& sys_list,
|
|
74
|
+
const Stock& stk, const KQuery& query,
|
|
75
|
+
const string& sort_key, int sort_mode = 0);
|
|
46
76
|
} // namespace hku
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
namespace hku {
|
|
17
17
|
|
|
18
18
|
class StockWeightTable {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
TABLE_BIND10(StockWeightTable, stkweight, stockid, date, countAsGift, countForSell,
|
|
20
|
+
priceForSell, bonus, countOfIncreasement, totalCount, freeCount, suogu)
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
uint64_t stockid{0};
|
|
@@ -29,11 +29,12 @@ public:
|
|
|
29
29
|
double countOfIncreasement{0.};
|
|
30
30
|
double totalCount{0.};
|
|
31
31
|
double freeCount{0.};
|
|
32
|
+
double suogu{0.};
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
struct StockWeightTableView {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
TABLE_BIND10(StockWeightTableView, stkweight, market_code, date, countAsGift, countForSell,
|
|
37
|
+
priceForSell, bonus, countOfIncreasement, totalCount, freeCount, suogu)
|
|
37
38
|
string market_code;
|
|
38
39
|
uint64_t date{0};
|
|
39
40
|
double countAsGift{0.};
|
|
@@ -43,6 +44,7 @@ struct StockWeightTableView {
|
|
|
43
44
|
double countOfIncreasement{0.};
|
|
44
45
|
double totalCount{0.};
|
|
45
46
|
double freeCount{0.};
|
|
47
|
+
double suogu{0.0};
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
} // namespace hku
|
|
@@ -125,12 +125,11 @@ private:
|
|
|
125
125
|
enum STATUS m_status = WAITING; // 当前内部状态
|
|
126
126
|
std::atomic_bool m_stop = true; // 结束代理工作标识
|
|
127
127
|
|
|
128
|
-
int m_revTimeout = 100;
|
|
129
|
-
|
|
130
|
-
std::
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
vector<std::future<void>> m_process_task_list;
|
|
128
|
+
int m_revTimeout = 100; // 连接数据服务超时时长(毫秒)
|
|
129
|
+
std::thread m_receiveThread; // 数据接收线程
|
|
130
|
+
std::unique_ptr<ThreadPool> m_tg; // 数据处理任务线程池
|
|
131
|
+
size_t m_work_num = 1; // 数据处理任务线程池线程数
|
|
132
|
+
std::unique_ptr<ThreadPool> m_receive_data_tg; // 数据接收任务组
|
|
134
133
|
|
|
135
134
|
bool m_print = true; // 是否打印连接信息
|
|
136
135
|
string m_server_addr; // 服务器地址
|
|
@@ -18,23 +18,24 @@ namespace hku {
|
|
|
18
18
|
* @param query 查询条件
|
|
19
19
|
* @param ref_stk 参照证券,默认 sh000300 沪深300
|
|
20
20
|
* @param n 时间窗口 (对应 n 日收益率)
|
|
21
|
+
* @param spearman 使用 spearman 相关系数,否则为 pearson
|
|
21
22
|
* @return Indicator
|
|
22
23
|
* @ingroup Indicator
|
|
23
24
|
*/
|
|
24
25
|
Indicator HKU_API IC(const StockList& stks, const KQuery& query,
|
|
25
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1);
|
|
26
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true);
|
|
26
27
|
|
|
27
28
|
Indicator HKU_API IC(const Block& blk, const KQuery& query,
|
|
28
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1);
|
|
29
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true);
|
|
29
30
|
|
|
30
31
|
inline Indicator IC(const Indicator& ind, const StockList& stks, const KQuery& query,
|
|
31
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1) {
|
|
32
|
-
return IC(stks, query, ref_stk, n)(ind);
|
|
32
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true) {
|
|
33
|
+
return IC(stks, query, ref_stk, n, spearman)(ind);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
inline Indicator IC(const Indicator& ind, const Block& blk, const KQuery& query,
|
|
36
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1) {
|
|
37
|
-
return IC(blk, query, ref_stk, n)(ind);
|
|
37
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true) {
|
|
38
|
+
return IC(blk, query, ref_stk, n, spearman)(ind);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
} // namespace hku
|
|
@@ -22,12 +22,14 @@ namespace hku {
|
|
|
22
22
|
* @param ref_stk 参照证券,默认 sh000300 沪深300
|
|
23
23
|
* @param n IC对应的N日收益率
|
|
24
24
|
* @param rolling_n 滚动时间窗口
|
|
25
|
+
* @param spearman 使用 spearman 相关系数,否则为 pearson
|
|
25
26
|
* @return Indicator
|
|
26
27
|
* @ingroup Indicator
|
|
27
28
|
*/
|
|
28
29
|
inline Indicator ICIR(const Indicator& ind, const StockList& stks, const KQuery& query,
|
|
29
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120
|
|
30
|
-
|
|
30
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120,
|
|
31
|
+
bool spearman = true) {
|
|
32
|
+
Indicator ic = IC(ind, stks, query, ref_stk, n, spearman);
|
|
31
33
|
Indicator x = MA(ic, rolling_n) / STDEV(ic, rolling_n);
|
|
32
34
|
x.name("ICIR");
|
|
33
35
|
x.setParam<int>("n", n);
|
|
@@ -36,8 +38,9 @@ inline Indicator ICIR(const Indicator& ind, const StockList& stks, const KQuery&
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
inline Indicator ICIR(const Indicator& ind, const Block& blk, const KQuery& query,
|
|
39
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120
|
|
40
|
-
|
|
41
|
+
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120,
|
|
42
|
+
bool spearman = true) {
|
|
43
|
+
Indicator ic = IC(ind, blk, query, ref_stk, n, spearman);
|
|
41
44
|
Indicator x = MA(ic, rolling_n) / STDEV(ic, rolling_n);
|
|
42
45
|
x.name("ICIR");
|
|
43
46
|
x.setParam<int>("n", n);
|
|
@@ -14,7 +14,7 @@ namespace hku {
|
|
|
14
14
|
class IIc : public IndicatorImp {
|
|
15
15
|
public:
|
|
16
16
|
IIc();
|
|
17
|
-
IIc(const StockList& stks, const KQuery& query, int n, const Stock& ref_stk);
|
|
17
|
+
IIc(const StockList& stks, const KQuery& query, int n, const Stock& ref_stk, bool spearman);
|
|
18
18
|
virtual ~IIc();
|
|
19
19
|
|
|
20
20
|
virtual void _checkParam(const string& name) const override;
|
|
@@ -26,6 +26,7 @@ void save(Archive& ar, const hku::StockWeight& record, unsigned int version) {
|
|
|
26
26
|
hku::price_t increasement = record.increasement();
|
|
27
27
|
hku::price_t totalCount = record.totalCount();
|
|
28
28
|
hku::price_t freeCount = record.freeCount();
|
|
29
|
+
hku::price_t suogu = record.suogu();
|
|
29
30
|
ar& BOOST_SERIALIZATION_NVP(datetime);
|
|
30
31
|
ar& BOOST_SERIALIZATION_NVP(countAsGift);
|
|
31
32
|
ar& BOOST_SERIALIZATION_NVP(countForSell);
|
|
@@ -34,13 +35,14 @@ void save(Archive& ar, const hku::StockWeight& record, unsigned int version) {
|
|
|
34
35
|
ar& BOOST_SERIALIZATION_NVP(increasement);
|
|
35
36
|
ar& BOOST_SERIALIZATION_NVP(totalCount);
|
|
36
37
|
ar& BOOST_SERIALIZATION_NVP(freeCount);
|
|
38
|
+
ar& BOOST_SERIALIZATION_NVP(suogu);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
template <class Archive>
|
|
40
42
|
void load(Archive& ar, hku::StockWeight& record, unsigned int version) {
|
|
41
43
|
hku::uint64_t datetime;
|
|
42
44
|
hku::price_t countAsGift, countForSell, priceForSell, bonus;
|
|
43
|
-
hku::price_t increasement, totalCount, freeCount;
|
|
45
|
+
hku::price_t increasement, totalCount, freeCount, suogu;
|
|
44
46
|
ar& BOOST_SERIALIZATION_NVP(datetime);
|
|
45
47
|
ar& BOOST_SERIALIZATION_NVP(countAsGift);
|
|
46
48
|
ar& BOOST_SERIALIZATION_NVP(countForSell);
|
|
@@ -49,8 +51,9 @@ void load(Archive& ar, hku::StockWeight& record, unsigned int version) {
|
|
|
49
51
|
ar& BOOST_SERIALIZATION_NVP(increasement);
|
|
50
52
|
ar& BOOST_SERIALIZATION_NVP(totalCount);
|
|
51
53
|
ar& BOOST_SERIALIZATION_NVP(freeCount);
|
|
54
|
+
ar& BOOST_SERIALIZATION_NVP(suogu);
|
|
52
55
|
record = hku::StockWeight(hku::Datetime(datetime), countAsGift, countForSell, priceForSell,
|
|
53
|
-
bonus, increasement, totalCount, freeCount);
|
|
56
|
+
bonus, increasement, totalCount, freeCount, suogu);
|
|
54
57
|
}
|
|
55
58
|
} // namespace serialization
|
|
56
59
|
} // namespace boost
|
|
@@ -94,48 +94,48 @@ public:
|
|
|
94
94
|
* @param stock 指定证券
|
|
95
95
|
* @return true 是 | false 否
|
|
96
96
|
*/
|
|
97
|
-
virtual bool haveShort(const Stock& stock) const {
|
|
97
|
+
virtual bool haveShort(const Stock& stock) const override {
|
|
98
98
|
HKU_WARN("The subclass does not implement this method");
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/** 当前持有的证券种类数量 */
|
|
103
|
-
virtual size_t getStockNumber() const {
|
|
103
|
+
virtual size_t getStockNumber() const override {
|
|
104
104
|
return m_position.size();
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
/** 当前空头持有的证券种类数量 */
|
|
108
|
-
virtual size_t getShortStockNumber() const {
|
|
108
|
+
virtual size_t getShortStockNumber() const override {
|
|
109
109
|
HKU_WARN("The subclass does not implement this method");
|
|
110
110
|
return 0;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/** 获取指定时刻的某证券持有数量 */
|
|
114
|
-
virtual double getHoldNumber(const Datetime& datetime, const Stock& stock) {
|
|
114
|
+
virtual double getHoldNumber(const Datetime& datetime, const Stock& stock) override {
|
|
115
115
|
HKU_WARN("The subclass does not implement this method");
|
|
116
116
|
return 0.0;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/** 获取指定时刻的空头某证券持有数量 */
|
|
120
|
-
virtual double getShortHoldNumber(const Datetime& datetime, const Stock& stock) {
|
|
120
|
+
virtual double getShortHoldNumber(const Datetime& datetime, const Stock& stock) override {
|
|
121
121
|
HKU_WARN("The subclass does not implement this method");
|
|
122
122
|
return 0.0;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/** 获取指定时刻已借入的股票数量 */
|
|
126
|
-
virtual double getDebtNumber(const Datetime& datetime, const Stock& stock) {
|
|
126
|
+
virtual double getDebtNumber(const Datetime& datetime, const Stock& stock) override {
|
|
127
127
|
HKU_WARN("The subclass does not implement this method");
|
|
128
128
|
return 0.0;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/** 获取指定时刻已借入的现金额 */
|
|
132
|
-
virtual price_t getDebtCash(const Datetime& datetime) {
|
|
132
|
+
virtual price_t getDebtCash(const Datetime& datetime) override {
|
|
133
133
|
HKU_WARN("The subclass does not implement this method");
|
|
134
134
|
return 0.0;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/** 获取全部交易记录 */
|
|
138
|
-
virtual TradeRecordList getTradeList() const {
|
|
138
|
+
virtual TradeRecordList getTradeList() const override {
|
|
139
139
|
HKU_WARN("The subclass does not implement this method");
|
|
140
140
|
return TradeRecordList();
|
|
141
141
|
}
|
|
@@ -146,7 +146,8 @@ public:
|
|
|
146
146
|
* @param end 结束日期
|
|
147
147
|
* @return 交易记录列表
|
|
148
148
|
*/
|
|
149
|
-
virtual TradeRecordList getTradeList(const Datetime& start,
|
|
149
|
+
virtual TradeRecordList getTradeList(const Datetime& start,
|
|
150
|
+
const Datetime& end) const override {
|
|
150
151
|
HKU_WARN("The subclass does not implement this method");
|
|
151
152
|
return TradeRecordList();
|
|
152
153
|
}
|
|
@@ -155,19 +156,19 @@ public:
|
|
|
155
156
|
virtual PositionRecordList getPositionList() const override;
|
|
156
157
|
|
|
157
158
|
/** 获取全部历史持仓记录,即已平仓记录 */
|
|
158
|
-
virtual PositionRecordList getHistoryPositionList() const {
|
|
159
|
+
virtual PositionRecordList getHistoryPositionList() const override {
|
|
159
160
|
HKU_WARN("The subclass does not implement this method");
|
|
160
161
|
return PositionRecordList();
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
/** 获取当前全部空头仓位记录 */
|
|
164
|
-
virtual PositionRecordList getShortPositionList() const {
|
|
165
|
+
virtual PositionRecordList getShortPositionList() const override {
|
|
165
166
|
HKU_WARN("The subclass does not implement this method");
|
|
166
167
|
return PositionRecordList();
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
/** 获取全部空头历史仓位记录 */
|
|
170
|
-
virtual PositionRecordList getShortHistoryPositionList() const {
|
|
171
|
+
virtual PositionRecordList getShortHistoryPositionList() const override {
|
|
171
172
|
HKU_WARN("The subclass does not implement this method");
|
|
172
173
|
return PositionRecordList();
|
|
173
174
|
}
|
|
@@ -183,13 +184,13 @@ public:
|
|
|
183
184
|
* 获取指定证券的空头持仓记录
|
|
184
185
|
* @param stock 指定的证券
|
|
185
186
|
*/
|
|
186
|
-
virtual PositionRecord getShortPosition(const Stock& stock) const {
|
|
187
|
+
virtual PositionRecord getShortPosition(const Stock& stock) const override {
|
|
187
188
|
HKU_WARN("The subclass does not implement this method");
|
|
188
189
|
return PositionRecord();
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
/** 获取当前借入的股票列表 */
|
|
192
|
-
virtual BorrowRecordList getBorrowStockList() const {
|
|
193
|
+
virtual BorrowRecordList getBorrowStockList() const override {
|
|
193
194
|
HKU_WARN("The subclass does not implement this method");
|
|
194
195
|
return BorrowRecordList();
|
|
195
196
|
}
|
|
@@ -222,7 +223,7 @@ public:
|
|
|
222
223
|
* @return true | false
|
|
223
224
|
*/
|
|
224
225
|
virtual bool checkinStock(const Datetime& datetime, const Stock& stock, price_t price,
|
|
225
|
-
double number) {
|
|
226
|
+
double number) override {
|
|
226
227
|
HKU_WARN("The subclass does not implement this method");
|
|
227
228
|
return false;
|
|
228
229
|
}
|
|
@@ -237,7 +238,7 @@ public:
|
|
|
237
238
|
* @note 应该不会被用到
|
|
238
239
|
*/
|
|
239
240
|
virtual bool checkoutStock(const Datetime& datetime, const Stock& stock, price_t price,
|
|
240
|
-
double number) {
|
|
241
|
+
double number) override {
|
|
241
242
|
HKU_WARN("The subclass does not implement this method");
|
|
242
243
|
return false;
|
|
243
244
|
}
|
|
@@ -289,7 +290,8 @@ public:
|
|
|
289
290
|
*/
|
|
290
291
|
virtual TradeRecord sellShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
291
292
|
double number, price_t stoploss = 0.0, price_t goalPrice = 0.0,
|
|
292
|
-
price_t planPrice = 0.0,
|
|
293
|
+
price_t planPrice = 0.0,
|
|
294
|
+
SystemPart from = PART_INVALID) override {
|
|
293
295
|
HKU_WARN("The subclass does not implement this method");
|
|
294
296
|
return TradeRecord();
|
|
295
297
|
}
|
|
@@ -309,7 +311,7 @@ public:
|
|
|
309
311
|
virtual TradeRecord buyShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
310
312
|
double number = MAX_DOUBLE, price_t stoploss = 0.0,
|
|
311
313
|
price_t goalPrice = 0.0, price_t planPrice = 0.0,
|
|
312
|
-
SystemPart from = PART_INVALID) {
|
|
314
|
+
SystemPart from = PART_INVALID) override {
|
|
313
315
|
HKU_WARN("The subclass does not implement this method");
|
|
314
316
|
return TradeRecord();
|
|
315
317
|
}
|
|
@@ -320,7 +322,7 @@ public:
|
|
|
320
322
|
* @param cash 借入的现金
|
|
321
323
|
* @return true | false
|
|
322
324
|
*/
|
|
323
|
-
virtual bool borrowCash(const Datetime& datetime, price_t cash) {
|
|
325
|
+
virtual bool borrowCash(const Datetime& datetime, price_t cash) override {
|
|
324
326
|
HKU_WARN("The subclass does not implement this method");
|
|
325
327
|
return false;
|
|
326
328
|
}
|
|
@@ -331,7 +333,7 @@ public:
|
|
|
331
333
|
* @param cash 归还现金
|
|
332
334
|
* @return true | false
|
|
333
335
|
*/
|
|
334
|
-
virtual bool returnCash(const Datetime& datetime, price_t cash) {
|
|
336
|
+
virtual bool returnCash(const Datetime& datetime, price_t cash) override {
|
|
335
337
|
HKU_WARN("The subclass does not implement this method");
|
|
336
338
|
return false;
|
|
337
339
|
}
|
|
@@ -345,7 +347,7 @@ public:
|
|
|
345
347
|
* @return true | false
|
|
346
348
|
*/
|
|
347
349
|
virtual bool borrowStock(const Datetime& datetime, const Stock& stock, price_t price,
|
|
348
|
-
double number) {
|
|
350
|
+
double number) override {
|
|
349
351
|
HKU_WARN("The subclass does not implement this method");
|
|
350
352
|
return false;
|
|
351
353
|
}
|
|
@@ -359,7 +361,7 @@ public:
|
|
|
359
361
|
* @return true | false
|
|
360
362
|
*/
|
|
361
363
|
virtual bool returnStock(const Datetime& datetime, const Stock& stock, price_t price,
|
|
362
|
-
double number) {
|
|
364
|
+
double number) override {
|
|
363
365
|
HKU_WARN("The subclass does not implement this method");
|
|
364
366
|
return false;
|
|
365
367
|
}
|
|
@@ -387,7 +389,7 @@ public:
|
|
|
387
389
|
* @param tr 待加入的交易记录
|
|
388
390
|
* @return bool true 成功 | false 失败
|
|
389
391
|
*/
|
|
390
|
-
virtual bool addTradeRecord(const TradeRecord& tr) {
|
|
392
|
+
virtual bool addTradeRecord(const TradeRecord& tr) override {
|
|
391
393
|
HKU_WARN("The subclass does not implement this method");
|
|
392
394
|
return false;
|
|
393
395
|
}
|
|
@@ -398,7 +400,7 @@ public:
|
|
|
398
400
|
* @return true 成功
|
|
399
401
|
* @return false 失败
|
|
400
402
|
*/
|
|
401
|
-
virtual bool addPosition(const PositionRecord& pr) {
|
|
403
|
+
virtual bool addPosition(const PositionRecord& pr) override {
|
|
402
404
|
HKU_WARN("The subclass does not implement this method");
|
|
403
405
|
return false;
|
|
404
406
|
}
|
|
@@ -410,7 +412,7 @@ public:
|
|
|
410
412
|
* 以csv格式输出交易记录、未平仓记录、已平仓记录、资产净值曲线
|
|
411
413
|
* @param path 输出文件所在目录
|
|
412
414
|
*/
|
|
413
|
-
virtual void tocsv(const string& path) {
|
|
415
|
+
virtual void tocsv(const string& path) override {
|
|
414
416
|
HKU_WARN("The subclass does not implement this method");
|
|
415
417
|
}
|
|
416
418
|
|
|
@@ -106,8 +106,7 @@ private:
|
|
|
106
106
|
string m_run_daily_market;
|
|
107
107
|
bool m_ignoreMarket{false};
|
|
108
108
|
|
|
109
|
-
std::function<void()
|
|
110
|
-
TimeDelta m_run_daily_at_delta;
|
|
109
|
+
std::map<TimeDelta, std::function<void()>> m_run_daily_at_funcs;
|
|
111
110
|
|
|
112
111
|
private:
|
|
113
112
|
void _initParam();
|
|
@@ -168,6 +168,7 @@ public:
|
|
|
168
168
|
p->m_name = m_name;
|
|
169
169
|
p->m_broker_last_datetime = m_broker_last_datetime;
|
|
170
170
|
p->m_costfunc = m_costfunc;
|
|
171
|
+
p->m_broker_list = m_broker_list;
|
|
171
172
|
return p;
|
|
172
173
|
}
|
|
173
174
|
|
|
@@ -197,7 +198,7 @@ public:
|
|
|
197
198
|
* @param ktype K线类型,必须与日期列表匹配,默认KQuery::DAY
|
|
198
199
|
* @return 日资产记录列表
|
|
199
200
|
*/
|
|
200
|
-
FundsList getFundsList(const DatetimeList& dates, KQuery::KType ktype = KQuery::DAY) {
|
|
201
|
+
FundsList getFundsList(const DatetimeList& dates, const KQuery::KType& ktype = KQuery::DAY) {
|
|
201
202
|
size_t total = dates.size();
|
|
202
203
|
FundsList result(total);
|
|
203
204
|
HKU_IF_RETURN(total == 0, result);
|
|
@@ -213,7 +214,7 @@ public:
|
|
|
213
214
|
* @param ktype K线类型,必须与日期列表匹配,默认KQuery::DAY
|
|
214
215
|
* @return 资产净值列表
|
|
215
216
|
*/
|
|
216
|
-
PriceList getFundsCurve(const DatetimeList& dates, KQuery::KType ktype = KQuery::DAY) {
|
|
217
|
+
PriceList getFundsCurve(const DatetimeList& dates, const KQuery::KType& ktype = KQuery::DAY) {
|
|
217
218
|
FundsList funds_list = getFundsList(dates, ktype);
|
|
218
219
|
PriceList ret(funds_list.size());
|
|
219
220
|
int precision = getParam<int>("precision");
|
|
@@ -229,7 +230,7 @@ public:
|
|
|
229
230
|
* @param ktype K线类型,必须与日期列表匹配,默认为KQuery::DAY
|
|
230
231
|
* @return 收益曲线
|
|
231
232
|
*/
|
|
232
|
-
PriceList getProfitCurve(const DatetimeList& dates, KQuery::KType ktype = KQuery::DAY) {
|
|
233
|
+
PriceList getProfitCurve(const DatetimeList& dates, const KQuery::KType& ktype = KQuery::DAY) {
|
|
233
234
|
FundsList funds_list = getFundsList(dates, ktype);
|
|
234
235
|
PriceList ret(funds_list.size());
|
|
235
236
|
int precision = getParam<int>("precision");
|
|
@@ -246,7 +247,7 @@ public:
|
|
|
246
247
|
* @return 收益率曲线
|
|
247
248
|
*/
|
|
248
249
|
PriceList getProfitCumChangeCurve(const DatetimeList& dates,
|
|
249
|
-
KQuery::KType ktype = KQuery::DAY) {
|
|
250
|
+
const KQuery::KType& ktype = KQuery::DAY) {
|
|
250
251
|
FundsList funds_list = getFundsList(dates, ktype);
|
|
251
252
|
PriceList ret(funds_list.size());
|
|
252
253
|
for (size_t i = 0, total = funds_list.size(); i < total; i++) {
|
|
@@ -261,7 +262,8 @@ public:
|
|
|
261
262
|
* @param ktype K线类型,必须与日期列表匹配,默认为KQuery::DAY
|
|
262
263
|
* @return 价格曲线
|
|
263
264
|
*/
|
|
264
|
-
PriceList getBaseAssetsCurve(const DatetimeList& dates,
|
|
265
|
+
PriceList getBaseAssetsCurve(const DatetimeList& dates,
|
|
266
|
+
const KQuery::KType& ktype = KQuery::DAY) {
|
|
265
267
|
FundsList funds_list = getFundsList(dates, ktype);
|
|
266
268
|
PriceList ret(funds_list.size());
|
|
267
269
|
for (size_t i = 0, total = funds_list.size(); i < total; i++) {
|
|
@@ -769,4 +771,12 @@ inline std::ostream& operator<<(std::ostream& os, const TradeManagerPtr& ptm) {
|
|
|
769
771
|
return os;
|
|
770
772
|
}
|
|
771
773
|
|
|
772
|
-
} // namespace hku
|
|
774
|
+
} // namespace hku
|
|
775
|
+
|
|
776
|
+
#if FMT_VERSION >= 90000
|
|
777
|
+
template <>
|
|
778
|
+
struct fmt::formatter<hku::TradeManagerBase> : ostream_formatter {};
|
|
779
|
+
|
|
780
|
+
template <>
|
|
781
|
+
struct fmt::formatter<hku::TradeManagerPtr> : ostream_formatter {};
|
|
782
|
+
#endif
|
|
@@ -73,7 +73,7 @@ public:
|
|
|
73
73
|
BUSINESS business; ///< 业务类型
|
|
74
74
|
price_t planPrice; ///< 计划交易价格
|
|
75
75
|
price_t realPrice; ///< 实际交易价格
|
|
76
|
-
price_t goalPrice; ///< 目标价位,如果为0表示未限定目标
|
|
76
|
+
price_t goalPrice; ///< 目标价位,如果为0或Null表示未限定目标
|
|
77
77
|
double number; ///< 成交数量
|
|
78
78
|
CostRecord cost; ///< 交易成本
|
|
79
79
|
price_t stoploss; ///< 止损价
|
|
@@ -112,9 +112,6 @@ private:
|
|
|
112
112
|
void _adjust_without_running(const Datetime& date, const SystemWeightList& se_list,
|
|
113
113
|
const std::unordered_set<SYSPtr>& running_list);
|
|
114
114
|
|
|
115
|
-
/* 检查分配的权重是否在 0 和 1 之间,如果存在错误,抛出异常,仅在 trace 时生效*/
|
|
116
|
-
void _check_weight(const SystemWeightList&);
|
|
117
|
-
|
|
118
115
|
private:
|
|
119
116
|
string m_name; // 组件名称
|
|
120
117
|
KQuery m_query; // 查询条件
|
|
@@ -180,10 +180,10 @@ typedef shared_ptr<ConditionBase> CNPtr;
|
|
|
180
180
|
|
|
181
181
|
#define CONDITION_IMP(classname) \
|
|
182
182
|
public: \
|
|
183
|
-
virtual ConditionPtr _clone() {
|
|
183
|
+
virtual ConditionPtr _clone() override { \
|
|
184
184
|
return std::make_shared<classname>(); \
|
|
185
185
|
} \
|
|
186
|
-
virtual void _calculate();
|
|
186
|
+
virtual void _calculate() override;
|
|
187
187
|
|
|
188
188
|
HKU_API std::ostream& operator<<(std::ostream&, const ConditionPtr&);
|
|
189
189
|
HKU_API std::ostream& operator<<(std::ostream&, const ConditionBase&);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2019~2023, hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* History:
|
|
5
|
+
* 1. 20240916 added by fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../ConditionBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 仅能手工添加有效性的CN,用于测试或其他特殊用途
|
|
16
|
+
* @return CNPtr
|
|
17
|
+
*/
|
|
18
|
+
CNPtr HKU_API CN_Manual();
|
|
19
|
+
|
|
20
|
+
} // namespace hku
|