hikyuu 2.3.0__py3-none-win_amd64.whl → 2.5.0__py3-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/__init__.py +438 -6
- hikyuu/__init__.pyi +791 -0
- hikyuu/analysis/__init__.pyi +487 -0
- hikyuu/analysis/analysis.pyi +517 -0
- hikyuu/core.pyi +482 -0
- hikyuu/cpp/__init__.pyi +3 -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/core311.pyd +0 -0
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +12867 -0
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/common_mysql.py +24 -7
- hikyuu/data/common_pytdx.py +17 -1
- hikyuu/data/em_block_to_mysql.py +3 -2
- hikyuu/data/em_block_to_sqlite.py +8 -3
- hikyuu/data/mysql_upgrade/0025.sql +61 -0
- hikyuu/data/mysql_upgrade/0026.sql +9 -0
- hikyuu/data/sqlite_upgrade/0025.sql +63 -0
- hikyuu/data/sqlite_upgrade/0026.sql +10 -0
- hikyuu/draw/__init__.pyi +35 -0
- hikyuu/draw/drawplot/__init__.py +3 -0
- hikyuu/draw/drawplot/__init__.pyi +134 -0
- hikyuu/draw/drawplot/bokeh_draw.pyi +796 -0
- hikyuu/draw/drawplot/common.pyi +10 -0
- hikyuu/draw/drawplot/echarts_draw.py +219 -24
- hikyuu/draw/drawplot/echarts_draw.pyi +682 -0
- hikyuu/draw/drawplot/matplotlib_draw.py +18 -3
- hikyuu/draw/drawplot/matplotlib_draw.pyi +1101 -0
- hikyuu/draw/elder.pyi +44 -0
- hikyuu/draw/kaufman.pyi +38 -0
- hikyuu/draw/volume.pyi +31 -0
- hikyuu/examples/notebook/Demo/Demo2.ipynb +1 -1
- hikyuu/extend.py +9 -3
- hikyuu/extend.pyi +636 -0
- hikyuu/fetcher/stock/zh_block_em.py +118 -51
- hikyuu/gui/data/EscapetimeThread.py +4 -4
- hikyuu/gui/data/ImportBlockInfoTask.py +3 -2
- hikyuu/gui/data/ImportHistoryFinanceTask.py +2 -0
- hikyuu/gui/data/MainWindow.py +48 -42
- hikyuu/gui/importdata.py +13 -26
- hikyuu/hub.py +2 -4
- hikyuu/hub.pyi +254 -0
- hikyuu/include/hikyuu/DataType.h +5 -0
- hikyuu/include/hikyuu/Stock.h +7 -0
- hikyuu/include/hikyuu/indicator/Indicator.h +8 -1
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +65 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +4 -3
- hikyuu/include/hikyuu/indicator/build_in.h +12 -0
- hikyuu/include/hikyuu/indicator/crt/ADVANCE.h +3 -1
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/CORR.h +4 -2
- hikyuu/include/hikyuu/indicator/crt/COST.h +3 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/DECLINE.h +3 -1
- hikyuu/include/hikyuu/indicator/crt/DISCARD.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/DMA.h +2 -1
- hikyuu/include/hikyuu/indicator/crt/HSL.h +1 -13
- hikyuu/include/hikyuu/indicator/crt/INBLOCK.h +31 -0
- hikyuu/include/hikyuu/indicator/crt/INDEX.h +60 -0
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +5 -2
- hikyuu/include/hikyuu/indicator/crt/ISINF.h +28 -0
- hikyuu/include/hikyuu/indicator/crt/ISINFA.h +28 -0
- hikyuu/include/hikyuu/indicator/crt/ISNA.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/JUMPDOWN.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/JUMPUP.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/LASTVALUE.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/LIUTONGPAN.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/REPLACE.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
- hikyuu/include/hikyuu/indicator/crt/WINNER.h +38 -0
- hikyuu/include/hikyuu/indicator/imp/IContext.h +1 -1
- hikyuu/include/hikyuu/indicator/imp/ICorr.h +7 -22
- hikyuu/include/hikyuu/indicator/imp/ICost.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/ICycle.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IDiscard.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IDma.h +7 -24
- hikyuu/include/hikyuu/indicator/imp/IHsl.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IInBlock.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IIndex.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInf.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInfa.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIsNa.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpDown.h +24 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpUp.h +24 -0
- hikyuu/include/hikyuu/indicator/imp/ILastValue.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IReplace.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/ISpearman.h +6 -21
- hikyuu/include/hikyuu/indicator/imp/IWinner.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMavp.h +6 -20
- hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +14 -65
- hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +54 -90
- hikyuu/include/hikyuu/indicator_talib/ta_crt.h +11 -9
- hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +3 -4
- hikyuu/include/hikyuu/strategy/Strategy.h +4 -5
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +5 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedWeightList.h +22 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixedWeightListAllocateFunds.h +25 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +17 -4
- hikyuu/include/hikyuu/trade_sys/moneymanager/build_in.h +2 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapital.h +6 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapitalFunds.h +26 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCountTps.h +27 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedRisk.h +6 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedUnits.h +6 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_WilliamsFixedRisk.h +7 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCountTpsMM.h +44 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +30 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +41 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +38 -37
- hikyuu/include/hikyuu/trade_sys/portfolio/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_Simple.h +25 -1
- hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_WithoutAF.h +50 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +53 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +57 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +7 -0
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +51 -5
- hikyuu/include/hikyuu/trade_sys/signal/build_in.h +2 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Bool.h +2 -1
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Logic.h +37 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_OneSide.h +28 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/OneSideSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +68 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +67 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/crt/ST_Indicator.h +1 -1
- hikyuu/include/hikyuu/trade_sys/stoploss/imp/IndicatorStoploss.h +3 -4
- hikyuu/include/hikyuu/utilities/FilterNode.h +2 -2
- hikyuu/include/hikyuu/utilities/Log.h +42 -15
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -1
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +2 -2
- hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +4 -0
- hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +2 -2
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +5 -1
- hikyuu/include/hikyuu/utilities/node/NodeServer.h +4 -4
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +2 -2
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +2 -2
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +5 -5
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +2 -2
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +16 -10
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/indicator/indicator.py +1 -0
- hikyuu/interactive.py +3 -266
- hikyuu/trade_manage/__init__.pyi +584 -0
- hikyuu/trade_manage/broker.pyi +54 -0
- hikyuu/trade_manage/broker_easytrader.pyi +21 -0
- hikyuu/trade_manage/broker_mail.pyi +55 -0
- hikyuu/trade_manage/trade.pyi +590 -0
- hikyuu/util/__init__.pyi +55 -0
- hikyuu/util/check.pyi +59 -0
- hikyuu/util/mylog.pyi +70 -0
- hikyuu/util/notebook.pyi +23 -0
- hikyuu/util/singleton.pyi +18 -0
- hikyuu/util/slice.pyi +8 -0
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/METADATA +3 -2
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/RECORD +178 -95
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/top_level.txt +1 -0
- hikyuu/deprecated.py +0 -651
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/LICENSE +0 -0
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/WHEEL +0 -0
- {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-01-08
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef INDICATOR_IMP_IISNA_H_
|
|
10
|
+
#define INDICATOR_IMP_IISNA_H_
|
|
11
|
+
|
|
12
|
+
#include "../Indicator.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
class IIsNa : public IndicatorImp {
|
|
17
|
+
INDICATOR_IMP(IIsNa)
|
|
18
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
IIsNa();
|
|
22
|
+
virtual ~IIsNa();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} /* namespace hku */
|
|
26
|
+
#endif /* INDICATOR_IMP_IISNA_H_ */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-02-10
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/* 边缘跳变,从大于0.0,跳变到 <= 0.0 */
|
|
15
|
+
class IJumpDown : public IndicatorImp {
|
|
16
|
+
INDICATOR_IMP(IJumpDown)
|
|
17
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
18
|
+
|
|
19
|
+
public:
|
|
20
|
+
IJumpDown();
|
|
21
|
+
virtual ~IJumpDown();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} /* namespace hku */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-02-10
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/* 边缘跳变,从小于等于0.0,跳变到 > 0.0 */
|
|
15
|
+
class IJumpUp : public IndicatorImp {
|
|
16
|
+
INDICATOR_IMP(IJumpUp)
|
|
17
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
18
|
+
|
|
19
|
+
public:
|
|
20
|
+
IJumpUp();
|
|
21
|
+
virtual ~IJumpUp();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} /* namespace hku */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-02-04
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef INDICATOR_IMP_ILASTVALUE_H_
|
|
10
|
+
#define INDICATOR_IMP_ILASTVALUE_H_
|
|
11
|
+
|
|
12
|
+
#include "../Indicator.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
class ILastValue : public IndicatorImp {
|
|
17
|
+
INDICATOR_IMP(ILastValue)
|
|
18
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
ILastValue();
|
|
22
|
+
virtual ~ILastValue();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} /* namespace hku */
|
|
26
|
+
#endif /* INDICATOR_IMP_ILASTVALUE_H_ */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-01-12
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* 替换指定数值,通常用于替换 Nan 值
|
|
16
|
+
*/
|
|
17
|
+
class IReplace : public IndicatorImp {
|
|
18
|
+
INDICATOR_IMP(IReplace)
|
|
19
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
IReplace();
|
|
23
|
+
virtual ~IReplace();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} /* namespace hku */
|
|
@@ -7,35 +7,20 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "../
|
|
10
|
+
#include "../Indicator2InImp.h"
|
|
11
11
|
|
|
12
12
|
namespace hku {
|
|
13
13
|
|
|
14
|
-
class ISpearman : public
|
|
14
|
+
class ISpearman : public Indicator2InImp {
|
|
15
|
+
INDICATOR2IN_IMP(ISpearman)
|
|
16
|
+
INDICATOR2IN_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
17
|
+
|
|
15
18
|
public:
|
|
16
19
|
ISpearman();
|
|
17
|
-
ISpearman(const Indicator& ref_ind, int n);
|
|
20
|
+
ISpearman(const Indicator& ref_ind, int n, bool fill_null);
|
|
18
21
|
virtual ~ISpearman();
|
|
19
22
|
|
|
20
23
|
virtual void _checkParam(const string& name) const override;
|
|
21
|
-
virtual void _calculate(const Indicator& data) override;
|
|
22
|
-
virtual IndicatorImpPtr _clone() override;
|
|
23
|
-
|
|
24
|
-
private:
|
|
25
|
-
Indicator m_ref_ind;
|
|
26
|
-
|
|
27
|
-
//============================================
|
|
28
|
-
// 序列化支持
|
|
29
|
-
//============================================
|
|
30
|
-
#if HKU_SUPPORT_SERIALIZATION
|
|
31
|
-
private:
|
|
32
|
-
friend class boost::serialization::access;
|
|
33
|
-
template <class Archive>
|
|
34
|
-
void serialize(Archive& ar, const unsigned int version) {
|
|
35
|
-
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(IndicatorImp);
|
|
36
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_ind);
|
|
37
|
-
}
|
|
38
|
-
#endif
|
|
39
24
|
};
|
|
40
25
|
|
|
41
26
|
} // namespace hku
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-01-25
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef INDICATOR_IMP_IWINNER_H_
|
|
10
|
+
#define INDICATOR_IMP_IWINNER_H_
|
|
11
|
+
|
|
12
|
+
#include "../Indicator.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
class IWinner : public IndicatorImp {
|
|
17
|
+
INDICATOR_IMP(IWinner)
|
|
18
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
IWinner();
|
|
22
|
+
virtual ~IWinner();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} /* namespace hku */
|
|
26
|
+
#endif /* INDICATOR_IMP_IWINNER_H_ */
|
|
@@ -8,34 +8,20 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
#include "hikyuu/indicator/Indicator.h"
|
|
11
|
+
#include "hikyuu/indicator/Indicator2InImp.h"
|
|
11
12
|
|
|
12
13
|
namespace hku {
|
|
13
14
|
|
|
14
|
-
class TaMavp : public
|
|
15
|
+
class TaMavp : public Indicator2InImp {
|
|
16
|
+
INDICATOR2IN_IMP(TaMavp)
|
|
17
|
+
INDICATOR2IN_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
18
|
+
|
|
15
19
|
public:
|
|
16
20
|
TaMavp();
|
|
17
|
-
TaMavp(const Indicator& ref_ind, int min_n, int max_n, int matype);
|
|
21
|
+
TaMavp(const Indicator& ref_ind, int min_n, int max_n, int matype, bool fill_null);
|
|
18
22
|
virtual ~TaMavp();
|
|
19
23
|
|
|
20
24
|
virtual void _checkParam(const string& name) const override;
|
|
21
|
-
virtual void _calculate(const Indicator& data) override;
|
|
22
|
-
virtual IndicatorImpPtr _clone() override;
|
|
23
|
-
|
|
24
|
-
private:
|
|
25
|
-
Indicator m_ref_ind;
|
|
26
|
-
|
|
27
|
-
//============================================
|
|
28
|
-
// 序列化支持
|
|
29
|
-
//============================================
|
|
30
|
-
#if HKU_SUPPORT_SERIALIZATION
|
|
31
|
-
private:
|
|
32
|
-
friend class boost::serialization::access;
|
|
33
|
-
template <class Archive>
|
|
34
|
-
void serialize(Archive& ar, const unsigned int version) {
|
|
35
|
-
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(IndicatorImp);
|
|
36
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_ind);
|
|
37
|
-
}
|
|
38
|
-
#endif
|
|
39
25
|
};
|
|
40
26
|
|
|
41
27
|
} // namespace hku
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
#include "hikyuu/indicator/Indicator.h"
|
|
11
|
+
#include "hikyuu/indicator/Indicator2InImp.h"
|
|
11
12
|
|
|
12
13
|
#define TA_IN1_OUT_DEF(func) \
|
|
13
14
|
class Cls_##func : public IndicatorImp { \
|
|
@@ -30,79 +31,27 @@
|
|
|
30
31
|
virtual void _checkParam(const string& name) const override; \
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Cls_##func(
|
|
39
|
-
|
|
40
|
-
virtual
|
|
41
|
-
virtual IndicatorImpPtr _clone() override; \
|
|
42
|
-
\
|
|
43
|
-
private: \
|
|
44
|
-
Indicator m_ref_ind; \
|
|
45
|
-
\
|
|
46
|
-
private: \
|
|
47
|
-
friend class boost::serialization::access; \
|
|
48
|
-
template <class Archive> \
|
|
49
|
-
void serialize(Archive& ar, const unsigned int version) { \
|
|
50
|
-
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(IndicatorImp); \
|
|
51
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_ind); \
|
|
52
|
-
} \
|
|
34
|
+
#define TA_IN2_OUT_DEF(func) \
|
|
35
|
+
class Cls_##func : public Indicator2InImp { \
|
|
36
|
+
INDICATOR2IN_IMP(Cls_##func) \
|
|
37
|
+
INDICATOR2IN_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
|
|
38
|
+
public: \
|
|
39
|
+
Cls_##func(); \
|
|
40
|
+
Cls_##func(const Indicator& ref_ind, bool fill_null); \
|
|
41
|
+
virtual ~Cls_##func(); \
|
|
53
42
|
};
|
|
54
43
|
|
|
55
44
|
#define TA_IN2_OUT_N_DEF(func) \
|
|
56
|
-
class Cls_##func : public
|
|
45
|
+
class Cls_##func : public Indicator2InImp { \
|
|
46
|
+
INDICATOR2IN_IMP(Cls_##func) \
|
|
47
|
+
INDICATOR2IN_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
|
|
57
48
|
public: \
|
|
58
49
|
Cls_##func(); \
|
|
59
|
-
explicit Cls_##func(int n);
|
|
60
|
-
Cls_##func(const Indicator& ref_ind, int n);
|
|
50
|
+
explicit Cls_##func(int n, bool fill_null); \
|
|
51
|
+
Cls_##func(const Indicator& ref_ind, int n, bool fill_null); \
|
|
61
52
|
virtual ~Cls_##func(); \
|
|
62
53
|
virtual void _checkParam(const string& name) const override; \
|
|
63
|
-
virtual void _calculate(const Indicator& data) override; \
|
|
64
|
-
virtual IndicatorImpPtr _clone() override; \
|
|
65
|
-
\
|
|
66
|
-
private: \
|
|
67
|
-
Indicator m_ref_ind; \
|
|
68
|
-
\
|
|
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(IndicatorImp); \
|
|
74
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_ind); \
|
|
75
|
-
} \
|
|
76
|
-
};
|
|
77
|
-
#else
|
|
78
|
-
#define TA_IN2_OUT_DEF(func) \
|
|
79
|
-
class Cls_##func : public IndicatorImp { \
|
|
80
|
-
public: \
|
|
81
|
-
Cls_##func(); \
|
|
82
|
-
Cls_##func(const Indicator& ref_ind); \
|
|
83
|
-
virtual ~Cls_##func(); \
|
|
84
|
-
virtual void _calculate(const Indicator& data) override; \
|
|
85
|
-
virtual IndicatorImpPtr _clone() override; \
|
|
86
|
-
\
|
|
87
|
-
private: \
|
|
88
|
-
Indicator m_ref_ind; \
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
#define TA_IN2_OUT_N_DEF(func) \
|
|
92
|
-
class Cls_##func : public IndicatorImp { \
|
|
93
|
-
public: \
|
|
94
|
-
Cls_##func(); \
|
|
95
|
-
explicit Cls_##func(int n); \
|
|
96
|
-
Cls_##func(const Indicator& ref_ind, int n); \
|
|
97
|
-
virtual ~Cls_##func(); \
|
|
98
|
-
virtual void _checkParam(const string& name) const override; \
|
|
99
|
-
virtual void _calculate(const Indicator& data) override; \
|
|
100
|
-
virtual IndicatorImpPtr _clone() override; \
|
|
101
|
-
\
|
|
102
|
-
private: \
|
|
103
|
-
Indicator m_ref_ind; \
|
|
104
54
|
};
|
|
105
|
-
#endif
|
|
106
55
|
|
|
107
56
|
#define TA_K_OUT_DEF(func) \
|
|
108
57
|
class Cls_##func : public IndicatorImp { \
|
|
@@ -447,80 +447,63 @@
|
|
|
447
447
|
return Indicator(p); \
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
#define TA_IN2_OUT1_IMP(func, func_lookback)
|
|
451
|
-
Cls_##func::Cls_##func() :
|
|
452
|
-
Cls_##func::Cls_##func(const Indicator &ref_ind)
|
|
453
|
-
:
|
|
454
|
-
Cls_##func::~Cls_##func() {}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
\
|
|
494
|
-
const auto *src0 = ind.data(); \
|
|
495
|
-
const auto *src1 = ref.data(); \
|
|
496
|
-
auto *dst = this->data(); \
|
|
497
|
-
int outBegIdx; \
|
|
498
|
-
int outNbElement; \
|
|
499
|
-
func(m_discard, total - 1, src0, src1, &outBegIdx, &outNbElement, dst + m_discard); \
|
|
500
|
-
HKU_ASSERT((outBegIdx == m_discard) && (outBegIdx + outNbElement) <= total); \
|
|
501
|
-
} \
|
|
502
|
-
\
|
|
503
|
-
Indicator HKU_API func() { \
|
|
504
|
-
return Indicator(make_shared<Cls_##func>()); \
|
|
505
|
-
} \
|
|
506
|
-
\
|
|
507
|
-
Indicator HKU_API func(const Indicator &ind1, const Indicator &ind2) { \
|
|
508
|
-
auto p = make_shared<Cls_##func>(ind2); \
|
|
509
|
-
Indicator result(p); \
|
|
510
|
-
return result(ind1); \
|
|
450
|
+
#define TA_IN2_OUT1_IMP(func, func_lookback) \
|
|
451
|
+
Cls_##func::Cls_##func() : Indicator2InImp(#func, 1) {} \
|
|
452
|
+
Cls_##func::Cls_##func(const Indicator &ref_ind, bool fill_null) \
|
|
453
|
+
: Indicator2InImp(#func, ref_ind, fill_null, 1) {} \
|
|
454
|
+
Cls_##func::~Cls_##func() {} \
|
|
455
|
+
\
|
|
456
|
+
void Cls_##func::_calculate(const Indicator &ind) { \
|
|
457
|
+
size_t total = ind.size(); \
|
|
458
|
+
HKU_IF_RETURN(total == 0, void()); \
|
|
459
|
+
\
|
|
460
|
+
Indicator ref = prepare(ind); \
|
|
461
|
+
int lookback = func_lookback(); \
|
|
462
|
+
if (lookback < 0) { \
|
|
463
|
+
m_discard = total; \
|
|
464
|
+
return; \
|
|
465
|
+
} \
|
|
466
|
+
\
|
|
467
|
+
size_t in_discard = std::max(ind.discard(), ref.discard()); \
|
|
468
|
+
m_discard = lookback + in_discard; \
|
|
469
|
+
if (m_discard >= total) { \
|
|
470
|
+
m_discard = total; \
|
|
471
|
+
return; \
|
|
472
|
+
} \
|
|
473
|
+
\
|
|
474
|
+
const auto *src0 = ind.data(); \
|
|
475
|
+
const auto *src1 = ref.data(); \
|
|
476
|
+
auto *dst = this->data(); \
|
|
477
|
+
int outBegIdx; \
|
|
478
|
+
int outNbElement; \
|
|
479
|
+
func(m_discard, total - 1, src0, src1, &outBegIdx, &outNbElement, dst + m_discard); \
|
|
480
|
+
HKU_ASSERT((outBegIdx == m_discard) && (outBegIdx + outNbElement) <= total); \
|
|
481
|
+
} \
|
|
482
|
+
\
|
|
483
|
+
Indicator HKU_API func(bool fill_null = true) { \
|
|
484
|
+
auto p = make_shared<Cls_##func>(); \
|
|
485
|
+
p->setParam<bool>("fill_null", fill_null); \
|
|
486
|
+
return Indicator(p); \
|
|
487
|
+
} \
|
|
488
|
+
\
|
|
489
|
+
Indicator HKU_API func(const Indicator &ind1, const Indicator &ind2, bool fill_null = true) { \
|
|
490
|
+
auto p = make_shared<Cls_##func>(ind2, fill_null); \
|
|
491
|
+
Indicator result(p); \
|
|
492
|
+
return result(ind1); \
|
|
511
493
|
}
|
|
512
494
|
|
|
513
495
|
#define TA_IN2_OUT1_N_IMP(func, func_lookback, period, period_min, period_max) \
|
|
514
|
-
Cls_##func::Cls_##func() :
|
|
496
|
+
Cls_##func::Cls_##func() : Indicator2InImp(#func, 1) { \
|
|
515
497
|
setParam<int>("n", period); \
|
|
516
498
|
} \
|
|
517
499
|
\
|
|
518
|
-
Cls_##func::Cls_##func(int n) :
|
|
500
|
+
Cls_##func::Cls_##func(int n, bool fill_null) : Indicator2InImp(#func, 1) { \
|
|
519
501
|
setParam<int>("n", n); \
|
|
502
|
+
setParam<bool>("fill_null", fill_null); \
|
|
520
503
|
} \
|
|
521
504
|
\
|
|
522
|
-
Cls_##func::Cls_##func(const Indicator &ref_ind, int n)
|
|
523
|
-
:
|
|
505
|
+
Cls_##func::Cls_##func(const Indicator &ref_ind, int n, bool fill_null) \
|
|
506
|
+
: Indicator2InImp(#func, ref_ind, fill_null, 1) { \
|
|
524
507
|
setParam<int>("n", n); \
|
|
525
508
|
} \
|
|
526
509
|
\
|
|
@@ -533,31 +516,11 @@
|
|
|
533
516
|
} \
|
|
534
517
|
} \
|
|
535
518
|
\
|
|
536
|
-
IndicatorImpPtr Cls_##func::_clone() { \
|
|
537
|
-
auto p = make_shared<Cls_##func>(); \
|
|
538
|
-
p->m_ref_ind = m_ref_ind.clone(); \
|
|
539
|
-
return p; \
|
|
540
|
-
} \
|
|
541
|
-
\
|
|
542
519
|
void Cls_##func::_calculate(const Indicator &ind) { \
|
|
543
520
|
size_t total = ind.size(); \
|
|
544
521
|
HKU_IF_RETURN(total == 0, void()); \
|
|
545
522
|
\
|
|
546
|
-
|
|
547
|
-
\
|
|
548
|
-
auto k = getContext(); \
|
|
549
|
-
m_ref_ind.setContext(k); \
|
|
550
|
-
Indicator ref = m_ref_ind; \
|
|
551
|
-
auto dates = ref.getDatetimeList(); \
|
|
552
|
-
if (dates.empty()) { \
|
|
553
|
-
if (ref.size() > ind.size()) { \
|
|
554
|
-
ref = SLICE(ref, ref.size() - ind.size(), ref.size()); \
|
|
555
|
-
} else if (ref.size() < ind.size()) { \
|
|
556
|
-
ref = CVAL(ind, 0.) + ref; \
|
|
557
|
-
} \
|
|
558
|
-
} else if (m_ref_ind.size() != ind.size()) { \
|
|
559
|
-
ref = ALIGN(m_ref_ind, ind); \
|
|
560
|
-
} \
|
|
523
|
+
Indicator ref = prepare(ind); \
|
|
561
524
|
\
|
|
562
525
|
int n = getParam<int>("n"); \
|
|
563
526
|
int lookback = func_lookback(n); \
|
|
@@ -582,12 +545,13 @@
|
|
|
582
545
|
HKU_ASSERT((outBegIdx == m_discard) && (outBegIdx + outNbElement) <= total); \
|
|
583
546
|
} \
|
|
584
547
|
\
|
|
585
|
-
Indicator HKU_API func(int n) {
|
|
586
|
-
return Indicator(make_shared<Cls_##func>(n));
|
|
548
|
+
Indicator HKU_API func(int n, bool fill_null = true) { \
|
|
549
|
+
return Indicator(make_shared<Cls_##func>(n, fill_null)); \
|
|
587
550
|
} \
|
|
588
551
|
\
|
|
589
|
-
Indicator HKU_API func(const Indicator &ind1, const Indicator &ind2, int n
|
|
590
|
-
|
|
552
|
+
Indicator HKU_API func(const Indicator &ind1, const Indicator &ind2, int n, \
|
|
553
|
+
bool fill_null = true) { \
|
|
554
|
+
auto p = make_shared<Cls_##func>(ind2, n, fill_null); \
|
|
591
555
|
HKU_WARN_IF(ind2.size() == 0, "The lenght of ind2 is zero!"); \
|
|
592
556
|
Indicator result(p); \
|
|
593
557
|
return result(ind1); \
|
|
@@ -35,13 +35,14 @@
|
|
|
35
35
|
return func(IndParam(n))(data); \
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
#define TA_IN2_OUT_CRT(func)
|
|
39
|
-
Indicator HKU_API func(const Indicator& ind1, const Indicator& ind2); \
|
|
40
|
-
Indicator HKU_API func();
|
|
38
|
+
#define TA_IN2_OUT_CRT(func) \
|
|
39
|
+
Indicator HKU_API func(const Indicator& ind1, const Indicator& ind2, bool fill_null = true); \
|
|
40
|
+
Indicator HKU_API func(bool fill_null = true);
|
|
41
41
|
|
|
42
|
-
#define TA_IN2_OUT_N_CRT(func, period)
|
|
43
|
-
Indicator HKU_API func(const Indicator& ind1, const Indicator& ind2, int n = period
|
|
44
|
-
|
|
42
|
+
#define TA_IN2_OUT_N_CRT(func, period) \
|
|
43
|
+
Indicator HKU_API func(const Indicator& ind1, const Indicator& ind2, int n = period, \
|
|
44
|
+
bool fill_null = true); \
|
|
45
|
+
Indicator HKU_API func(int n = period, bool fill_null = true);
|
|
45
46
|
|
|
46
47
|
#define TA_K_OUT_CRT(func) \
|
|
47
48
|
Indicator HKU_API func(); \
|
|
@@ -209,10 +210,11 @@ inline Indicator TA_MAMA(const Indicator& ind, double fast_limit = 5.000000e-1,
|
|
|
209
210
|
return TA_MAMA(fast_limit, slow_limit)(ind);
|
|
210
211
|
}
|
|
211
212
|
|
|
212
|
-
Indicator HKU_API TA_MAVP(const Indicator& ref_ind, int min_n = 2, int max_n = 30, int matype = 0
|
|
213
|
+
Indicator HKU_API TA_MAVP(const Indicator& ref_ind, int min_n = 2, int max_n = 30, int matype = 0,
|
|
214
|
+
bool fill_null = true);
|
|
213
215
|
inline Indicator TA_MAVP(const Indicator& ind1, const Indicator& ind2, int min_n = 2,
|
|
214
|
-
int max_n = 30, int matype = 0) {
|
|
215
|
-
return TA_MAVP(ind2, min_n, max_n, matype)(ind1);
|
|
216
|
+
int max_n = 30, int matype = 0, bool fill_null = true) {
|
|
217
|
+
return TA_MAVP(ind2, min_n, max_n, matype, fill_null)(ind1);
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
TA_IN1_OUT_N_CRT(TA_MAX, 30)
|
|
@@ -15,8 +15,8 @@ namespace hku {
|
|
|
15
15
|
class HKU_API RunPortfolioInStrategy {
|
|
16
16
|
public:
|
|
17
17
|
RunPortfolioInStrategy() = default;
|
|
18
|
-
RunPortfolioInStrategy(const PFPtr& pf, const KQuery& query,
|
|
19
|
-
const
|
|
18
|
+
RunPortfolioInStrategy(const PFPtr& pf, const KQuery& query, const OrderBrokerPtr& broker,
|
|
19
|
+
const TradeCostPtr& costfunc);
|
|
20
20
|
virtual ~RunPortfolioInStrategy() = default;
|
|
21
21
|
|
|
22
22
|
void run();
|
|
@@ -25,10 +25,9 @@ private:
|
|
|
25
25
|
PFPtr m_pf;
|
|
26
26
|
OrderBrokerPtr m_broker;
|
|
27
27
|
KQuery m_query;
|
|
28
|
-
int m_adjust_cycle = 1;
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
StrategyPtr HKU_API crtPFStrategy(const PFPtr& pf, const KQuery& query,
|
|
30
|
+
StrategyPtr HKU_API crtPFStrategy(const PFPtr& pf, const KQuery& query,
|
|
32
31
|
const OrderBrokerPtr& broker, const TradeCostPtr& costfunc,
|
|
33
32
|
const string& name = "PFStrategy",
|
|
34
33
|
const std::vector<OrderBrokerPtr>& other_brokers = {},
|
|
@@ -133,8 +133,8 @@ private:
|
|
|
133
133
|
|
|
134
134
|
/** 向线程池提交任务 */
|
|
135
135
|
template <typename FunctionType>
|
|
136
|
-
|
|
137
|
-
typedef typename std::
|
|
136
|
+
auto event(FunctionType f) {
|
|
137
|
+
typedef typename std::invoke_result<FunctionType>::type result_type;
|
|
138
138
|
std::packaged_task<result_type()> task(f);
|
|
139
139
|
event_handle<result_type> res(task.get_future());
|
|
140
140
|
m_event_queue.push(std::move(task));
|
|
@@ -169,13 +169,12 @@ void HKU_API runInStrategy(const SYSPtr& sys, const Stock& stk, const KQuery& qu
|
|
|
169
169
|
* @note 目前仅支持 buy_delay| sell_delay 均为 false 的系统,即 close 时执行交易
|
|
170
170
|
* @param pf 资产组合
|
|
171
171
|
* @param query 查询条件
|
|
172
|
-
* @param adjust_cycle 调仓周期
|
|
173
172
|
* @param broker 订单代理(专用与和账户资产同步的订单代理)
|
|
174
173
|
* @param costfunc 成本函数
|
|
175
174
|
* @param other_brokers 其他的订单代理
|
|
176
175
|
*/
|
|
177
|
-
void HKU_API runInStrategy(const PFPtr& pf, const KQuery& query,
|
|
178
|
-
const
|
|
176
|
+
void HKU_API runInStrategy(const PFPtr& pf, const KQuery& query, const OrderBrokerPtr& broker,
|
|
177
|
+
const TradeCostPtr& costfunc,
|
|
179
178
|
const std::vector<OrderBrokerPtr>& other_brokers = {});
|
|
180
179
|
|
|
181
180
|
/**
|
|
@@ -78,7 +78,7 @@ public:
|
|
|
78
78
|
CostRecord cost; ///< 交易成本
|
|
79
79
|
price_t stoploss; ///< 止损价
|
|
80
80
|
price_t cash; ///< 现金余额
|
|
81
|
-
SystemPart from;
|
|
81
|
+
SystemPart from; ///< 辅助记录交易系统部件,区别是哪个部件发出的指示,Null<int>()表示无效
|
|
82
82
|
|
|
83
83
|
#if HKU_SUPPORT_SERIALIZATION
|
|
84
84
|
private:
|
|
@@ -141,6 +141,10 @@ HKU_API std::ostream& operator<<(std::ostream&, const TradeRecord&);
|
|
|
141
141
|
|
|
142
142
|
bool HKU_API operator==(const TradeRecord& d1, const TradeRecord& d2);
|
|
143
143
|
|
|
144
|
+
inline bool operator!=(const TradeRecord& d1, const TradeRecord& d2) {
|
|
145
|
+
return !(d1 == d2);
|
|
146
|
+
}
|
|
147
|
+
|
|
144
148
|
} /* namespace hku */
|
|
145
149
|
|
|
146
150
|
#if FMT_VERSION >= 90000
|