hikyuu 2.6.7__py3-none-win_amd64.whl → 2.6.8__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 +6 -2
- hikyuu/__init__.pyi +656 -632
- hikyuu/analysis/__init__.pyi +563 -539
- hikyuu/analysis/analysis.pyi +583 -561
- hikyuu/core.pyi +565 -541
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/concrt140.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +408 -31
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +408 -31
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +408 -31
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +408 -31
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +408 -31
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/hku_hdf5.dll +0 -0
- hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/msvcp140.dll +0 -0
- hikyuu/cpp/msvcp140_1.dll +0 -0
- hikyuu/cpp/msvcp140_2.dll +0 -0
- hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
- hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/cpp/vcruntime140.dll +0 -0
- hikyuu/cpp/vcruntime140_1.dll +0 -0
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +31 -36
- hikyuu/draw/drawplot/bokeh_draw.pyi +651 -637
- hikyuu/draw/drawplot/common.pyi +3 -4
- hikyuu/draw/drawplot/echarts_draw.pyi +598 -572
- hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -879
- hikyuu/draw/elder.pyi +19 -20
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/extend.py +19 -0
- hikyuu/extend.pyi +594 -574
- hikyuu/hub.pyi +69 -67
- hikyuu/include/hikyuu/DataType.h +2 -2
- hikyuu/include/hikyuu/KData.h +83 -25
- hikyuu/include/hikyuu/KDataImp.h +31 -46
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
- hikyuu/include/hikyuu/KQuery.h +16 -4
- hikyuu/include/hikyuu/KRecord.h +4 -1
- hikyuu/include/hikyuu/Stock.h +10 -4
- hikyuu/include/hikyuu/StockManager.h +11 -3
- hikyuu/include/hikyuu/TransRecord.h +2 -2
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
- hikyuu/include/hikyuu/doc.h +2 -2
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
- hikyuu/include/hikyuu/indicator/Indicator.h +11 -0
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
- hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
- hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
- hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
- hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
- hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
- hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
- hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
- hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
- hikyuu/include/hikyuu/plugin/backtest.h +2 -0
- hikyuu/include/hikyuu/plugin/extind.h +45 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +21 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +16 -0
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +19 -11
- hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
- hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
- hikyuu/include/hikyuu/utilities/os.h +4 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/include/hikyuu/views/arrow_common.h +38 -0
- hikyuu/include/hikyuu/views/arrow_views.h +117 -0
- hikyuu/indicator/indicator.py +4 -5
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/hkuextra.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/strategy/strategy_demo1.py +1 -1
- hikyuu/test/test_init.py +19 -19
- hikyuu/trade_manage/__init__.pyi +581 -556
- hikyuu/trade_manage/broker.pyi +19 -18
- hikyuu/trade_manage/broker_easytrader.pyi +6 -4
- hikyuu/trade_manage/broker_mail.pyi +22 -24
- hikyuu/trade_manage/trade.py +6 -0
- hikyuu/trade_manage/trade.pyi +581 -556
- hikyuu/trade_sys/__init__.py +4 -0
- hikyuu/util/check.pyi +17 -15
- hikyuu/util/mylog.pyi +8 -7
- hikyuu/util/notebook.pyi +9 -11
- hikyuu/util/singleton.pyi +8 -6
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/METADATA +3 -1
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/RECORD +140 -135
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +1 -1
- hikyuu/include/hikyuu/view/MarketView.h +0 -59
- /hikyuu/include/hikyuu/{view → views}/__init__.py +0 -0
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
|
@@ -86,6 +86,11 @@ public:
|
|
|
86
86
|
/** 子类计算接口,由setTO调用 */
|
|
87
87
|
virtual void _calculate() = 0;
|
|
88
88
|
|
|
89
|
+
protected:
|
|
90
|
+
virtual bool isPythonObject() const {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
protected:
|
|
90
95
|
string m_name;
|
|
91
96
|
TradeManagerPtr m_tm;
|
|
@@ -156,7 +161,7 @@ public: \
|
|
|
156
161
|
|
|
157
162
|
/**
|
|
158
163
|
* 客户程序都应使用该指针类型,操作止损策略实例
|
|
159
|
-
* @ingroup
|
|
164
|
+
* @ingroup Stoploss
|
|
160
165
|
*/
|
|
161
166
|
typedef shared_ptr<StoplossBase> StoplossPtr;
|
|
162
167
|
typedef shared_ptr<StoplossBase> STPtr;
|
|
@@ -265,6 +265,11 @@ public:
|
|
|
265
265
|
// 处理延迟买入请求,仅供 PF 调用
|
|
266
266
|
virtual TradeRecord pfProcessDelayBuyRequest(const Datetime& date);
|
|
267
267
|
|
|
268
|
+
protected:
|
|
269
|
+
virtual bool isPythonObject() const {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
268
273
|
private:
|
|
269
274
|
bool _environmentIsValid(const Datetime& datetime);
|
|
270
275
|
bool _conditionIsValid(const Datetime& datetime);
|
|
@@ -193,10 +193,10 @@ public:
|
|
|
193
193
|
uint64_t ticks() const noexcept;
|
|
194
194
|
|
|
195
195
|
/** 时间戳,距离1970-01-01 00:00:00的微秒数 */
|
|
196
|
-
|
|
196
|
+
uint64_t timestamp() const noexcept;
|
|
197
197
|
|
|
198
198
|
/** 时间戳,距离1970-01-01 00:00:00的微秒数, 并扣除本地 UTC 偏差时间 */
|
|
199
|
-
|
|
199
|
+
uint64_t timestampUTC() const noexcept;
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* 转化为字符串,供打印阅读,格式:
|
hikyuu/include/hikyuu/version.h
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
#define HKU_VERSION_H
|
|
13
13
|
|
|
14
14
|
// clang-format off
|
|
15
|
-
#define HKU_VERSION "2.6.
|
|
15
|
+
#define HKU_VERSION "2.6.8"
|
|
16
16
|
#define HKU_VERSION_MAJOR 2
|
|
17
17
|
#define HKU_VERSION_MINOR 6
|
|
18
|
-
#define HKU_VERSION_ALTER
|
|
19
|
-
#define HKU_VERSION_BUILD
|
|
18
|
+
#define HKU_VERSION_ALTER 8
|
|
19
|
+
#define HKU_VERSION_BUILD 202509060002
|
|
20
20
|
#define HKU_VERSION_MODE "RELEASE"
|
|
21
|
-
#define HKU_VERSION_GIT "2.6.
|
|
21
|
+
#define HKU_VERSION_GIT "2.6.8 release.5d5956d0 (RELEASE)"
|
|
22
22
|
// clang-format on
|
|
23
23
|
|
|
24
24
|
#endif /* HKU_VERSION_H */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-08-15
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <arrow/api.h>
|
|
11
|
+
#include "hikyuu/config.h"
|
|
12
|
+
#include "hikyuu/utilities/osdef.h"
|
|
13
|
+
#include "hikyuu/utilities/Log.h"
|
|
14
|
+
|
|
15
|
+
namespace hku {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @ingroup Views
|
|
19
|
+
* @{
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#if HKU_USE_LOW_PRECISION
|
|
23
|
+
#define HKU_ARROW_PRICE_FIELD arrow::float32()
|
|
24
|
+
#define HKU_ARROW_PRICE_BUILDER arrow::FloatBuilder
|
|
25
|
+
#else
|
|
26
|
+
#define HKU_ARROW_PRICE_FIELD arrow::float64()
|
|
27
|
+
#define HKU_ARROW_PRICE_BUILDER arrow::DoubleBuilder
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @brief 打印 arrow table
|
|
32
|
+
* @param table
|
|
33
|
+
* @param max_rows
|
|
34
|
+
*/
|
|
35
|
+
void printArrowTable(const std::shared_ptr<arrow::Table>& table, int max_rows = 10);
|
|
36
|
+
|
|
37
|
+
/** @} */
|
|
38
|
+
} // namespace hku
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-08-13
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "arrow_common.h"
|
|
11
|
+
#include "hikyuu/Stock.h"
|
|
12
|
+
#include "hikyuu/indicator/Indicator.h"
|
|
13
|
+
#include "hikyuu/trade_manage/PositionRecord.h"
|
|
14
|
+
#include "hikyuu/trade_manage/TradeRecord.h"
|
|
15
|
+
|
|
16
|
+
namespace hku {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @ingroup Views
|
|
20
|
+
* @{
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
//-----------------------------------------------------------
|
|
24
|
+
// arrow错误时抛出异常, 其他情况仅可能返回为空表, 而不是空指针
|
|
25
|
+
//-----------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 获取指定股票集合在指定交易日的行情数据,不包含当日停牌无数据的股票
|
|
29
|
+
* @param stks 股票列表
|
|
30
|
+
* @param date 交易日
|
|
31
|
+
* @param market 市场代码(用于获取交易日历)
|
|
32
|
+
* @return
|
|
33
|
+
*/
|
|
34
|
+
std::shared_ptr<arrow::Table> HKU_API getMarketView(const StockList& stks, const Datetime& date,
|
|
35
|
+
const string& market = "SH");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 获取指定股票集合在最后交易日的行情数据,不包含当日停牌无数据的股票。如自动接收行情数据,则为实时行情数据
|
|
39
|
+
* @param stks 股票列表
|
|
40
|
+
* @param market 市场代码(用于获取交易日历)
|
|
41
|
+
* @return
|
|
42
|
+
*/
|
|
43
|
+
std::shared_ptr<arrow::Table> HKU_API getMarketView(const StockList& stks,
|
|
44
|
+
const string& market = "SH");
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 计算指定证券列表的各指标结果,以 arrow table 形式返回
|
|
48
|
+
* @param stks 指定证券列表
|
|
49
|
+
* @param inds 指定指标列表
|
|
50
|
+
* @param query 查询条件
|
|
51
|
+
* @param market 指定行情市场(用于日期对齐)
|
|
52
|
+
* @return * arrow::Result<std::shared_ptr<arrow::Table>>
|
|
53
|
+
*/
|
|
54
|
+
std::shared_ptr<arrow::Table> HKU_API getIndicatorsView(const StockList& stks,
|
|
55
|
+
const IndicatorList& inds,
|
|
56
|
+
const KQuery& query,
|
|
57
|
+
const string& market = "SH");
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 获取指定日期的各指定证券的各指标视图
|
|
61
|
+
* @param stks 证券列表
|
|
62
|
+
* @param inds 指标列表
|
|
63
|
+
* @param date 指定日期
|
|
64
|
+
* @param cal_len 计算需要的数据长度
|
|
65
|
+
* @param ktype k线类型
|
|
66
|
+
* @param market 指定行情市场(用于日期对齐)
|
|
67
|
+
* @return arrow::Result<std::shared_ptr<arrow::Table>>
|
|
68
|
+
*/
|
|
69
|
+
std::shared_ptr<arrow::Table> HKU_API getIndicatorsView(const StockList& stks,
|
|
70
|
+
const IndicatorList& inds,
|
|
71
|
+
const Datetime& date, size_t cal_len = 100,
|
|
72
|
+
const KQuery::KType& ktype = KQuery::DAY,
|
|
73
|
+
const string& market = "SH");
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Indicator转换为 Arrow Table,包含时间序列,则带有时间列,否则无时间列
|
|
77
|
+
* @param ind Indicator
|
|
78
|
+
* @return arrow::Result<std::shared_ptr<arrow::Table>>
|
|
79
|
+
*/
|
|
80
|
+
std::shared_ptr<arrow::Table> HKU_API getIndicatorView(const Indicator& ind);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Indicator转换为 Arrow Table,仅包含值,不包含时间序列
|
|
84
|
+
* @return arrow::Result<std::shared_ptr<arrow::Table>>
|
|
85
|
+
*/
|
|
86
|
+
std::shared_ptr<arrow::Table> HKU_API getIndicatorValueView(const Indicator& ind);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* KData 转换至 arrow table
|
|
90
|
+
* @return arrow::Result<std::shared_ptr<arrow::Table>>
|
|
91
|
+
*/
|
|
92
|
+
std::shared_ptr<arrow::Table> HKU_API getKDataView(const KData& kdata);
|
|
93
|
+
|
|
94
|
+
/** KRecordList 转换至 arrow table */
|
|
95
|
+
std::shared_ptr<arrow::Table> HKU_API getKRecordListView(const KRecordList& ks);
|
|
96
|
+
|
|
97
|
+
/** TimeLineList 转换至 arrow table */
|
|
98
|
+
std::shared_ptr<arrow::Table> HKU_API getTimeLineListView(const TimeLineList& ts);
|
|
99
|
+
|
|
100
|
+
/** TransRecordList 转换至 arrow table */
|
|
101
|
+
std::shared_ptr<arrow::Table> HKU_API getTransRecordListView(const TransRecordList& ts);
|
|
102
|
+
|
|
103
|
+
/** StockWeightList 转换至 arrow table */
|
|
104
|
+
std::shared_ptr<arrow::Table> HKU_API getStockWeightListView(const StockWeightList& sws);
|
|
105
|
+
|
|
106
|
+
/** DatetimeList 转换至 arrow table */
|
|
107
|
+
std::shared_ptr<arrow::Table> HKU_API getDatetimeListView(const DatetimeList& dates);
|
|
108
|
+
|
|
109
|
+
/** TradeRecordList 转换至 arrow table */
|
|
110
|
+
std::shared_ptr<arrow::Table> HKU_API getTradeRecordListView(const TradeRecordList& trades);
|
|
111
|
+
|
|
112
|
+
/** PositionList 转换至 arrow table */
|
|
113
|
+
std::shared_ptr<arrow::Table> HKU_API
|
|
114
|
+
getPositionRecordListView(const PositionRecordList& positions);
|
|
115
|
+
|
|
116
|
+
/** @} */
|
|
117
|
+
} // namespace hku
|
hikyuu/indicator/indicator.py
CHANGED
|
@@ -29,12 +29,11 @@ from hikyuu import Datetime
|
|
|
29
29
|
import pandas as pd
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return pd.DataFrame.from_records(indicator.to_np())
|
|
32
|
+
Indicator.to_numpy = Indicator.to_np
|
|
33
|
+
Indicator.to_pandas = Indicator.to_df
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
Indicator.
|
|
35
|
+
Indicator.value_to_numpy = Indicator.value_to_np
|
|
36
|
+
Indicator.value_to_pandas = Indicator.value_to_df
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
def concat_to_df(dates, ind_list, head_stock_code=True, head_ind_name=False):
|
hikyuu/plugin/backtest.dll
CHANGED
|
Binary file
|
|
Binary file
|
hikyuu/plugin/dataserver.dll
CHANGED
|
Binary file
|
hikyuu/plugin/device.dll
CHANGED
|
Binary file
|
hikyuu/plugin/extind.dll
CHANGED
|
Binary file
|
hikyuu/plugin/hkuextra.dll
CHANGED
|
Binary file
|
hikyuu/plugin/import2hdf5.dll
CHANGED
|
Binary file
|
hikyuu/plugin/tmreport.dll
CHANGED
|
Binary file
|
|
@@ -11,7 +11,7 @@ from hikyuu import *
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def on_change(stg: Strategy, stk: Stock, spot: SpotRecord):
|
|
14
|
-
print("[on_change]:", stk.market_code, stk.name, spot.close, spot.
|
|
14
|
+
print("[on_change]:", stk.market_code, stk.name, spot.close, spot.bid[0], spot.ask[0])
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def on_spot(stg: Strategy, rev_time: Datetime):
|
hikyuu/test/test_init.py
CHANGED
|
@@ -2,44 +2,44 @@
|
|
|
2
2
|
# -*- coding: utf8 -*-
|
|
3
3
|
# cp936
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# ===============================================================================
|
|
6
6
|
# 作者:fasiondog
|
|
7
7
|
# 历史:1)20130128, Added by fasiondog
|
|
8
|
-
|
|
8
|
+
# ===============================================================================
|
|
9
9
|
from hikyuu import *
|
|
10
10
|
from configparser import ConfigParser
|
|
11
11
|
from functools import lru_cache
|
|
12
12
|
|
|
13
13
|
import os
|
|
14
|
-
#curdir = os.path.dirname(os.path.realpath(__file__))
|
|
15
|
-
#head, tail = os.path.split(curdir)
|
|
16
|
-
#head, tail = os.path.split(head)
|
|
17
|
-
#head, tail = os.path.split(head)
|
|
14
|
+
# curdir = os.path.dirname(os.path.realpath(__file__))
|
|
15
|
+
# head, tail = os.path.split(curdir)
|
|
16
|
+
# head, tail = os.path.split(head)
|
|
17
|
+
# head, tail = os.path.split(head)
|
|
18
18
|
|
|
19
19
|
import sys
|
|
20
20
|
if sys.platform == 'win32':
|
|
21
|
-
#config_file = os.path.join(head, "test_data/hikyuu_win.ini")
|
|
21
|
+
# config_file = os.path.join(head, "test_data/hikyuu_win.ini")
|
|
22
22
|
config_file = "test_data/hikyuu_win.ini"
|
|
23
23
|
else:
|
|
24
|
-
#config_file = os.path.join(head, "test_data/hikyuu_linux.ini")
|
|
24
|
+
# config_file = os.path.join(head, "test_data/hikyuu_linux.ini")
|
|
25
25
|
config_file = "test_data/hikyuu_linux.ini"
|
|
26
|
-
#print(config_file)
|
|
26
|
+
# print(config_file)
|
|
27
27
|
|
|
28
|
-
#tmp_dir = os.path.join(head, "test/data/tmp")
|
|
28
|
+
# tmp_dir = os.path.join(head, "test/data/tmp")
|
|
29
29
|
tmp_dir = "test_data/tmp"
|
|
30
30
|
if not os.path.lexists(tmp_dir):
|
|
31
31
|
os.mkdir(tmp_dir)
|
|
32
32
|
|
|
33
|
-
#starttime = time.time()
|
|
34
|
-
#print "Loading Day Data ..."
|
|
33
|
+
# starttime = time.time()
|
|
34
|
+
# print "Loading Day Data ..."
|
|
35
35
|
hikyuu_init(config_file)
|
|
36
36
|
sm = StockManager.instance()
|
|
37
|
-
#endtime = time.time()
|
|
38
|
-
#print "%.2fs" % (endtime-starttime)
|
|
37
|
+
# endtime = time.time()
|
|
38
|
+
# print "%.2fs" % (endtime-starttime)
|
|
39
39
|
|
|
40
40
|
# 仅在模块加载时读取一次配置
|
|
41
41
|
_config = ConfigParser()
|
|
42
|
-
_config.read(config_file)
|
|
42
|
+
_config.read(config_file, encoding='utf-8')
|
|
43
43
|
_tdx_dir = _config.get('tdx', 'dir', fallback='/mnt/tdx')
|
|
44
44
|
|
|
45
45
|
|
|
@@ -47,17 +47,17 @@ _tdx_dir = _config.get('tdx', 'dir', fallback='/mnt/tdx')
|
|
|
47
47
|
def get_real_tdx_filepath(code, market='sh'):
|
|
48
48
|
"""
|
|
49
49
|
获取真实的通达信.day文件路径。
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
该函数按以下顺序确定文件路径:
|
|
52
52
|
1. 检查环境变量 `HKU_real_tdx_file_path` 是否被设置。
|
|
53
53
|
2. 如果未设置, 则检查配置文件中 "tdx"->"dir" 指定的路径。
|
|
54
54
|
3. 如果未配置, 则使用 /mnt/tdx/vipdoc/。
|
|
55
55
|
4. 如果上述路径不存在, 则检查 test_data/vipdoc/ 是否存在, 如果存在, 则使用该路径。
|
|
56
56
|
5. 如果上述路径都不存在, 则自动回退到在项目根目录下的 `test_data` 文件夹中寻找同名文件作为备用。
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
这使得测试既能适应有权访问生产数据环境的开发者, 也能让其他贡献者使用
|
|
59
59
|
项目内提供的样本数据来运行测试, 避免了因路径问题导致的测试挂起或失败。
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
:param str code: 股票代码 (如 '600000', '000001')
|
|
62
62
|
:param str market: 市场简称 (如 'sh', 'sz')
|
|
63
63
|
:return: 最终确定的文件路径 (可能不存在, 由调用方处理)
|
|
@@ -92,4 +92,4 @@ def get_real_tdx_filepath(code, market='sh'):
|
|
|
92
92
|
test_data_dir = os.path.join(project_root, 'test_data')
|
|
93
93
|
fallback_path = os.path.join(test_data_dir, filename)
|
|
94
94
|
print(f"get_real_tdx_filepath return: {fallback_path}")
|
|
95
|
-
return fallback_path
|
|
95
|
+
return fallback_path
|