hikyuu 2.1.5__cp310-none-win_amd64.whl → 2.2.1__cp310-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/core310.pyd +0 -0
- hikyuu/cpp/hikyuu.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 +93 -74
- {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
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
class ManualCondition : public ConditionBase {
|
|
15
|
+
CONDITION_IMP(ManualCondition)
|
|
16
|
+
CONDITION_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
ManualCondition();
|
|
20
|
+
virtual ~ManualCondition() = default;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace hku
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -151,12 +151,12 @@ private: \
|
|
|
151
151
|
typedef shared_ptr<EnvironmentBase> EnvironmentPtr;
|
|
152
152
|
typedef shared_ptr<EnvironmentBase> EVPtr;
|
|
153
153
|
|
|
154
|
-
#define ENVIRONMENT_IMP(classname)
|
|
155
|
-
public:
|
|
156
|
-
virtual EnvironmentPtr _clone() {
|
|
157
|
-
return std::make_shared<classname>();
|
|
158
|
-
}
|
|
159
|
-
virtual void _calculate();
|
|
154
|
+
#define ENVIRONMENT_IMP(classname) \
|
|
155
|
+
public: \
|
|
156
|
+
virtual EnvironmentPtr _clone() override { \
|
|
157
|
+
return std::make_shared<classname>(); \
|
|
158
|
+
} \
|
|
159
|
+
virtual void _calculate() override;
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* 输出Environment信息,如:Environment(name, params[...])
|
|
@@ -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 "../EnvironmentBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 仅能手工添加系统环境有效性的EV,用于测试或其他用途
|
|
16
|
+
* @return EVPtr
|
|
17
|
+
*/
|
|
18
|
+
EVPtr HKU_API EV_Manual();
|
|
19
|
+
|
|
20
|
+
} // namespace hku
|
|
@@ -0,0 +1,23 @@
|
|
|
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 "../EnvironmentBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
class ManualEnvironment : public EnvironmentBase {
|
|
15
|
+
ENVIRONMENT_IMP(ManualEnvironment)
|
|
16
|
+
ENVIRONMENT_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
ManualEnvironment();
|
|
20
|
+
virtual ~ManualEnvironment() = default;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace hku
|
|
@@ -29,7 +29,7 @@ public:
|
|
|
29
29
|
MultiFactorBase();
|
|
30
30
|
explicit MultiFactorBase(const string& name);
|
|
31
31
|
MultiFactorBase(const IndicatorList& inds, const StockList& stks, const KQuery& query,
|
|
32
|
-
const Stock& ref_stk, const string& name, int ic_n);
|
|
32
|
+
const Stock& ref_stk, const string& name, int ic_n, bool spearman);
|
|
33
33
|
MultiFactorBase(const MultiFactorBase&);
|
|
34
34
|
virtual ~MultiFactorBase() = default;
|
|
35
35
|
|
|
@@ -17,10 +17,12 @@ namespace hku {
|
|
|
17
17
|
* @param query 日期范围
|
|
18
18
|
* @param ref_stk 参考证券
|
|
19
19
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
20
|
+
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
20
21
|
* @return MultiFactorPtr
|
|
21
22
|
*/
|
|
22
23
|
MultiFactorPtr HKU_API MF_EqualWeight(const IndicatorList& inds, const StockList& stks,
|
|
23
|
-
const KQuery& query, const Stock& ref_stk, int ic_n = 5
|
|
24
|
+
const KQuery& query, const Stock& ref_stk, int ic_n = 5,
|
|
25
|
+
bool spearman = true);
|
|
24
26
|
|
|
25
27
|
MultiFactorPtr HKU_API MF_EqualWeight();
|
|
26
28
|
|
|
@@ -19,11 +19,12 @@ namespace hku {
|
|
|
19
19
|
* @param ref_stk 参考证券
|
|
20
20
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
21
21
|
* @param ic_rolling_n IC 滚动窗口
|
|
22
|
+
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
22
23
|
* @return MultiFactorPtr
|
|
23
24
|
*/
|
|
24
25
|
MultiFactorPtr HKU_API MF_ICIRWeight(const IndicatorList& inds, const StockList& stks,
|
|
25
26
|
const KQuery& query, const Stock& ref_stk, int ic_n = 5,
|
|
26
|
-
int ic_rolling_n = 120);
|
|
27
|
+
int ic_rolling_n = 120, bool spearman = true);
|
|
27
28
|
|
|
28
29
|
MultiFactorPtr HKU_API MF_ICIRWeight();
|
|
29
|
-
}
|
|
30
|
+
} // namespace hku
|
|
@@ -19,10 +19,12 @@ namespace hku {
|
|
|
19
19
|
* @param ref_stk 参考证券
|
|
20
20
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
21
21
|
* @param ic_rolling_n IC 滚动窗口
|
|
22
|
+
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
22
23
|
* @return MultiFactorPtr
|
|
23
24
|
*/
|
|
24
25
|
MultiFactorPtr HKU_API MF_ICWeight(const IndicatorList& inds, const StockList& stks,
|
|
25
26
|
const KQuery& query, const Stock& ref_stk, int ic_n = 5,
|
|
26
|
-
int ic_rolling_n = 120);
|
|
27
|
+
int ic_rolling_n = 120, bool spearman = true);
|
|
27
28
|
MultiFactorPtr HKU_API MF_ICWeight();
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
} // namespace hku
|
|
@@ -18,7 +18,7 @@ class EqualWeightMultiFactor : public MultiFactorBase {
|
|
|
18
18
|
public:
|
|
19
19
|
EqualWeightMultiFactor();
|
|
20
20
|
EqualWeightMultiFactor(const vector<Indicator>& inds, const StockList& stks,
|
|
21
|
-
const KQuery& query, const Stock& ref_stk, int ic_n);
|
|
21
|
+
const KQuery& query, const Stock& ref_stk, int ic_n, bool spearman);
|
|
22
22
|
virtual ~EqualWeightMultiFactor() = default;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -18,7 +18,7 @@ class ICIRMultiFactor : public MultiFactorBase {
|
|
|
18
18
|
public:
|
|
19
19
|
ICIRMultiFactor();
|
|
20
20
|
ICIRMultiFactor(const IndicatorList& inds, const StockList& stks, const KQuery& query,
|
|
21
|
-
const Stock& ref_stk, int ic_n, int ic_rolling_n);
|
|
21
|
+
const Stock& ref_stk, int ic_n, int ic_rolling_n, bool spearman);
|
|
22
22
|
virtual ~ICIRMultiFactor() = default;
|
|
23
23
|
|
|
24
24
|
virtual void _checkParam(const string& name) const override;
|
|
@@ -18,7 +18,7 @@ class ICMultiFactor : public MultiFactorBase {
|
|
|
18
18
|
public:
|
|
19
19
|
ICMultiFactor();
|
|
20
20
|
ICMultiFactor(const IndicatorList& inds, const StockList& stks, const KQuery& query,
|
|
21
|
-
const Stock& ref_stk, int ic_n, int ic_rolling_n);
|
|
21
|
+
const Stock& ref_stk, int ic_n, int ic_rolling_n, bool spearman);
|
|
22
22
|
virtual ~ICMultiFactor() = default;
|
|
23
23
|
|
|
24
24
|
virtual void _checkParam(const string& name) const override;
|
|
@@ -34,10 +34,10 @@ public:
|
|
|
34
34
|
/**
|
|
35
35
|
* @brief 构造函数
|
|
36
36
|
* @param tm 账户
|
|
37
|
-
* @param
|
|
37
|
+
* @param se 选择器
|
|
38
38
|
* @param af 资产分配算法
|
|
39
39
|
*/
|
|
40
|
-
Portfolio(const TradeManagerPtr& tm, const SelectorPtr&
|
|
40
|
+
Portfolio(const TradeManagerPtr& tm, const SelectorPtr& se, const AFPtr& af);
|
|
41
41
|
|
|
42
42
|
/** 析构函数 */
|
|
43
43
|
virtual ~Portfolio();
|
|
@@ -122,13 +122,15 @@ public:
|
|
|
122
122
|
virtual void _removeAll() {}
|
|
123
123
|
|
|
124
124
|
/* 仅供PF调用,由PF通知其实际运行的系统列表,并启动计算 */
|
|
125
|
-
void calculate(const SystemList& pf_realSysList, const KQuery& query);
|
|
125
|
+
virtual void calculate(const SystemList& pf_realSysList, const KQuery& query);
|
|
126
126
|
|
|
127
127
|
/* 仅供PF调用,建立实际系统到原型系统映射 */
|
|
128
128
|
virtual void bindRealToProto(const SYSPtr& real, const SYSPtr& proto) {}
|
|
129
129
|
|
|
130
130
|
void calculate_proto(const KQuery& query);
|
|
131
131
|
|
|
132
|
+
virtual string str() const;
|
|
133
|
+
|
|
132
134
|
private:
|
|
133
135
|
void initParam();
|
|
134
136
|
|
|
@@ -28,12 +28,13 @@ SelectorPtr HKU_API SE_MultiFactor(const MFPtr& mf, int topn = 10);
|
|
|
28
28
|
* @param ic_n ic 对应的 ic_n 日收益率
|
|
29
29
|
* @param ic_rolling_n 计算滚动 IC (即 IC 的 n 日移动平均)周期
|
|
30
30
|
* @param ref_stk 参照对比证券,未指定时,默认使用 sh000300 沪深300指数
|
|
31
|
+
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
31
32
|
* @param mode "MF_ICIRWeight" | "MF_ICWeight" | "MF_EqualWeight" 因子合成算法名称
|
|
32
33
|
* @return SelectorPtr
|
|
33
34
|
* @ingroup Selector
|
|
34
35
|
*/
|
|
35
36
|
SelectorPtr HKU_API SE_MultiFactor(const IndicatorList& src_inds, int topn = 10, int ic_n = 5,
|
|
36
37
|
int ic_rolling_n = 120, const Stock& ref_stk = Stock(),
|
|
37
|
-
const string& mode = "MF_ICIRWeight");
|
|
38
|
+
bool spearman = true, const string& mode = "MF_ICIRWeight");
|
|
38
39
|
|
|
39
40
|
} // namespace hku
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-09-14
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../SelectorBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 账户资产最大寻优选择器
|
|
16
|
+
* @return SEPtr
|
|
17
|
+
*/
|
|
18
|
+
SEPtr HKU_API SE_MaxFundsOptimal();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 使用 Performance 统计结果进行寻优的选择器
|
|
22
|
+
* @return SEPtr
|
|
23
|
+
*/
|
|
24
|
+
SEPtr HKU_API SE_PerformanceOptimal(const string& key = "帐户平均年收益率%", int mode = 0);
|
|
25
|
+
|
|
26
|
+
} // namespace hku
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-09-22
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef HKU_TRADE_SYS_MAX_FUNDS_OPTIMAL_SELECTOR_H_
|
|
10
|
+
#define HKU_TRADE_SYS_MAX_FUNDS_OPTIMAL_SELECTOR_H_
|
|
11
|
+
|
|
12
|
+
#include "OptimalSelectorBase.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
class MaxFundsOptimalSelector : public OptimalSelectorBase {
|
|
17
|
+
OPTIMAL_SELECTOR_IMP(MaxFundsOptimalSelector)
|
|
18
|
+
OPTIMAL_SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
MaxFundsOptimalSelector();
|
|
22
|
+
virtual ~MaxFundsOptimalSelector();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace hku
|
|
26
|
+
|
|
27
|
+
#endif /* HKU_TRADE_SYS_MAX_FUNDS_OPTIMAL_SELECTOR_H_ */
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-09-13
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#include "hikyuu/trade_sys/selector/SelectorBase.h"
|
|
10
|
+
|
|
11
|
+
namespace hku {
|
|
12
|
+
|
|
13
|
+
//
|
|
14
|
+
// start ------ run_start --end
|
|
15
|
+
// | train_len | test_len
|
|
16
|
+
//
|
|
17
|
+
struct RunRanges {
|
|
18
|
+
Datetime start;
|
|
19
|
+
Datetime run_start;
|
|
20
|
+
Datetime end;
|
|
21
|
+
|
|
22
|
+
RunRanges(const Datetime& start_, const Datetime& run_start_, const Datetime end_)
|
|
23
|
+
: start(start_), run_start(run_start_), end(end_) {}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class HKU_API OptimalSelectorBase : public SelectorBase {
|
|
27
|
+
CLASS_LOGGER_IMP(SE_Optimal)
|
|
28
|
+
SELECTOR_IMP(OptimalSelectorBase)
|
|
29
|
+
SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
OptimalSelectorBase();
|
|
33
|
+
explicit OptimalSelectorBase(const string& name);
|
|
34
|
+
virtual ~OptimalSelectorBase() = default;
|
|
35
|
+
|
|
36
|
+
virtual void _checkParam(const string& name) const override;
|
|
37
|
+
virtual void calculate(const SystemList& pf_realSysList, const KQuery& query) override;
|
|
38
|
+
|
|
39
|
+
virtual void _reset() override;
|
|
40
|
+
|
|
41
|
+
virtual string str() const override;
|
|
42
|
+
|
|
43
|
+
// 以便继承子类只需要实现 _clone 和 该接口即可
|
|
44
|
+
// 该接口实现系统绩效评估,getSelected 时将取评估结果最大的系统
|
|
45
|
+
// 使用 std::function 的话,在 C++ 中无法序列化,所以使用继承
|
|
46
|
+
virtual double evaluate(const SYSPtr& sys, const Datetime& endDate) noexcept {
|
|
47
|
+
return Null<double>();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const vector<RunRanges>& getRunRanges() const {
|
|
51
|
+
return m_run_ranges;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private:
|
|
55
|
+
void _initParams();
|
|
56
|
+
void _calculate_single(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
57
|
+
const DatetimeList& dates, size_t test_len, bool trace);
|
|
58
|
+
|
|
59
|
+
void _calculate_parallel(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
60
|
+
const DatetimeList& dates, size_t test_len, bool trace);
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
unordered_map<Datetime, std::shared_ptr<SystemWeightList>> m_sys_dict;
|
|
64
|
+
vector<RunRanges> m_run_ranges;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
#if HKU_SUPPORT_SERIALIZATION
|
|
68
|
+
#define OPTIMAL_SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION \
|
|
69
|
+
private: \
|
|
70
|
+
friend class boost::serialization::access; \
|
|
71
|
+
template <class Archive> \
|
|
72
|
+
void serialize(Archive& ar, const unsigned int version) { \
|
|
73
|
+
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase); \
|
|
74
|
+
}
|
|
75
|
+
#else
|
|
76
|
+
#define OPTIMAL_SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
#define OPTIMAL_SELECTOR_IMP(classname) \
|
|
80
|
+
public: \
|
|
81
|
+
virtual SelectorPtr _clone() override { \
|
|
82
|
+
return std::make_shared<classname>(); \
|
|
83
|
+
} \
|
|
84
|
+
virtual double evaluate(const SYSPtr&, const Datetime& endDate) noexcept override;
|
|
85
|
+
|
|
86
|
+
} // namespace hku
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-09-13
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "OptimalSelectorBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
class PerformanceOptimalSelector : public OptimalSelectorBase {
|
|
15
|
+
CLASS_LOGGER_IMP(SE_Optimal)
|
|
16
|
+
OPTIMAL_SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
PerformanceOptimalSelector();
|
|
20
|
+
virtual ~PerformanceOptimalSelector() = default;
|
|
21
|
+
|
|
22
|
+
virtual void _checkParam(const string& name) const override;
|
|
23
|
+
virtual void calculate(const SystemList& pf_realSysList, const KQuery& query) override;
|
|
24
|
+
|
|
25
|
+
virtual SystemWeightList getSelected(Datetime date);
|
|
26
|
+
virtual SelectorPtr _clone() override;
|
|
27
|
+
virtual void _reset() override;
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
void _calculate_single(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
31
|
+
const DatetimeList& dates, const string& key, int mode, size_t test_len,
|
|
32
|
+
bool trace);
|
|
33
|
+
|
|
34
|
+
void _calculate_parallel(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
35
|
+
const DatetimeList& dates, const string& key, int mode,
|
|
36
|
+
size_t test_len, bool trace);
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
unordered_map<Datetime, SYSPtr> m_sys_dict;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
} // namespace hku
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -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 "../SignalBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 仅能手动添加信号的信号指示器,用于测试或其他特殊用途
|
|
16
|
+
* @return SignalPtr
|
|
17
|
+
*/
|
|
18
|
+
SignalPtr HKU_API SG_Manual();
|
|
19
|
+
|
|
20
|
+
} // namespace hku
|
|
@@ -0,0 +1,23 @@
|
|
|
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 "../SignalBase.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
class ManualSignal : public SignalBase {
|
|
15
|
+
SIGNAL_IMP(ManualSignal)
|
|
16
|
+
SIGNAL_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
ManualSignal();
|
|
20
|
+
virtual ~ManualSignal() = default;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace hku
|