hikyuu 2.1.5__cp311-none-win_amd64.whl → 2.2.1__cp311-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 (93) hide show
  1. hikyuu/analysis/analysis.py +20 -0
  2. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  3. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  4. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  5. hikyuu/cpp/core311.pyd +0 -0
  6. hikyuu/cpp/hikyuu.dll +0 -0
  7. hikyuu/data/common.py +3 -3
  8. hikyuu/data/mysql_upgrade/0023.sql +4 -0
  9. hikyuu/data/pytdx_weight_to_mysql.py +14 -15
  10. hikyuu/data/pytdx_weight_to_sqlite.py +14 -15
  11. hikyuu/data/sqlite_upgrade/0024.sql +22 -0
  12. hikyuu/gui/HikyuuTDX.py +3 -2
  13. hikyuu/gui/data/ImportHistoryFinanceTask.py +7 -0
  14. hikyuu/gui/data/ImportWeightToSqliteTask.py +2 -2
  15. hikyuu/gui/data/MainWindow.py +520 -424
  16. hikyuu/include/hikyuu/StockWeight.h +16 -10
  17. hikyuu/include/hikyuu/analysis/analysis_sys.h +42 -12
  18. hikyuu/include/hikyuu/data_driver/base_info/table/StockWeightTable.h +6 -4
  19. hikyuu/include/hikyuu/global/agent/SpotAgent.h +5 -6
  20. hikyuu/include/hikyuu/indicator/crt/IC.h +7 -6
  21. hikyuu/include/hikyuu/indicator/crt/ICIR.h +7 -4
  22. hikyuu/include/hikyuu/indicator/imp/IIc.h +1 -1
  23. hikyuu/include/hikyuu/serialization/StockWeight_serialization.h +5 -2
  24. hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +27 -25
  25. hikyuu/include/hikyuu/strategy/Strategy.h +1 -2
  26. hikyuu/include/hikyuu/trade_manage/Performance.h +3 -0
  27. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +16 -6
  28. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
  29. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +0 -3
  30. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +2 -2
  31. hikyuu/include/hikyuu/trade_sys/condition/build_in.h +1 -0
  32. hikyuu/include/hikyuu/trade_sys/condition/crt/CN_Manual.h +20 -0
  33. hikyuu/include/hikyuu/trade_sys/condition/imp/ManualCondition.h +23 -0
  34. hikyuu/include/hikyuu/trade_sys/condition/imp/{AddCondition.h → logic/AddCondition.h} +1 -1
  35. hikyuu/include/hikyuu/trade_sys/condition/imp/{AndCondition.h → logic/AndCondition.h} +1 -1
  36. hikyuu/include/hikyuu/trade_sys/condition/imp/{DivCondition.h → logic/DivCondition.h} +1 -1
  37. hikyuu/include/hikyuu/trade_sys/condition/imp/{MultiCondition.h → logic/MultiCondition.h} +1 -1
  38. hikyuu/include/hikyuu/trade_sys/condition/imp/{OrCondition.h → logic/OrCondition.h} +1 -1
  39. hikyuu/include/hikyuu/trade_sys/condition/imp/logic/__init__.py +1 -0
  40. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +6 -6
  41. hikyuu/include/hikyuu/trade_sys/environment/build_in.h +1 -0
  42. hikyuu/include/hikyuu/trade_sys/environment/crt/EV_Manual.h +20 -0
  43. hikyuu/include/hikyuu/trade_sys/environment/imp/ManualEnvironment.h +23 -0
  44. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +1 -1
  45. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +3 -1
  46. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +3 -2
  47. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +4 -2
  48. hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
  49. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
  50. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
  51. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +2 -2
  52. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +3 -1
  53. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +2 -1
  54. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +2 -1
  55. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Optimal.h +26 -0
  56. hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSelector.h → logic/OperatorSelector.h} +1 -1
  57. hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorValueSelector.h → logic/OperatorValueSelector.h} +1 -1
  58. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/__init__.py +1 -0
  59. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/MaxFundsOptimalSelector.h +27 -0
  60. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +86 -0
  61. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +42 -0
  62. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/__init__.py +1 -0
  63. hikyuu/include/hikyuu/trade_sys/signal/build_in.h +1 -0
  64. hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Manual.h +20 -0
  65. hikyuu/include/hikyuu/trade_sys/signal/imp/ManualSignal.h +23 -0
  66. hikyuu/include/hikyuu/trade_sys/system/System.h +30 -13
  67. hikyuu/include/hikyuu/trade_sys/system/TradeRequest.h +19 -11
  68. hikyuu/include/hikyuu/trade_sys/system/build_in.h +1 -0
  69. hikyuu/include/hikyuu/trade_sys/system/crt/SYS_WalkForward.h +27 -0
  70. hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +51 -0
  71. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +70 -0
  72. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +465 -0
  73. hikyuu/include/hikyuu/utilities/base64.h +25 -31
  74. hikyuu/include/hikyuu/version.h +5 -5
  75. hikyuu/strategy/strategy_demo1.py +2 -1
  76. hikyuu/trade_sys/trade_sys.py +28 -9
  77. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/METADATA +1 -1
  78. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/RECORD +93 -74
  79. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/top_level.txt +3 -0
  80. /hikyuu/include/hikyuu/trade_sys/selector/crt/{SE_Operator.h → SE_Logic.h} +0 -0
  81. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorAddSelector.h → logic/OperatorAddSelector.h} +0 -0
  82. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorAddValueSelector.h → logic/OperatorAddValueSelector.h} +0 -0
  83. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorDivSelector.h → logic/OperatorDivSelector.h} +0 -0
  84. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorDivValueSelector.h → logic/OperatorDivValueSelector.h} +0 -0
  85. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorInvertDivValueSelector.h → logic/OperatorInvertDivValueSelector.h} +0 -0
  86. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorInvertSubValueSelector.h → logic/OperatorInvertSubValueSelector.h} +0 -0
  87. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorMulSelector.h → logic/OperatorMulSelector.h} +0 -0
  88. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorMulValueSelector.h → logic/OperatorMulValueSelector.h} +0 -0
  89. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSubSelector.h → logic/OperatorSubSelector.h} +0 -0
  90. /hikyuu/include/hikyuu/trade_sys/selector/imp/{OperatorSubValueSelector.h → logic/OperatorSubValueSelector.h} +0 -0
  91. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/LICENSE +0 -0
  92. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/WHEEL +0 -0
  93. {hikyuu-2.1.5.dist-info → hikyuu-2.2.1.dist-info}/entry_points.txt +0 -0
@@ -31,6 +31,11 @@ def combinate_ind_analysis(
31
31
  :param list keys: 输出 Performance 统计项
32
32
  :rtype: pd.DataFrame
33
33
  '''
34
+ if not keys:
35
+ for key in keys:
36
+ if not Performance.exist(key):
37
+ raise Exception(f'Invalid key: {key}')
38
+
34
39
  pers = inner_combinate_ind_analysis(stk, query, tm, sys, buy_inds, sell_inds, n)
35
40
 
36
41
  if not keys:
@@ -75,6 +80,11 @@ def combinate_ind_analysis_multi(
75
80
  :param int n: 买入信号组合时的周期
76
81
  :param list keys: 输出 Performance 统计项
77
82
  '''
83
+ if not keys:
84
+ for key in keys:
85
+ if not Performance.exist(key):
86
+ raise Exception(f'Invalid key: {key}')
87
+
78
88
  if isinstance(stks, Block):
79
89
  blks = stks
80
90
  else:
@@ -95,6 +105,11 @@ def combinate_ind_analysis_multi(
95
105
 
96
106
 
97
107
  def analysis_sys_list(stks, query, sys_proto, keys=["累计投入本金", "当前总资产", "现金余额", "未平仓头寸净值", "赢利交易比例%", "赢利交易数", "亏损交易数"]):
108
+ if not keys:
109
+ for key in keys:
110
+ if not Performance.exist(key):
111
+ raise Exception(f'Invalid key: {key}')
112
+
98
113
  names = ["证券代码", "证券名称"]
99
114
  names.extend(keys)
100
115
  ret = {}
@@ -119,6 +134,11 @@ def analysis_sys_list(stks, query, sys_proto, keys=["累计投入本金", "当
119
134
 
120
135
 
121
136
  def analysis_sys_list_multi(stks, query, sys_proto, keys=["累计投入本金", "当前总资产", "现金余额", "未平仓头寸净值", "赢利交易比例%", "赢利交易数", "亏损交易数"]):
137
+ if not keys:
138
+ for key in keys:
139
+ if not Performance.exist(key):
140
+ raise Exception(f'Invalid key: {key}')
141
+
122
142
  out = inner_analysis_sys_list(stks, query, sys_proto)
123
143
  if not keys:
124
144
  ret = out
Binary file
Binary file
Binary file
hikyuu/cpp/core311.pyd CHANGED
Binary file
hikyuu/cpp/hikyuu.dll CHANGED
Binary file
hikyuu/data/common.py CHANGED
@@ -91,7 +91,7 @@ def get_stktype_list(quotations=None):
91
91
 
92
92
 
93
93
  @hku_catch(ret=[], trace=True)
94
- @timeout(120)
94
+ @timeout(30)
95
95
  def get_stk_code_name_list(market: str) -> list:
96
96
  """
97
97
  获取指定证券交易所股票代码与名称列表
@@ -128,7 +128,7 @@ def get_stk_code_name_list(market: str) -> list:
128
128
 
129
129
 
130
130
  @hku_catch(ret=[], trace=True)
131
- @timeout(120)
131
+ @timeout(60)
132
132
  def get_index_code_name_list() -> list:
133
133
  """
134
134
  获取所有股票指数代码名称列表
@@ -191,7 +191,7 @@ def get_new_holidays():
191
191
 
192
192
 
193
193
  @hku_catch(ret=[], trace=True)
194
- @timeout(120)
194
+ @timeout(60)
195
195
  def get_china_bond10_rate(start_date="19901219"):
196
196
  """获取中国国债收益率10年"""
197
197
  bond_zh_us_rate_df = ak.bond_zh_us_rate(start_date)
@@ -0,0 +1,4 @@
1
+ DELETE FROM `hku_base`.`stkweight`;
2
+ alter table `hku_base`.`stkweight` add `suogu` DOUBLE not null default 0;
3
+ ALTER TABLE `hku_base`.`stkweight` AUTO_INCREMENT = 1;
4
+ UPDATE `hku_base`.`version` set `version` = 23;
@@ -51,7 +51,7 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
51
51
  cur.execute(
52
52
  "select id, stockid, date, countAsGift, countForSell, priceForSell, \
53
53
  bonus, countOfIncreasement, totalCount, \
54
- freeCount from `hku_base`.`stkweight` where stockid=%s \
54
+ freeCount, suogu from `hku_base`.`stkweight` where stockid=%s \
55
55
  order by date desc limit 1" % stockid
56
56
  )
57
57
  a = [x for x in cur.fetchall()]
@@ -79,10 +79,6 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
79
79
  if xdxr['songzhuangu'] is not None:
80
80
  new_last_db_weight[3] = 10000 * xdxr['songzhuangu']
81
81
  update_last_db_weight = True
82
- if xdxr['suogu'] is not None:
83
- # etf 扩股
84
- new_last_db_weight[3] += 100000 * (xdxr['suogu']-1)
85
- update_last_db_weight = True
86
82
  if xdxr['peigu'] is not None:
87
83
  new_last_db_weight[4] = 10000 * xdxr['peigu']
88
84
  update_last_db_weight = True
@@ -100,26 +96,27 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
100
96
  new_last_db_weight[9] = xdxr['panhouliutong']
101
97
  update_last_db_weight = True
102
98
  last_free_count = new_last_db_weight[9]
99
+ if xdxr['suogu'] is not None:
100
+ # etf 扩缩股
101
+ new_last_db_weight[10] = xdxr['suogu']
102
+ update_last_db_weight = True
103
103
  continue
104
104
  if date not in records:
105
- songzhuangu = 10000 * xdxr['songzhuangu'] if xdxr['songzhuangu'] is not None else 0
106
- songzhuangu += 100000 * (xdxr['suogu']-1) if xdxr['suogu'] is not None else 0
107
105
  records[date] = [
108
106
  stockid,
109
107
  date,
110
- songzhuangu, # countAsGift
108
+ 10000 * xdxr['songzhuangu'] if xdxr['songzhuangu'] is not None else 0, # countAsGift
111
109
  10000 * xdxr['peigu'] if xdxr['peigu'] is not None else 0, # countForSell
112
110
  1000 * xdxr['peigujia'] if xdxr['peigujia'] is not None else 0, # priceForSell
113
111
  1000 * xdxr['fenhong'] if xdxr['fenhong'] is not None else 0, # bonus
114
112
  0, # countOfIncreasement, pytdx 不区分送股和转增股,统一记在送股
115
113
  xdxr['houzongguben'] if xdxr['houzongguben'] is not None else last_total_count, # totalCount
116
- xdxr['panhouliutong'] if xdxr['panhouliutong'] is not None else last_free_count # freeCount
114
+ xdxr['panhouliutong'] if xdxr['panhouliutong'] is not None else last_free_count, # freeCount
115
+ xdxr["suogu"] if xdxr["suogu"] is not None else 0
117
116
  ]
118
117
  else:
119
118
  if xdxr['songzhuangu'] is not None:
120
119
  records[date][2] = 10000 * xdxr['songzhuangu']
121
- if xdxr['suogu'] is not None:
122
- records[date][2] += 100000 * (xdxr['suogu']-1)
123
120
  if xdxr['peigu'] is not None:
124
121
  records[date][3] = 10000 * xdxr['peigu']
125
122
  if xdxr['peigujia'] is not None:
@@ -130,6 +127,8 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
130
127
  records[date][7] = xdxr['houzongguben']
131
128
  if xdxr['panhouliutong'] is not None:
132
129
  records[date][8] = xdxr['panhouliutong']
130
+ if xdxr['suogu'] is not None:
131
+ records[date][9] = xdxr['suogu']
133
132
  if xdxr['houzongguben'] is not None:
134
133
  last_total_count = xdxr['houzongguben']
135
134
  if xdxr['panhouliutong'] is not None:
@@ -144,8 +143,8 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
144
143
  x = new_last_db_weight
145
144
  cur.execute(
146
145
  "UPDATE `hku_base`.`stkweight` SET countAsGift=%s, countForSell=%s, priceForSell=%s, \
147
- bonus=%s, totalCount=%s, freeCount=%s \
148
- where id=%s" % (x[3], x[4], x[5], x[6], x[8], x[9], x[0])
146
+ bonus=%s, totalCount=%s, freeCount=%s, suogu=%s \
147
+ where id=%s" % (x[3], x[4], x[5], x[6], x[8], x[9], x[10], x[0])
149
148
  )
150
149
  connect.commit()
151
150
  cur.close()
@@ -154,8 +153,8 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
154
153
  cur = connect.cursor()
155
154
  cur.executemany(
156
155
  "INSERT INTO `hku_base`.`stkweight` (stockid, date, countAsGift, \
157
- countForSell, priceForSell, bonus, countOfIncreasement, totalCount, freeCount) \
158
- VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)", [x for x in records.values()]
156
+ countForSell, priceForSell, bonus, countOfIncreasement, totalCount, freeCount, suogu) \
157
+ VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", [x for x in records.values()]
159
158
  )
160
159
  connect.commit()
161
160
  cur.close()
@@ -48,7 +48,7 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
48
48
  a = cur.execute(
49
49
  "select id, stockid, date, countAsGift, countForSell, priceForSell, \
50
50
  bonus, countOfIncreasement, totalCount, \
51
- freeCount from stkweight where stockid=%s \
51
+ freeCount, suogu from stkweight where stockid=%s \
52
52
  order by date desc limit 1" % stockid
53
53
  )
54
54
  a = [x for x in a]
@@ -76,10 +76,6 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
76
76
  if xdxr['songzhuangu'] is not None:
77
77
  new_last_db_weight[3] = int(10000 * xdxr['songzhuangu'])
78
78
  update_last_db_weight = True
79
- if xdxr['suogu'] is not None:
80
- # etf 扩股
81
- new_last_db_weight[3] += int(100000 * (xdxr['suogu']-1))
82
- update_last_db_weight = True
83
79
  if xdxr['peigu'] is not None:
84
80
  new_last_db_weight[4] = int(10000 * xdxr['peigu'])
85
81
  update_last_db_weight = True
@@ -97,14 +93,16 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
97
93
  new_last_db_weight[9] = round(xdxr['panhouliutong'])
98
94
  update_last_db_weight = True
99
95
  last_free_count = new_last_db_weight[9]
96
+ if xdxr['suogu'] is not None:
97
+ # etf 扩股
98
+ new_last_db_weight[10] = xdxr['suogu']
99
+ update_last_db_weight = True
100
100
  continue
101
101
  if date not in records:
102
- songzhuangu = int(10000 * xdxr['songzhuangu']) if xdxr['songzhuangu'] is not None else 0
103
- songzhuangu += int(100000 * (xdxr['suogu']-1)) if xdxr['suogu'] is not None else 0
104
102
  records[date] = [
105
103
  stockid,
106
104
  date,
107
- songzhuangu, # countForGift
105
+ int(10000 * xdxr['songzhuangu']) if xdxr['songzhuangu'] is not None else 0, # countForGift
108
106
  int(10000 * xdxr['peigu']) if xdxr['peigu'] is not None else 0, # countForSell
109
107
  int(1000 * xdxr['peigujia']) if xdxr['peigujia'] is not None else 0, # priceForSell
110
108
  int(1000 * xdxr['fenhong']) if xdxr['fenhong'] is not None else 0, # bonus
@@ -112,13 +110,12 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
112
110
  round(xdxr['houzongguben'])
113
111
  if xdxr['houzongguben'] is not None else last_total_count, # totalCount
114
112
  round(xdxr['panhouliutong'])
115
- if xdxr['panhouliutong'] is not None else last_free_count # freeCount
113
+ if xdxr['panhouliutong'] is not None else last_free_count, # freeCount
114
+ xdxr["suogu"] if xdxr["suogu"] is not None else 0
116
115
  ]
117
116
  else:
118
117
  if xdxr['songzhuangu'] is not None:
119
118
  records[date][2] = int(10000 * xdxr['songzhuangu'])
120
- if xdxr['suogu'] is not None:
121
- records[date][2] += int(100000 * (xdxr['suogu']-1))
122
119
  if xdxr['peigu'] is not None:
123
120
  records[date][3] = int(10000 * xdxr['peigu'])
124
121
  if xdxr['peigujia'] is not None:
@@ -129,6 +126,8 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
129
126
  records[date][7] = round(xdxr['houzongguben'])
130
127
  if xdxr['panhouliutong'] is not None:
131
128
  records[date][8] = round(xdxr['panhouliutong'])
129
+ if xdxr['suogu'] is not None:
130
+ records[date][9] = xdxr['suogu']
132
131
  if xdxr['houzongguben'] is not None:
133
132
  last_total_count = round(xdxr['houzongguben'])
134
133
  if xdxr['panhouliutong'] is not None:
@@ -143,8 +142,8 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
143
142
  x = new_last_db_weight
144
143
  cur.execute(
145
144
  "UPDATE StkWeight SET countAsGift=%s, countForSell=%s, priceForSell=%s, \
146
- bonus=%s, totalCount=%s, freeCount=%s \
147
- where id=%s" % (x[3], x[4], x[5], x[6], x[8], x[9], x[0])
145
+ bonus=%s, totalCount=%s, freeCount=%s, suogu=%s \
146
+ where id=%s" % (x[3], x[4], x[5], x[6], x[8], x[9], x[10], x[0])
148
147
  )
149
148
  connect.commit()
150
149
  cur.close()
@@ -153,8 +152,8 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
153
152
  cur = connect.cursor()
154
153
  cur.executemany(
155
154
  "INSERT INTO StkWeight(stockid, date, countAsGift, \
156
- countForSell, priceForSell, bonus, countOfIncreasement, totalCount, freeCount) \
157
- VALUES (?,?,?,?,?,?,?,?,?)", [x for x in records.values()]
155
+ countForSell, priceForSell, bonus, countOfIncreasement, totalCount, freeCount, suogu) \
156
+ VALUES (?,?,?,?,?,?,?,?,?,?)", [x for x in records.values()]
158
157
  )
159
158
  connect.commit()
160
159
  cur.close()
@@ -0,0 +1,22 @@
1
+ BEGIN TRANSACTION;
2
+ DROP TABLE `stkWeight`;
3
+ CREATE TABLE "stkWeight" (
4
+ id INTEGER NOT NULL,
5
+ stockid INTEGER,
6
+ date INTEGER,
7
+ "countAsGift" INTEGER,
8
+ "countForSell" INTEGER,
9
+ "priceForSell" INTEGER,
10
+ bonus INTEGER,
11
+ "countOfIncreasement" INTEGER,
12
+ "totalCount" INTEGER,
13
+ "freeCount" INTEGER,
14
+ "suogu" NUMBER,
15
+ PRIMARY KEY (id AUTOINCREMENT),
16
+ FOREIGN KEY(stockid) REFERENCES "Stock" (stockid)
17
+ );
18
+ CREATE INDEX "ix_stkWeight_stockid" ON "stkWeight" (stockid);
19
+ CREATE INDEX "ix_stkWeight_date" ON "stkWeight" (date);
20
+ CREATE INDEX "ix_stkWeight" ON "stkWeight" (stockid, date);
21
+ UPDATE `version` set `version` = 24;
22
+ COMMIT;
hikyuu/gui/HikyuuTDX.py CHANGED
@@ -267,8 +267,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
267
267
 
268
268
  current_dir = os.path.dirname(__file__)
269
269
  self.setWindowIcon(QIcon("{}/hikyuu.ico".format(current_dir)))
270
- # self.setFixedSize(self.width(), self.height())
271
- self.import_status_label.setText('')
272
270
  self.import_detail_textEdit.clear()
273
271
  self.reset_progress_bar()
274
272
  self.day_start_dateEdit.setMinimumDate(datetime.date(1990, 12, 19))
@@ -703,6 +701,9 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
703
701
  self.start_import_pushButton.setEnabled(False)
704
702
  self.reset_progress_bar()
705
703
 
704
+ if config.getboolean('weight', 'enable', fallback=False):
705
+ self.hdf5_weight_label.setText("正在导入")
706
+
706
707
  self.import_status_label.setText("正在启动任务....")
707
708
  QApplication.processEvents()
708
709
 
@@ -115,6 +115,13 @@ class ImportHistoryFinanceTask:
115
115
  old_md5 = hashlib.md5(f.read()).hexdigest()
116
116
  if old_md5 != item['hash']:
117
117
  self.download_file(item)
118
+ else:
119
+ # 不管是否有变化,都导入一次,以便切换引擎时可以导入
120
+ shutil.unpack_archive(dest_file, extract_dir=self.dest_dir)
121
+ filename = item['filename']
122
+ filename = f'{self.dest_dir}/{filename[0:-4]}.dat'
123
+ self.import_to_db(filename)
124
+ hku_info(f"Import finance file: {filename}")
118
125
  count += 1
119
126
  self.queue.put([self.task_name, None, None, int(100 * count / self.total_count), self.total_count])
120
127
  except Exception as e:
@@ -91,8 +91,8 @@ class ImportWeightToSqliteTask:
91
91
  hku_check(api.connect(self.host, self.port), "failed connect pytdx {}:{}!", self.host, self.port)
92
92
 
93
93
  if self.cmd == 'weight':
94
- count = pytdx_import_weight(api, connect, self.market)
95
- self.logger.info("导入 {} 权息记录数: {}".format(self.market, count))
94
+ total_count = pytdx_import_weight(api, connect, self.market)
95
+ self.logger.info("导入 {} 权息记录数: {}".format(self.market, total_count))
96
96
  self.queue.put([self.msg_name, '导入权息数据完毕!', 0, 0, f'{self.market} {total_count}'])
97
97
  elif self.cmd == 'finance':
98
98
  self.queue.put([self.msg_name, f'下载通达信当前财务信息({self.market})...', 0, 0, 0])