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.
Files changed (141) hide show
  1. hikyuu/__init__.py +6 -2
  2. hikyuu/__init__.pyi +656 -632
  3. hikyuu/analysis/__init__.pyi +563 -539
  4. hikyuu/analysis/analysis.pyi +583 -561
  5. hikyuu/core.pyi +565 -541
  6. hikyuu/cpp/__init__.pyi +2 -2
  7. hikyuu/cpp/concrt140.dll +0 -0
  8. hikyuu/cpp/core310.pyd +0 -0
  9. hikyuu/cpp/core310.pyi +408 -31
  10. hikyuu/cpp/core311.pyd +0 -0
  11. hikyuu/cpp/core311.pyi +408 -31
  12. hikyuu/cpp/core312.pyd +0 -0
  13. hikyuu/cpp/core312.pyi +408 -31
  14. hikyuu/cpp/core313.pyd +0 -0
  15. hikyuu/cpp/core313.pyi +408 -31
  16. hikyuu/cpp/core39.pyd +0 -0
  17. hikyuu/cpp/core39.pyi +408 -31
  18. hikyuu/cpp/hikyuu.dll +0 -0
  19. hikyuu/cpp/hikyuu.lib +0 -0
  20. hikyuu/cpp/hku_hdf5.dll +0 -0
  21. hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
  22. hikyuu/cpp/hku_hdf5_hl.dll +0 -0
  23. hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
  24. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  25. hikyuu/cpp/msvcp140.dll +0 -0
  26. hikyuu/cpp/msvcp140_1.dll +0 -0
  27. hikyuu/cpp/msvcp140_2.dll +0 -0
  28. hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
  29. hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
  30. hikyuu/cpp/sqlite3.dll +0 -0
  31. hikyuu/cpp/vcruntime140.dll +0 -0
  32. hikyuu/cpp/vcruntime140_1.dll +0 -0
  33. hikyuu/draw/__init__.pyi +1 -1
  34. hikyuu/draw/drawplot/__init__.pyi +31 -36
  35. hikyuu/draw/drawplot/bokeh_draw.pyi +651 -637
  36. hikyuu/draw/drawplot/common.pyi +3 -4
  37. hikyuu/draw/drawplot/echarts_draw.pyi +598 -572
  38. hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -879
  39. hikyuu/draw/elder.pyi +19 -20
  40. hikyuu/draw/kaufman.pyi +18 -18
  41. hikyuu/draw/volume.pyi +10 -10
  42. hikyuu/extend.py +19 -0
  43. hikyuu/extend.pyi +594 -574
  44. hikyuu/hub.pyi +69 -67
  45. hikyuu/include/hikyuu/DataType.h +2 -2
  46. hikyuu/include/hikyuu/KData.h +83 -25
  47. hikyuu/include/hikyuu/KDataImp.h +31 -46
  48. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
  49. hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
  50. hikyuu/include/hikyuu/KQuery.h +16 -4
  51. hikyuu/include/hikyuu/KRecord.h +4 -1
  52. hikyuu/include/hikyuu/Stock.h +10 -4
  53. hikyuu/include/hikyuu/StockManager.h +11 -3
  54. hikyuu/include/hikyuu/TransRecord.h +2 -2
  55. hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
  56. hikyuu/include/hikyuu/doc.h +2 -2
  57. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
  58. hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
  59. hikyuu/include/hikyuu/indicator/Indicator.h +11 -0
  60. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
  61. hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
  62. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  63. hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
  64. hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
  65. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
  66. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
  67. hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
  68. hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
  69. hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
  70. hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
  71. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
  72. hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
  73. hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
  74. hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
  75. hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
  76. hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
  77. hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
  78. hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
  79. hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
  80. hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
  81. hikyuu/include/hikyuu/plugin/backtest.h +2 -0
  82. hikyuu/include/hikyuu/plugin/extind.h +45 -0
  83. hikyuu/include/hikyuu/plugin/hkuextra.h +21 -0
  84. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +16 -0
  85. hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
  86. hikyuu/include/hikyuu/python/pybind_utils.h +19 -11
  87. hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
  88. hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
  89. hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
  90. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  91. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
  92. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
  93. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
  94. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
  95. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
  96. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
  97. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
  98. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
  99. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
  100. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
  101. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
  102. hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
  103. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
  104. hikyuu/include/hikyuu/utilities/os.h +4 -0
  105. hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
  106. hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
  107. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
  108. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
  109. hikyuu/include/hikyuu/version.h +4 -4
  110. hikyuu/include/hikyuu/views/arrow_common.h +38 -0
  111. hikyuu/include/hikyuu/views/arrow_views.h +117 -0
  112. hikyuu/indicator/indicator.py +4 -5
  113. hikyuu/plugin/backtest.dll +0 -0
  114. hikyuu/plugin/clickhousedriver.dll +0 -0
  115. hikyuu/plugin/dataserver.dll +0 -0
  116. hikyuu/plugin/device.dll +0 -0
  117. hikyuu/plugin/extind.dll +0 -0
  118. hikyuu/plugin/hkuextra.dll +0 -0
  119. hikyuu/plugin/import2hdf5.dll +0 -0
  120. hikyuu/plugin/tmreport.dll +0 -0
  121. hikyuu/strategy/strategy_demo1.py +1 -1
  122. hikyuu/test/test_init.py +19 -19
  123. hikyuu/trade_manage/__init__.pyi +581 -556
  124. hikyuu/trade_manage/broker.pyi +19 -18
  125. hikyuu/trade_manage/broker_easytrader.pyi +6 -4
  126. hikyuu/trade_manage/broker_mail.pyi +22 -24
  127. hikyuu/trade_manage/trade.py +6 -0
  128. hikyuu/trade_manage/trade.pyi +581 -556
  129. hikyuu/trade_sys/__init__.py +4 -0
  130. hikyuu/util/check.pyi +17 -15
  131. hikyuu/util/mylog.pyi +8 -7
  132. hikyuu/util/notebook.pyi +9 -11
  133. hikyuu/util/singleton.pyi +8 -6
  134. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/METADATA +3 -1
  135. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/RECORD +140 -135
  136. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +1 -1
  137. hikyuu/include/hikyuu/view/MarketView.h +0 -59
  138. /hikyuu/include/hikyuu/{view → views}/__init__.py +0 -0
  139. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
  140. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
  141. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
@@ -71,6 +71,11 @@ public:
71
71
  /** 子类计算接口,由setTO调用 */
72
72
  virtual void _calculate() = 0;
73
73
 
74
+ protected:
75
+ virtual bool isPythonObject() const {
76
+ return false;
77
+ }
78
+
74
79
  protected:
75
80
  string m_name;
76
81
  KData m_kdata;
@@ -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 StopLoss
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
- int64_t timestamp() const noexcept;
196
+ uint64_t timestamp() const noexcept;
197
197
 
198
198
  /** 时间戳,距离1970-01-01 00:00:00的微秒数, 并扣除本地 UTC 偏差时间 */
199
- int64_t timestampUTC() const noexcept;
199
+ uint64_t timestampUTC() const noexcept;
200
200
 
201
201
  /**
202
202
  * 转化为字符串,供打印阅读,格式:
@@ -108,4 +108,8 @@ std::string HKU_UTILS_API getCpuArch();
108
108
  /** 获取当前系统语言名称(全部小写返回) */
109
109
  std::string HKU_UTILS_API getSystemLanguage();
110
110
 
111
+ uint64_t HKU_UTILS_API getMemoryMaxSize();
112
+
113
+ uint64_t HKU_UTILS_API getMemoryIdleSize();
114
+
111
115
  } // namespace hku
@@ -30,7 +30,7 @@ namespace hku {
30
30
 
31
31
  /**
32
32
  * @brief 无集中队列多队列偷取任务池
33
- * @ingroup GlobalMQStealThreadPool
33
+ * @ingroup ThreadPool
34
34
  */
35
35
  #ifdef _MSC_VER
36
36
  class GlobalMQStealThreadPool {
@@ -32,7 +32,7 @@ namespace hku {
32
32
  /**
33
33
  * @brief 全局分布式线程池,只适合程序运行期内一直保持运行的情况
34
34
  * @details
35
- * @ingroup GlobalMQThreadPool
35
+ * @ingroup ThreadPool
36
36
  */
37
37
  #ifdef _MSC_VER
38
38
  class GlobalMQThreadPool {
@@ -35,7 +35,7 @@ namespace hku {
35
35
  * @brief 全局集中式任务队列线程池,任务之间彼此独立不能互相等待
36
36
  * @note 任务运行之间如存在先后顺序,只适合程序运行期内一直保持运行的情况
37
37
  * @details
38
- * @ingroup GlobalThreadPool
38
+ * @ingroup ThreadPool
39
39
  */
40
40
  #ifdef _MSC_VER
41
41
  class GlobalThreadPool {
@@ -33,7 +33,7 @@ namespace hku {
33
33
  * @brief 普通多任务队列线程池,任务之间彼此独立不能互相等待
34
34
  * @note 任务运行之间如存在先后顺序,请使用 StealThreadPool。
35
35
  * @details
36
- * @ingroup MQThreadPool
36
+ * @ingroup ThreadPool
37
37
  */
38
38
  #ifdef _MSC_VER
39
39
  class MQThreadPool {
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.6.7"
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 7
19
- #define HKU_VERSION_BUILD 202508150017
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.7 release.95439630 (RELEASE)"
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
@@ -29,12 +29,11 @@ from hikyuu import Datetime
29
29
  import pandas as pd
30
30
 
31
31
 
32
- def indicator_to_df(indicator):
33
- """转化为pandas.DataFrame"""
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.to_df = indicator_to_df
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):
Binary file
Binary file
Binary file
hikyuu/plugin/device.dll CHANGED
Binary file
hikyuu/plugin/extind.dll CHANGED
Binary file
Binary file
Binary file
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.bid1, spot.ask1)
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