hikyuu 2.5.5__py3-none-win_amd64.whl → 2.6.0__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 (93) hide show
  1. hikyuu/__init__.py +15 -0
  2. hikyuu/__init__.pyi +524 -516
  3. hikyuu/analysis/__init__.pyi +497 -490
  4. hikyuu/analysis/analysis.pyi +498 -491
  5. hikyuu/core.pyi +499 -492
  6. hikyuu/cpp/__init__.pyi +2 -2
  7. hikyuu/cpp/core310.pyd +0 -0
  8. hikyuu/cpp/core310.pyi +153 -21
  9. hikyuu/cpp/core311.pyd +0 -0
  10. hikyuu/cpp/core311.pyi +153 -21
  11. hikyuu/cpp/core312.pyd +0 -0
  12. hikyuu/cpp/core312.pyi +153 -21
  13. hikyuu/cpp/core313.pyd +0 -0
  14. hikyuu/cpp/core313.pyi +152 -21
  15. hikyuu/cpp/core39.pyd +0 -0
  16. hikyuu/cpp/core39.pyi +153 -21
  17. hikyuu/cpp/hikyuu.dll +0 -0
  18. hikyuu/cpp/hikyuu.lib +0 -0
  19. hikyuu/cpp/sqlite3.dll +0 -0
  20. hikyuu/data/tdx_to_mysql.py +15 -15
  21. hikyuu/draw/drawplot/__init__.py +2 -0
  22. hikyuu/draw/drawplot/__init__.pyi +9 -8
  23. hikyuu/draw/drawplot/bokeh_draw.pyi +514 -507
  24. hikyuu/draw/drawplot/common.pyi +1 -1
  25. hikyuu/draw/drawplot/echarts_draw.pyi +516 -509
  26. hikyuu/draw/drawplot/matplotlib_draw.py +80 -0
  27. hikyuu/draw/drawplot/matplotlib_draw.pyi +535 -518
  28. hikyuu/draw/elder.pyi +11 -11
  29. hikyuu/draw/kaufman.pyi +18 -18
  30. hikyuu/draw/volume.pyi +10 -10
  31. hikyuu/examples/notebook/002-HowToGetStock.ipynb +1 -1
  32. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +117 -52
  33. hikyuu/extend.pyi +507 -501
  34. hikyuu/gui/HikyuuTDX.py +19 -3
  35. hikyuu/gui/data/MainWindow.py +87 -24
  36. hikyuu/gui/data/UseTdxImportToH5Thread.py +2 -2
  37. hikyuu/gui/dataserver.py +25 -0
  38. hikyuu/gui/images/star.png +0 -0
  39. hikyuu/hub.py +7 -13
  40. hikyuu/hub.pyi +9 -6
  41. hikyuu/include/hikyuu/StockManager.h +23 -0
  42. hikyuu/include/hikyuu/global/agent/spot_generated.h +3 -3
  43. hikyuu/include/hikyuu/plugin/__init__.py +1 -0
  44. hikyuu/include/hikyuu/plugin/backtest.h +37 -0
  45. hikyuu/include/hikyuu/plugin/dataserver.h +18 -0
  46. hikyuu/include/hikyuu/plugin/device.h +29 -0
  47. hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +26 -0
  48. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +23 -0
  49. hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +25 -0
  50. hikyuu/include/hikyuu/plugin/interface/__init__.py +1 -0
  51. hikyuu/include/hikyuu/plugin/interface/plugins.h +20 -0
  52. hikyuu/include/hikyuu/python/pybind_utils.h +8 -0
  53. hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +2 -1
  54. hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +1 -0
  55. hikyuu/include/hikyuu/strategy/Strategy.h +96 -16
  56. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +4 -2
  57. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +3 -2
  58. hikyuu/include/hikyuu/utilities/config.h +1 -1
  59. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +3 -3
  60. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +8 -0
  61. hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +47 -0
  62. hikyuu/include/hikyuu/utilities/plugin/PluginClient.h +55 -0
  63. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +117 -0
  64. hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +72 -0
  65. hikyuu/include/hikyuu/utilities/plugin/__init__.py +1 -0
  66. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +1 -1
  67. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
  68. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +1 -1
  69. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -1
  70. hikyuu/include/hikyuu/version.h +5 -5
  71. hikyuu/indicator/indicator.py +1 -1
  72. hikyuu/plugin/__init__.py +1 -0
  73. hikyuu/plugin/backtest.dll +0 -0
  74. hikyuu/plugin/dataserver.dll +0 -0
  75. hikyuu/plugin/device.dll +0 -0
  76. hikyuu/strategy/strategy_demo1.py +7 -8
  77. hikyuu/strategy/strategy_demo2.py +1 -1
  78. hikyuu/trade_manage/__init__.pyi +513 -506
  79. hikyuu/trade_manage/broker.pyi +3 -3
  80. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  81. hikyuu/trade_manage/trade.pyi +513 -506
  82. hikyuu/util/__init__.pyi +2 -2
  83. hikyuu/util/singleton.pyi +1 -1
  84. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/METADATA +6 -2
  85. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/RECORD +90 -73
  86. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/entry_points.txt +1 -0
  87. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/top_level.txt +5 -0
  88. hikyuu/cpp/core38.pyd +0 -0
  89. hikyuu/cpp/core38.pyi +0 -13172
  90. hikyuu/examples/notebook/011-PyechartsDrawplot.ipynb +0 -21821
  91. /hikyuu/gui/{hikyuu_small.png → images/hikyuu_small.png} +0 -0
  92. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/LICENSE +0 -0
  93. {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.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
  绘制系统绩效,即账户累积收益率曲线