hikyuu 2.6.6__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 (175) hide show
  1. hikyuu/__init__.py +16 -2
  2. hikyuu/__init__.pyi +658 -627
  3. hikyuu/analysis/__init__.pyi +563 -519
  4. hikyuu/analysis/analysis.pyi +583 -541
  5. hikyuu/core.pyi +565 -521
  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 +1424 -865
  10. hikyuu/cpp/core311.pyd +0 -0
  11. hikyuu/cpp/core311.pyi +1424 -865
  12. hikyuu/cpp/core312.pyd +0 -0
  13. hikyuu/cpp/core312.pyi +1424 -865
  14. hikyuu/cpp/core313.pyd +0 -0
  15. hikyuu/cpp/core313.pyi +1424 -863
  16. hikyuu/cpp/core39.pyd +0 -0
  17. hikyuu/cpp/core39.pyi +1424 -865
  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/__init__.py +0 -0
  25. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  26. hikyuu/cpp/msvcp140.dll +0 -0
  27. hikyuu/cpp/msvcp140_1.dll +0 -0
  28. hikyuu/cpp/msvcp140_2.dll +0 -0
  29. hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
  30. hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
  31. hikyuu/cpp/sqlite3.dll +0 -0
  32. hikyuu/cpp/vcruntime140.dll +0 -0
  33. hikyuu/cpp/vcruntime140_1.dll +0 -0
  34. hikyuu/data/common_clickhouse.py +0 -47
  35. hikyuu/data/tdx_to_h5.py +1 -1
  36. hikyuu/draw/drawplot/__init__.pyi +32 -37
  37. hikyuu/draw/drawplot/bokeh_draw.pyi +651 -632
  38. hikyuu/draw/drawplot/common.pyi +3 -4
  39. hikyuu/draw/drawplot/echarts_draw.py +9 -8
  40. hikyuu/draw/drawplot/echarts_draw.pyi +598 -567
  41. hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
  42. hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -874
  43. hikyuu/draw/elder.pyi +19 -20
  44. hikyuu/draw/kaufman.py +1 -1
  45. hikyuu/draw/kaufman.pyi +18 -18
  46. hikyuu/draw/volume.pyi +10 -10
  47. hikyuu/examples/notebook/000-Index.ipynb +1 -1
  48. hikyuu/examples/notebook/001-overview.ipynb +78 -63
  49. hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
  50. hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
  51. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
  52. hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
  53. hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
  54. hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
  55. hikyuu/examples/notebook/009-RealData.ipynb +3 -3
  56. hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
  57. hikyuu/extend.py +32 -98
  58. hikyuu/extend.pyi +597 -593
  59. hikyuu/gui/HikyuuTDX.py +2 -4
  60. hikyuu/gui/data/MainWindow.py +185 -174
  61. hikyuu/hub.pyi +69 -67
  62. hikyuu/include/hikyuu/DataType.h +3 -12
  63. hikyuu/include/hikyuu/KData.h +83 -25
  64. hikyuu/include/hikyuu/KDataImp.h +31 -46
  65. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
  66. hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
  67. hikyuu/include/hikyuu/KQuery.h +38 -32
  68. hikyuu/include/hikyuu/KRecord.h +4 -1
  69. hikyuu/include/hikyuu/MarketInfo.h +1 -1
  70. hikyuu/include/hikyuu/Stock.h +24 -6
  71. hikyuu/include/hikyuu/StockManager.h +15 -6
  72. hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
  73. hikyuu/include/hikyuu/TransRecord.h +2 -8
  74. hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
  75. hikyuu/include/hikyuu/doc.h +4 -0
  76. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
  77. hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
  78. hikyuu/include/hikyuu/indicator/Indicator.h +48 -0
  79. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
  80. hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
  81. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  82. hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
  83. hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
  84. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
  85. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
  86. hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
  87. hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
  88. hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
  89. hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
  90. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
  91. hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
  92. hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
  93. hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
  94. hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
  95. hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
  96. hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
  97. hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
  98. hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
  99. hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
  100. hikyuu/include/hikyuu/lang.h +27 -0
  101. hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +6 -1
  102. hikyuu/include/hikyuu/plugin/backtest.h +2 -0
  103. hikyuu/include/hikyuu/plugin/extind.h +45 -0
  104. hikyuu/include/hikyuu/plugin/hkuextra.h +77 -0
  105. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +54 -0
  106. hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +10 -1
  107. hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
  108. hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
  109. hikyuu/include/hikyuu/python/pybind_utils.h +28 -11
  110. hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
  111. hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
  112. hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
  113. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  114. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
  115. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
  116. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
  117. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
  118. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
  120. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
  121. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
  122. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
  123. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
  124. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
  125. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
  126. hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
  127. hikyuu/include/hikyuu/utilities/config.h +0 -2
  128. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
  129. hikyuu/include/hikyuu/utilities/os.h +7 -0
  130. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
  131. hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
  132. hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
  133. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
  134. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
  135. hikyuu/include/hikyuu/version.h +4 -4
  136. hikyuu/include/hikyuu/views/arrow_common.h +38 -0
  137. hikyuu/include/hikyuu/views/arrow_views.h +117 -0
  138. hikyuu/indicator/__init__.py +0 -1
  139. hikyuu/indicator/indicator.py +17 -57
  140. hikyuu/plugin/backtest.dll +0 -0
  141. hikyuu/plugin/clickhousedriver.dll +0 -0
  142. hikyuu/plugin/dataserver.dll +0 -0
  143. hikyuu/plugin/device.dll +0 -0
  144. hikyuu/plugin/extind.dll +0 -0
  145. hikyuu/plugin/hkuextra.dll +0 -0
  146. hikyuu/plugin/import2hdf5.dll +0 -0
  147. hikyuu/plugin/tmreport.dll +0 -0
  148. hikyuu/strategy/strategy_demo1.py +1 -1
  149. hikyuu/test/test_init.py +73 -14
  150. hikyuu/test/test_real_tdx_import.py +336 -0
  151. hikyuu/test/test_tdx_import.py +315 -0
  152. hikyuu/test/test_tdx_real_data_import.py +281 -0
  153. hikyuu/trade_manage/__init__.pyi +583 -553
  154. hikyuu/trade_manage/broker.pyi +19 -18
  155. hikyuu/trade_manage/broker_easytrader.pyi +6 -4
  156. hikyuu/trade_manage/broker_mail.pyi +22 -24
  157. hikyuu/trade_manage/trade.py +10 -65
  158. hikyuu/trade_manage/trade.pyi +583 -565
  159. hikyuu/trade_sys/__init__.py +15 -0
  160. hikyuu/util/__init__.pyi +0 -1
  161. hikyuu/util/check.pyi +17 -15
  162. hikyuu/util/mylog.pyi +8 -7
  163. hikyuu/util/notebook.pyi +9 -11
  164. hikyuu/util/singleton.pyi +8 -6
  165. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/METADATA +8 -4
  166. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/RECORD +172 -160
  167. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +2 -1
  168. hikyuu/cpp/i18n/zh_CN.mo +0 -0
  169. hikyuu/include/hikyuu/utilities/mo/mo.h +0 -64
  170. hikyuu/indicator/talib_wrap.py +0 -1273
  171. /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
  172. /hikyuu/include/hikyuu/{utilities/mo → views}/__init__.py +0 -0
  173. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
  174. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
  175. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.6.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 6
19
- #define HKU_VERSION_BUILD 202507291558
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.6 master.c4a12bf4 (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
@@ -26,4 +26,3 @@
26
26
 
27
27
  from .indicator import *
28
28
  from .pyind import *
29
- from .talib_wrap import *
@@ -29,53 +29,11 @@ from hikyuu import Datetime
29
29
  import pandas as pd
30
30
 
31
31
 
32
- def indicator_iter(indicator):
33
- for i in range(len(indicator)):
34
- yield indicator[i]
32
+ Indicator.to_numpy = Indicator.to_np
33
+ Indicator.to_pandas = Indicator.to_df
35
34
 
36
-
37
- def indicator_getitem(data, i):
38
- """
39
- :param i: int | Datetime | slice | str 类型
40
- """
41
- if isinstance(i, int):
42
- length = len(data)
43
- index = length + i if i < 0 else i
44
- if index < 0 or index >= length:
45
- raise IndexError("index out of range: %d" % i)
46
- return data.get(index)
47
-
48
- elif isinstance(i, slice):
49
- return [data.get(x) for x in range(*i.indices(len(data)))]
50
-
51
- elif isinstance(i, Datetime):
52
- return data.get_by_datetime(i)
53
-
54
- elif isinstance(i, str):
55
- return data.get_by_datetime(Datetime(i))
56
-
57
- else:
58
- raise IndexError("Error index type")
59
-
60
-
61
- Indicator.__getitem__ = indicator_getitem
62
- Indicator.__iter__ = indicator_iter
63
-
64
-
65
- def indicator_to_df(indicator):
66
- """转化为pandas.DataFrame"""
67
- if indicator.get_result_num() == 1:
68
- return pd.DataFrame(indicator.to_np(), columns=[indicator.name])
69
- data = {}
70
- name = indicator.name
71
- columns = []
72
- for i in range(indicator.get_result_num()):
73
- data[name + str(i)] = indicator.get_result(i)
74
- columns.append(name + str(i + 1))
75
- return pd.DataFrame(data, columns=columns)
76
-
77
-
78
- Indicator.to_df = indicator_to_df
35
+ Indicator.value_to_numpy = Indicator.value_to_np
36
+ Indicator.value_to_pandas = Indicator.value_to_df
79
37
 
80
38
 
81
39
  def concat_to_df(dates, ind_list, head_stock_code=True, head_ind_name=False):
@@ -107,17 +65,19 @@ def concat_to_df(dates, ind_list, head_stock_code=True, head_ind_name=False):
107
65
  198 2024-03-06 00:00:00 10.070455 9.776818
108
66
  199 2024-03-07 00:00:00 10.101364 9.738182
109
67
  """
110
- df = pd.DataFrame(dates, columns=['date'])
111
- for ind in ind_list:
112
- x = ALIGN(ind, dates)
68
+ df = dates.to_df('ms')
69
+ if not ind_list:
70
+ return df
71
+ for i in range(len(ind_list)):
72
+ ind = ind_list[i]
113
73
  if head_ind_name and head_stock_code:
114
- x.name = f"{ind.name}/{ind.get_context().get_stock().market_code}"
74
+ name = f"{ind.name}/{ind.get_context().get_stock().market_code}"
115
75
  elif head_ind_name:
116
- x.name = ind.name
76
+ name = f'{ind.name}{i}'
117
77
  else:
118
- x.name = ind.get_context().get_stock().market_code
119
- df = pd.concat([df, x.to_df()], axis=1)
120
- df.set_index('date')
78
+ name = ind.get_context().get_stock().market_code
79
+ df = pd.merge(df, ind.to_df()[['datetime', 'value1']].rename(
80
+ columns={'value1': name}), on='datetime', how='left')
121
81
  return df
122
82
 
123
83
 
@@ -137,10 +97,10 @@ def df_to_ind(df, col_name, col_date=None):
137
97
  :return: Indicator
138
98
  """
139
99
  if col_date is not None:
140
- dates = df[col_date].to_list()
100
+ dates = df[col_date]
141
101
  dates = DatetimeList([Datetime(x) for x in dates])
142
- return PRICELIST(df[col_name].to_list(), align_dates=dates)
143
- return PRICELIST(df[col_name].to_list())
102
+ return PRICELIST(df[col_name], align_dates=dates)
103
+ return PRICELIST(df[col_name])
144
104
 
145
105
 
146
106
  # 避免 python 中公式原型必须加括号
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,35 +2,94 @@
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
+ from configparser import ConfigParser
11
+ from functools import lru_cache
10
12
 
11
13
  import os
12
- #curdir = os.path.dirname(os.path.realpath(__file__))
13
- #head, tail = os.path.split(curdir)
14
- #head, tail = os.path.split(head)
15
- #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)
16
18
 
17
19
  import sys
18
20
  if sys.platform == 'win32':
19
- #config_file = os.path.join(head, "test_data/hikyuu_win.ini")
21
+ # config_file = os.path.join(head, "test_data/hikyuu_win.ini")
20
22
  config_file = "test_data/hikyuu_win.ini"
21
23
  else:
22
- #config_file = os.path.join(head, "test_data/hikyuu_linux.ini")
24
+ # config_file = os.path.join(head, "test_data/hikyuu_linux.ini")
23
25
  config_file = "test_data/hikyuu_linux.ini"
24
- #print(config_file)
26
+ # print(config_file)
25
27
 
26
- #tmp_dir = os.path.join(head, "test/data/tmp")
28
+ # tmp_dir = os.path.join(head, "test/data/tmp")
27
29
  tmp_dir = "test_data/tmp"
28
30
  if not os.path.lexists(tmp_dir):
29
31
  os.mkdir(tmp_dir)
30
32
 
31
- #starttime = time.time()
32
- #print "Loading Day Data ..."
33
+ # starttime = time.time()
34
+ # print "Loading Day Data ..."
33
35
  hikyuu_init(config_file)
34
36
  sm = StockManager.instance()
35
- #endtime = time.time()
36
- #print "%.2fs" % (endtime-starttime)
37
+ # endtime = time.time()
38
+ # print "%.2fs" % (endtime-starttime)
39
+
40
+ # 仅在模块加载时读取一次配置
41
+ _config = ConfigParser()
42
+ _config.read(config_file, encoding='utf-8')
43
+ _tdx_dir = _config.get('tdx', 'dir', fallback='/mnt/tdx')
44
+
45
+
46
+ @lru_cache(maxsize=None)
47
+ def get_real_tdx_filepath(code, market='sh'):
48
+ """
49
+ 获取真实的通达信.day文件路径。
50
+
51
+ 该函数按以下顺序确定文件路径:
52
+ 1. 检查环境变量 `HKU_real_tdx_file_path` 是否被设置。
53
+ 2. 如果未设置, 则检查配置文件中 "tdx"->"dir" 指定的路径。
54
+ 3. 如果未配置, 则使用 /mnt/tdx/vipdoc/。
55
+ 4. 如果上述路径不存在, 则检查 test_data/vipdoc/ 是否存在, 如果存在, 则使用该路径。
56
+ 5. 如果上述路径都不存在, 则自动回退到在项目根目录下的 `test_data` 文件夹中寻找同名文件作为备用。
57
+
58
+ 这使得测试既能适应有权访问生产数据环境的开发者, 也能让其他贡献者使用
59
+ 项目内提供的样本数据来运行测试, 避免了因路径问题导致的测试挂起或失败。
60
+
61
+ :param str code: 股票代码 (如 '600000', '000001')
62
+ :param str market: 市场简称 (如 'sh', 'sz')
63
+ :return: 最终确定的文件路径 (可能不存在, 由调用方处理)
64
+ """
65
+ # 检查环境变量
66
+ env_path = os.environ.get('HKU_real_tdx_file_path')
67
+ if env_path and os.path.exists(env_path):
68
+ print(f"get_real_tdx_filepath return: {env_path}")
69
+ return env_path
70
+
71
+ market_subdir = f"{market.lower()}/lday"
72
+ filename = f"{market.lower()}{code}.day"
73
+
74
+ # 检查配置文件指定的路径
75
+ base_path = os.path.join(_tdx_dir, 'vipdoc')
76
+ if os.path.exists(base_path):
77
+ primary_path = os.path.join(base_path, market_subdir, filename)
78
+ if os.path.exists(primary_path):
79
+ print(f"get_real_tdx_filepath return: {primary_path}")
80
+ return primary_path
81
+
82
+ # 检查 test_data/vipdoc/
83
+ project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
84
+ test_data_vipdoc_path = os.path.join(project_root, 'test_data', 'vipdoc')
85
+ if os.path.exists(test_data_vipdoc_path):
86
+ primary_path = os.path.join(test_data_vipdoc_path, market_subdir, filename)
87
+ if os.path.exists(primary_path):
88
+ print(f"get_real_tdx_filepath return: {primary_path}")
89
+ return primary_path
90
+
91
+ # 如果主路径文件不存在, 则尝试从 test_data 目录寻找同名文件作为备用
92
+ test_data_dir = os.path.join(project_root, 'test_data')
93
+ fallback_path = os.path.join(test_data_dir, filename)
94
+ print(f"get_real_tdx_filepath return: {fallback_path}")
95
+ return fallback_path