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.
- hikyuu/__init__.py +15 -0
- hikyuu/__init__.pyi +524 -516
- hikyuu/analysis/__init__.pyi +497 -490
- hikyuu/analysis/analysis.pyi +498 -491
- hikyuu/core.pyi +499 -492
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +153 -21
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +153 -21
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +153 -21
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +152 -21
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +153 -21
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/tdx_to_mysql.py +15 -15
- hikyuu/draw/drawplot/__init__.py +2 -0
- hikyuu/draw/drawplot/__init__.pyi +9 -8
- hikyuu/draw/drawplot/bokeh_draw.pyi +514 -507
- hikyuu/draw/drawplot/common.pyi +1 -1
- hikyuu/draw/drawplot/echarts_draw.pyi +516 -509
- hikyuu/draw/drawplot/matplotlib_draw.py +80 -0
- hikyuu/draw/drawplot/matplotlib_draw.pyi +535 -518
- hikyuu/draw/elder.pyi +11 -11
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/002-HowToGetStock.ipynb +1 -1
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +117 -52
- hikyuu/extend.pyi +507 -501
- hikyuu/gui/HikyuuTDX.py +19 -3
- hikyuu/gui/data/MainWindow.py +87 -24
- hikyuu/gui/data/UseTdxImportToH5Thread.py +2 -2
- hikyuu/gui/dataserver.py +25 -0
- hikyuu/gui/images/star.png +0 -0
- hikyuu/hub.py +7 -13
- hikyuu/hub.pyi +9 -6
- hikyuu/include/hikyuu/StockManager.h +23 -0
- hikyuu/include/hikyuu/global/agent/spot_generated.h +3 -3
- hikyuu/include/hikyuu/plugin/__init__.py +1 -0
- hikyuu/include/hikyuu/plugin/backtest.h +37 -0
- hikyuu/include/hikyuu/plugin/dataserver.h +18 -0
- hikyuu/include/hikyuu/plugin/device.h +29 -0
- hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +26 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +23 -0
- hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +25 -0
- hikyuu/include/hikyuu/plugin/interface/__init__.py +1 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +20 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +8 -0
- hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +2 -1
- hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +1 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +96 -16
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +4 -2
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +3 -2
- hikyuu/include/hikyuu/utilities/config.h +1 -1
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +3 -3
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +8 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +47 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginClient.h +55 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +117 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +72 -0
- hikyuu/include/hikyuu/utilities/plugin/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -1
- hikyuu/include/hikyuu/version.h +5 -5
- hikyuu/indicator/indicator.py +1 -1
- hikyuu/plugin/__init__.py +1 -0
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/strategy/strategy_demo1.py +7 -8
- hikyuu/strategy/strategy_demo2.py +1 -1
- hikyuu/trade_manage/__init__.pyi +513 -506
- hikyuu/trade_manage/broker.pyi +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +1 -1
- hikyuu/trade_manage/trade.pyi +513 -506
- hikyuu/util/__init__.pyi +2 -2
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/METADATA +6 -2
- {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/RECORD +90 -73
- {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/entry_points.txt +1 -0
- {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/top_level.txt +5 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/core38.pyi +0 -13172
- hikyuu/examples/notebook/011-PyechartsDrawplot.ipynb +0 -21821
- /hikyuu/gui/{hikyuu_small.png → images/hikyuu_small.png} +0 -0
- {hikyuu-2.5.5.dist-info → hikyuu-2.6.0.dist-info}/LICENSE +0 -0
- {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
|
绘制系统绩效,即账户累积收益率曲线
|