hikyuu 2.5.6__py3-none-win_amd64.whl → 2.6.1__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 (118) hide show
  1. hikyuu/__init__.py +33 -49
  2. hikyuu/__init__.pyi +530 -516
  3. hikyuu/analysis/__init__.pyi +498 -490
  4. hikyuu/analysis/analysis.pyi +499 -491
  5. hikyuu/core.pyi +500 -492
  6. hikyuu/cpp/__init__.pyi +2 -2
  7. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  8. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  9. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  10. hikyuu/cpp/core310.pyd +0 -0
  11. hikyuu/cpp/core310.pyi +187 -22
  12. hikyuu/cpp/core311.pyd +0 -0
  13. hikyuu/cpp/core311.pyi +187 -22
  14. hikyuu/cpp/core312.pyd +0 -0
  15. hikyuu/cpp/core312.pyi +187 -22
  16. hikyuu/cpp/core313.pyd +0 -0
  17. hikyuu/cpp/core313.pyi +186 -22
  18. hikyuu/cpp/core39.pyd +0 -0
  19. hikyuu/cpp/core39.pyi +187 -22
  20. hikyuu/cpp/hikyuu.dll +0 -0
  21. hikyuu/cpp/hikyuu.lib +0 -0
  22. hikyuu/draw/__init__.pyi +1 -1
  23. hikyuu/draw/drawplot/__init__.py +2 -0
  24. hikyuu/draw/drawplot/__init__.pyi +9 -8
  25. hikyuu/draw/drawplot/bokeh_draw.pyi +519 -506
  26. hikyuu/draw/drawplot/common.pyi +1 -1
  27. hikyuu/draw/drawplot/echarts_draw.pyi +521 -508
  28. hikyuu/draw/drawplot/matplotlib_draw.py +80 -0
  29. hikyuu/draw/drawplot/matplotlib_draw.pyi +540 -517
  30. hikyuu/draw/elder.pyi +11 -11
  31. hikyuu/draw/kaufman.pyi +18 -18
  32. hikyuu/draw/volume.pyi +10 -10
  33. hikyuu/examples/notebook/002-HowToGetStock.ipynb +1 -1
  34. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +117 -52
  35. hikyuu/extend.pyi +507 -500
  36. hikyuu/gui/HikyuuTDX.py +85 -15
  37. hikyuu/gui/data/ImportQmtToH5Task.py +209 -0
  38. hikyuu/gui/data/ImportTdxToH5Task.py +8 -1
  39. hikyuu/gui/data/MainWindow.py +94 -13
  40. hikyuu/gui/data/UseQmtImportToH5Thread.py +316 -0
  41. hikyuu/gui/data/UseTdxImportToH5Thread.py +221 -65
  42. hikyuu/gui/dataserver.py +25 -0
  43. hikyuu/gui/images/star.png +0 -0
  44. hikyuu/gui/importdata.py +24 -11
  45. hikyuu/hub.pyi +6 -6
  46. hikyuu/include/hikyuu/KData.h +5 -0
  47. hikyuu/include/hikyuu/KDataImp.h +4 -0
  48. hikyuu/include/hikyuu/StockManager.h +23 -0
  49. hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +41 -2
  50. hikyuu/include/hikyuu/global/agent/spot_generated.h +3 -3
  51. hikyuu/include/hikyuu/indicator/crt/COUNT.h +3 -3
  52. hikyuu/include/hikyuu/indicator/crt/DISCARD.h +1 -1
  53. hikyuu/include/hikyuu/indicator/crt/ISINF.h +1 -1
  54. hikyuu/include/hikyuu/indicator/crt/ISINFA.h +1 -1
  55. hikyuu/include/hikyuu/indicator/crt/ISNA.h +1 -1
  56. hikyuu/include/hikyuu/indicator/crt/LAST.h +2 -2
  57. hikyuu/include/hikyuu/indicator/crt/MAX.h +1 -1
  58. hikyuu/include/hikyuu/indicator/crt/MIN.h +1 -1
  59. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +1 -15
  60. hikyuu/include/hikyuu/indicator/crt/SUMBARS.h +1 -1
  61. hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +33 -0
  62. hikyuu/include/hikyuu/plugin/__init__.py +1 -0
  63. hikyuu/include/hikyuu/plugin/backtest.h +37 -0
  64. hikyuu/include/hikyuu/plugin/dataserver.h +18 -0
  65. hikyuu/include/hikyuu/plugin/device.h +29 -0
  66. hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +26 -0
  67. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +23 -0
  68. hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +25 -0
  69. hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +33 -0
  70. hikyuu/include/hikyuu/plugin/interface/__init__.py +1 -0
  71. hikyuu/include/hikyuu/plugin/interface/plugins.h +22 -0
  72. hikyuu/include/hikyuu/python/pybind_utils.h +8 -0
  73. hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +2 -1
  74. hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +1 -0
  75. hikyuu/include/hikyuu/strategy/Strategy.h +93 -16
  76. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +4 -2
  77. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +2 -1
  78. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -9
  79. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +1 -1
  80. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +12 -12
  81. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +2 -2
  82. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +1 -1
  83. hikyuu/include/hikyuu/trade_sys/system/System.h +12 -3
  84. hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +0 -1
  85. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +0 -1
  86. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +3 -2
  87. hikyuu/include/hikyuu/utilities/arithmetic.h +32 -22
  88. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -0
  89. hikyuu/include/hikyuu/utilities/plugin/PluginClient.h +2 -2
  90. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +66 -13
  91. hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +72 -0
  92. hikyuu/include/hikyuu/version.h +5 -5
  93. hikyuu/plugin/__init__.py +1 -0
  94. hikyuu/plugin/backtest.dll +0 -0
  95. hikyuu/plugin/dataserver.dll +0 -0
  96. hikyuu/plugin/device.dll +0 -0
  97. hikyuu/plugin/import2hdf5.dll +0 -0
  98. hikyuu/strategy/strategy_demo1.py +7 -8
  99. hikyuu/strategy/strategy_demo2.py +1 -1
  100. hikyuu/trade_manage/__init__.pyi +518 -505
  101. hikyuu/trade_manage/broker.pyi +3 -3
  102. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  103. hikyuu/trade_manage/trade.pyi +518 -505
  104. hikyuu/util/__init__.py +1 -0
  105. hikyuu/util/__init__.pyi +2 -1
  106. hikyuu/util/mylog.py +30 -3
  107. hikyuu/util/mylog.pyi +3 -1
  108. hikyuu/util/singleton.pyi +1 -1
  109. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/METADATA +6 -2
  110. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/RECORD +115 -97
  111. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/entry_points.txt +1 -0
  112. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/top_level.txt +4 -0
  113. hikyuu/cpp/core38.pyd +0 -0
  114. hikyuu/cpp/core38.pyi +0 -13173
  115. hikyuu/examples/notebook/011-PyechartsDrawplot.ipynb +0 -21821
  116. /hikyuu/gui/{hikyuu_small.png → images/hikyuu_small.png} +0 -0
  117. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/LICENSE +0 -0
  118. {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/WHEEL +0 -0
@@ -823,6 +823,86 @@ def sysplot(sys, new=True, axes=None, style=1, only_draw_close=False):
823
823
  )
824
824
 
825
825
 
826
+ def tm_performance(tm: TradeManager, query: Query, ref_stk: Stock = None):
827
+ """
828
+ 绘制系统绩效,即账户累积收益率曲线
829
+
830
+ :param SystemBase | PortfolioBase sys: SYS或PF实例
831
+ :param Stock ref_stk: 参考股票, 默认为沪深300: sh000300, 绘制参考标的的收益曲线
832
+ :return: None
833
+ """
834
+ if ref_stk is None:
835
+ ref_stk = get_stock('sh000300')
836
+
837
+ sh000001_k = get_kdata('sh000001', query)
838
+ ref_dates = sh000001_k.get_datetime_list()
839
+
840
+ ref_k = ref_stk.get_kdata(query)
841
+
842
+ funds_list = tm.get_funds_list(ref_dates)
843
+ funds = [f.total_assets for f in funds_list]
844
+ funds = VALUE(funds)
845
+ funds_return = [f.total_assets / f.total_base if f.total_base != 0.0 else constant.null_price for f in funds_list]
846
+ funds_return = VALUE(funds_return, align_dates=ref_dates)
847
+ funds_return.name = "系统累积收益率"
848
+ ref_return = ALIGN(ROCR(ref_k.close, 0), ref_dates)
849
+ ref_return.name = f"{ref_stk.name}({ref_stk.market_code})"
850
+
851
+ per = Performance()
852
+ text = per.report(tm, sh000001_k[-1].datetime)
853
+
854
+ # 计算最大回撤
855
+ max_pullback = min(MDD(funds).to_np())
856
+
857
+ # 计算 sharp
858
+ bond = ZHBOND10(ref_dates)
859
+ sigma = STDEV(ROCP(funds), len(ref_dates))
860
+ sigma = 15.874507866387544 * sigma[-1] # 15.874 = sqrt(252)
861
+ sharp = (per['帐户平均年收益率%'] - bond[-1]) * 0.01 / sigma if sigma != 0.0 else 0.0
862
+
863
+ invest_total = per['累计投入本金'] + per['累计投入资产']
864
+ cur_fund = per['当前总资产']
865
+ t1 = '投入总资产: {:<.2f} 当前总资产: {:<.2f} 当前盈利: {:<.2f}'.format(
866
+ invest_total, cur_fund, cur_fund - invest_total)
867
+ t2 = '当前策略收益: {:<.2f}% 年化收益率: {:<.2f}% 最大回撤: {:<.2f}%'.format(
868
+ funds_return[-1]*100 - 100, per["帐户平均年收益率%"], max_pullback)
869
+ t3 = '系统胜率: {:<.2f}% 盈/亏比: 1 : {:<.2f} 夏普比率: {:<.2f}'.format(
870
+ per['赢利交易比例%'], per['净赢利/亏损比例'], sharp)
871
+
872
+ import matplotlib.pyplot as plt
873
+ fg = plt.figure(figsize=(15, 10))
874
+ gs = fg.add_gridspec(5, 4)
875
+ ax1 = fg.add_subplot(gs[:4, :3])
876
+ ax2 = fg.add_subplot(gs[:, 3:])
877
+ ax3 = fg.add_subplot(gs[4:, :3])
878
+ ref_return.plot(axes=ax1, legend_on=True)
879
+ funds_return.plot(axes=ax1, legend_on=True)
880
+ ax1.set_title(f"账户({tm.name}) 累积收益率")
881
+ label = t1 + '\n\n' + t2 + '\n\n' + t3
882
+ ax2.text(0,
883
+ 1,
884
+ text,
885
+ horizontalalignment='left',
886
+ verticalalignment='top',
887
+ transform=ax2.transAxes,
888
+ # color='r'
889
+ )
890
+ ax3.text(0.02,
891
+ 0.9,
892
+ label,
893
+ horizontalalignment='left',
894
+ verticalalignment='top',
895
+ transform=ax3.transAxes,
896
+ # color='r'
897
+ )
898
+ ax2.xaxis.set_visible(False)
899
+ ax2.yaxis.set_visible(False)
900
+ ax2.set_frame_on(False)
901
+ ax3.xaxis.set_visible(False)
902
+ ax3.yaxis.set_visible(False)
903
+ ax3.set_frame_on(False)
904
+
905
+
826
906
  def sys_performance(sys, ref_stk=None):
827
907
  """
828
908
  绘制系统绩效,即账户累积收益率曲线