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.
- hikyuu/__init__.py +33 -49
- hikyuu/__init__.pyi +530 -516
- hikyuu/analysis/__init__.pyi +498 -490
- hikyuu/analysis/analysis.pyi +499 -491
- hikyuu/core.pyi +500 -492
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +187 -22
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +187 -22
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +187 -22
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +186 -22
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +187 -22
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.py +2 -0
- hikyuu/draw/drawplot/__init__.pyi +9 -8
- hikyuu/draw/drawplot/bokeh_draw.pyi +519 -506
- hikyuu/draw/drawplot/common.pyi +1 -1
- hikyuu/draw/drawplot/echarts_draw.pyi +521 -508
- hikyuu/draw/drawplot/matplotlib_draw.py +80 -0
- hikyuu/draw/drawplot/matplotlib_draw.pyi +540 -517
- 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 -500
- hikyuu/gui/HikyuuTDX.py +85 -15
- hikyuu/gui/data/ImportQmtToH5Task.py +209 -0
- hikyuu/gui/data/ImportTdxToH5Task.py +8 -1
- hikyuu/gui/data/MainWindow.py +94 -13
- hikyuu/gui/data/UseQmtImportToH5Thread.py +316 -0
- hikyuu/gui/data/UseTdxImportToH5Thread.py +221 -65
- hikyuu/gui/dataserver.py +25 -0
- hikyuu/gui/images/star.png +0 -0
- hikyuu/gui/importdata.py +24 -11
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/KData.h +5 -0
- hikyuu/include/hikyuu/KDataImp.h +4 -0
- hikyuu/include/hikyuu/StockManager.h +23 -0
- hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +41 -2
- hikyuu/include/hikyuu/global/agent/spot_generated.h +3 -3
- hikyuu/include/hikyuu/indicator/crt/COUNT.h +3 -3
- hikyuu/include/hikyuu/indicator/crt/DISCARD.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/ISINF.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/ISINFA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/ISNA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/LAST.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/MAX.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/MIN.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +1 -15
- hikyuu/include/hikyuu/indicator/crt/SUMBARS.h +1 -1
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +33 -0
- 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/ImportKDataToHdf5PluginInterface.h +33 -0
- hikyuu/include/hikyuu/plugin/interface/__init__.py +1 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +22 -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 +93 -16
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +4 -2
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +2 -1
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -9
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +12 -12
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +2 -2
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/system/System.h +12 -3
- hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +0 -1
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +0 -1
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +3 -2
- hikyuu/include/hikyuu/utilities/arithmetic.h +32 -22
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginClient.h +2 -2
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +66 -13
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +72 -0
- hikyuu/include/hikyuu/version.h +5 -5
- 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/plugin/import2hdf5.dll +0 -0
- hikyuu/strategy/strategy_demo1.py +7 -8
- hikyuu/strategy/strategy_demo2.py +1 -1
- hikyuu/trade_manage/__init__.pyi +518 -505
- hikyuu/trade_manage/broker.pyi +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +1 -1
- hikyuu/trade_manage/trade.pyi +518 -505
- hikyuu/util/__init__.py +1 -0
- hikyuu/util/__init__.pyi +2 -1
- hikyuu/util/mylog.py +30 -3
- hikyuu/util/mylog.pyi +3 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/METADATA +6 -2
- {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/RECORD +115 -97
- {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/entry_points.txt +1 -0
- {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/top_level.txt +4 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/core38.pyi +0 -13173
- hikyuu/examples/notebook/011-PyechartsDrawplot.ipynb +0 -21821
- /hikyuu/gui/{hikyuu_small.png → images/hikyuu_small.png} +0 -0
- {hikyuu-2.5.6.dist-info → hikyuu-2.6.1.dist-info}/LICENSE +0 -0
- {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
|
绘制系统绩效,即账户累积收益率曲线
|