hikyuu 2.6.8__py3-none-manylinux2014_aarch64.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/LICENSE.txt +21 -0
- hikyuu/__init__.py +577 -0
- hikyuu/__init__.pyi +872 -0
- hikyuu/analysis/__init__.py +14 -0
- hikyuu/analysis/__init__.pyi +572 -0
- hikyuu/analysis/analysis.py +151 -0
- hikyuu/analysis/analysis.pyi +602 -0
- hikyuu/config/__init__.py +1 -0
- hikyuu/config/block/__init__.py +0 -0
- hikyuu/config/block/dybk.ini +5357 -0
- hikyuu/config/block/gnbk.ini +50024 -0
- hikyuu/config/block/hybk.ini +5464 -0
- hikyuu/config/block/self.ini +10 -0
- hikyuu/config/block/zsbk.ini +65543 -0
- hikyuu/core.py +27 -0
- hikyuu/core.pyi +567 -0
- hikyuu/cpp/__init__.py +1 -0
- hikyuu/cpp/__init__.pyi +3 -0
- hikyuu/cpp/core310.pyi +14179 -0
- hikyuu/cpp/core310.so +0 -0
- hikyuu/cpp/core311.pyi +14179 -0
- hikyuu/cpp/core311.so +0 -0
- hikyuu/cpp/core312.pyi +14179 -0
- hikyuu/cpp/core312.so +0 -0
- hikyuu/cpp/core313.pyi +14158 -0
- hikyuu/cpp/core313.so +0 -0
- hikyuu/cpp/core39.pyi +14179 -0
- hikyuu/cpp/core39.so +0 -0
- hikyuu/cpp/i18n/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/libcrypto.so.3 +0 -0
- hikyuu/cpp/libhikyuu.so +0 -0
- hikyuu/cpp/libhku_hdf5.so +0 -0
- hikyuu/cpp/libhku_hdf5.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5.so.200.2.0 +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so.200.2.0 +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so.200.1.0 +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so.200.1.0 +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so.200.1.1 +0 -0
- hikyuu/cpp/libmysqlclient.so +0 -0
- hikyuu/cpp/libmysqlclient.so.21 +0 -0
- hikyuu/cpp/libmysqlclient.so.21.2.32 +0 -0
- hikyuu/cpp/libresolv.so.2 +0 -0
- hikyuu/cpp/libsqlite3.so +0 -0
- hikyuu/cpp/libssl.so.3 +0 -0
- hikyuu/cpp/libzstd.so.1 +0 -0
- hikyuu/data/__init__.py +1 -0
- hikyuu/data/clickhouse_upgrade/__init__.py +1 -0
- hikyuu/data/clickhouse_upgrade/createdb.sql +1085 -0
- hikyuu/data/common.py +248 -0
- hikyuu/data/common_clickhouse.py +465 -0
- hikyuu/data/common_h5.py +398 -0
- hikyuu/data/common_mysql.py +521 -0
- hikyuu/data/common_pytdx.py +126 -0
- hikyuu/data/common_sqlite3.py +141 -0
- hikyuu/data/em_block_to_clickhouse.py +120 -0
- hikyuu/data/em_block_to_mysql.py +121 -0
- hikyuu/data/em_block_to_sqlite.py +122 -0
- hikyuu/data/hku_config_template.py +335 -0
- hikyuu/data/mysql_upgrade/0001.sql +5 -0
- hikyuu/data/mysql_upgrade/0002.sql +3 -0
- hikyuu/data/mysql_upgrade/0003.sql +9 -0
- hikyuu/data/mysql_upgrade/0004.sql +26 -0
- hikyuu/data/mysql_upgrade/0005.sql +3 -0
- hikyuu/data/mysql_upgrade/0006.sql +2 -0
- hikyuu/data/mysql_upgrade/0007.sql +20 -0
- hikyuu/data/mysql_upgrade/0008.sql +6 -0
- hikyuu/data/mysql_upgrade/0009.sql +36 -0
- hikyuu/data/mysql_upgrade/0010.sql +5 -0
- hikyuu/data/mysql_upgrade/0011.sql +5 -0
- hikyuu/data/mysql_upgrade/0012.sql +5 -0
- hikyuu/data/mysql_upgrade/0013.sql +2389 -0
- hikyuu/data/mysql_upgrade/0014.sql +3 -0
- hikyuu/data/mysql_upgrade/0015.sql +4 -0
- hikyuu/data/mysql_upgrade/0016.sql +4 -0
- hikyuu/data/mysql_upgrade/0017.sql +5 -0
- hikyuu/data/mysql_upgrade/0018.sql +2 -0
- hikyuu/data/mysql_upgrade/0019.sql +6 -0
- hikyuu/data/mysql_upgrade/0020.sql +4 -0
- hikyuu/data/mysql_upgrade/0021.sql +4 -0
- hikyuu/data/mysql_upgrade/0022.sql +5 -0
- hikyuu/data/mysql_upgrade/0023.sql +4 -0
- hikyuu/data/mysql_upgrade/0024.sql +2 -0
- hikyuu/data/mysql_upgrade/0025.sql +61 -0
- hikyuu/data/mysql_upgrade/0026.sql +9 -0
- hikyuu/data/mysql_upgrade/0027.sql +6 -0
- hikyuu/data/mysql_upgrade/0028.sql +95 -0
- hikyuu/data/mysql_upgrade/__init__.py +1 -0
- hikyuu/data/mysql_upgrade/createdb.sql +265 -0
- hikyuu/data/pytdx_finance_to_clickhouse.py +107 -0
- hikyuu/data/pytdx_finance_to_mysql.py +129 -0
- hikyuu/data/pytdx_finance_to_sqlite.py +162 -0
- hikyuu/data/pytdx_to_clickhouse.py +841 -0
- hikyuu/data/pytdx_to_h5.py +705 -0
- hikyuu/data/pytdx_to_mysql.py +839 -0
- hikyuu/data/pytdx_to_taos.py +736 -0
- hikyuu/data/pytdx_weight_to_clickhouse.py +191 -0
- hikyuu/data/pytdx_weight_to_mysql.py +196 -0
- hikyuu/data/pytdx_weight_to_sqlite.py +192 -0
- hikyuu/data/sqlite_mem.py +84 -0
- hikyuu/data/sqlite_mem_sql/__init__.py +1 -0
- hikyuu/data/sqlite_mem_sql/createdb.sql +126 -0
- hikyuu/data/sqlite_upgrade/0001.sql +4 -0
- hikyuu/data/sqlite_upgrade/0002.sql +48 -0
- hikyuu/data/sqlite_upgrade/0003.sql +18 -0
- hikyuu/data/sqlite_upgrade/0004.sql +11 -0
- hikyuu/data/sqlite_upgrade/0005.sql +28 -0
- hikyuu/data/sqlite_upgrade/0006.sql +5 -0
- hikyuu/data/sqlite_upgrade/0007.sql +4 -0
- hikyuu/data/sqlite_upgrade/0008.sql +22 -0
- hikyuu/data/sqlite_upgrade/0009.sql +8 -0
- hikyuu/data/sqlite_upgrade/0010.sql +5 -0
- hikyuu/data/sqlite_upgrade/0011.sql +16 -0
- hikyuu/data/sqlite_upgrade/0012.sql +15 -0
- hikyuu/data/sqlite_upgrade/0013.sql +9 -0
- hikyuu/data/sqlite_upgrade/0014.sql +607 -0
- hikyuu/data/sqlite_upgrade/0015.sql +7 -0
- hikyuu/data/sqlite_upgrade/0016.sql +8 -0
- hikyuu/data/sqlite_upgrade/0017.sql +16 -0
- hikyuu/data/sqlite_upgrade/0018.sql +5 -0
- hikyuu/data/sqlite_upgrade/0019.sql +4 -0
- hikyuu/data/sqlite_upgrade/0020.sql +4 -0
- hikyuu/data/sqlite_upgrade/0021.sql +6 -0
- hikyuu/data/sqlite_upgrade/0022.sql +6 -0
- hikyuu/data/sqlite_upgrade/0023.sql +7 -0
- hikyuu/data/sqlite_upgrade/0024.sql +22 -0
- hikyuu/data/sqlite_upgrade/0025.sql +63 -0
- hikyuu/data/sqlite_upgrade/0026.sql +10 -0
- hikyuu/data/sqlite_upgrade/0027.sql +8 -0
- hikyuu/data/sqlite_upgrade/0028.sql +97 -0
- hikyuu/data/sqlite_upgrade/__init__.py +1 -0
- hikyuu/data/sqlite_upgrade/createdb.sql +61 -0
- hikyuu/data/tdx_to_clickhouse.py +448 -0
- hikyuu/data/tdx_to_h5.py +464 -0
- hikyuu/data/tdx_to_mysql.py +464 -0
- hikyuu/data/weight_to_mysql.py +72 -0
- hikyuu/data/weight_to_sqlite.py +70 -0
- hikyuu/data/zh_bond10_to_clickhouse.py +49 -0
- hikyuu/data/zh_bond10_to_mysql.py +30 -0
- hikyuu/data/zh_bond10_to_sqlite.py +42 -0
- hikyuu/data_driver/__init__.py +49 -0
- hikyuu/data_driver/jqdata_data_driver.py +277 -0
- hikyuu/data_driver/pytdx_data_driver.py +292 -0
- hikyuu/draw/__init__.py +65 -0
- hikyuu/draw/__init__.pyi +35 -0
- hikyuu/draw/drawplot/__init__.py +309 -0
- hikyuu/draw/drawplot/__init__.pyi +139 -0
- hikyuu/draw/drawplot/bokeh_draw.py +583 -0
- hikyuu/draw/drawplot/bokeh_draw.pyi +872 -0
- hikyuu/draw/drawplot/common.py +89 -0
- hikyuu/draw/drawplot/common.pyi +10 -0
- hikyuu/draw/drawplot/echarts_draw.py +598 -0
- hikyuu/draw/drawplot/echarts_draw.pyi +758 -0
- hikyuu/draw/drawplot/icon/1.png +0 -0
- hikyuu/draw/drawplot/icon/10.png +0 -0
- hikyuu/draw/drawplot/icon/11.png +0 -0
- hikyuu/draw/drawplot/icon/12.png +0 -0
- hikyuu/draw/drawplot/icon/13.png +0 -0
- hikyuu/draw/drawplot/icon/14.png +0 -0
- hikyuu/draw/drawplot/icon/15.png +0 -0
- hikyuu/draw/drawplot/icon/16.png +0 -0
- hikyuu/draw/drawplot/icon/17.png +0 -0
- hikyuu/draw/drawplot/icon/18.png +0 -0
- hikyuu/draw/drawplot/icon/19.png +0 -0
- hikyuu/draw/drawplot/icon/2.png +0 -0
- hikyuu/draw/drawplot/icon/20.png +0 -0
- hikyuu/draw/drawplot/icon/21.png +0 -0
- hikyuu/draw/drawplot/icon/22.png +0 -0
- hikyuu/draw/drawplot/icon/23.png +0 -0
- hikyuu/draw/drawplot/icon/24.png +0 -0
- hikyuu/draw/drawplot/icon/25.png +0 -0
- hikyuu/draw/drawplot/icon/26.png +0 -0
- hikyuu/draw/drawplot/icon/27.png +0 -0
- hikyuu/draw/drawplot/icon/28.png +0 -0
- hikyuu/draw/drawplot/icon/29.png +0 -0
- hikyuu/draw/drawplot/icon/3.png +0 -0
- hikyuu/draw/drawplot/icon/30.png +0 -0
- hikyuu/draw/drawplot/icon/31.png +0 -0
- hikyuu/draw/drawplot/icon/32.png +0 -0
- hikyuu/draw/drawplot/icon/33.png +0 -0
- hikyuu/draw/drawplot/icon/34.png +0 -0
- hikyuu/draw/drawplot/icon/35.png +0 -0
- hikyuu/draw/drawplot/icon/36.png +0 -0
- hikyuu/draw/drawplot/icon/37.png +0 -0
- hikyuu/draw/drawplot/icon/38.png +0 -0
- hikyuu/draw/drawplot/icon/39.png +0 -0
- hikyuu/draw/drawplot/icon/4.png +0 -0
- hikyuu/draw/drawplot/icon/40.png +0 -0
- hikyuu/draw/drawplot/icon/41.png +0 -0
- hikyuu/draw/drawplot/icon/42.png +0 -0
- hikyuu/draw/drawplot/icon/43.png +0 -0
- hikyuu/draw/drawplot/icon/44.png +0 -0
- hikyuu/draw/drawplot/icon/45.png +0 -0
- hikyuu/draw/drawplot/icon/46.png +0 -0
- hikyuu/draw/drawplot/icon/47.png +0 -0
- hikyuu/draw/drawplot/icon/48.png +0 -0
- hikyuu/draw/drawplot/icon/49.png +0 -0
- hikyuu/draw/drawplot/icon/5.png +0 -0
- hikyuu/draw/drawplot/icon/6.png +0 -0
- hikyuu/draw/drawplot/icon/7.png +0 -0
- hikyuu/draw/drawplot/icon/8.png +0 -0
- hikyuu/draw/drawplot/icon/9.png +0 -0
- hikyuu/draw/drawplot/icon/__init__.py +0 -0
- hikyuu/draw/drawplot/matplotlib_draw.py +1620 -0
- hikyuu/draw/drawplot/matplotlib_draw.pyi +1234 -0
- hikyuu/draw/elder.py +135 -0
- hikyuu/draw/elder.pyi +44 -0
- hikyuu/draw/kaufman.py +192 -0
- hikyuu/draw/kaufman.pyi +38 -0
- hikyuu/draw/volume.py +122 -0
- hikyuu/draw/volume.pyi +31 -0
- hikyuu/examples/Turtle_SG.py +47 -0
- hikyuu/examples/__init__.py +1 -0
- hikyuu/examples/examples_init.py +33 -0
- hikyuu/examples/notebook/000-Index.ipynb +76 -0
- hikyuu/examples/notebook/001-overview.ipynb +325 -0
- hikyuu/examples/notebook/002-HowToGetStock.ipynb +484 -0
- hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +383 -0
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +568 -0
- hikyuu/examples/notebook/005-Drawplot.ipynb +350 -0
- hikyuu/examples/notebook/006-TradeManager.ipynb +1128 -0
- hikyuu/examples/notebook/007-SystemDetails.ipynb +394 -0
- hikyuu/examples/notebook/008-Pickle.ipynb +127 -0
- hikyuu/examples/notebook/009-RealData.ipynb +110 -0
- hikyuu/examples/notebook/010-Portfolio.ipynb +968 -0
- hikyuu/examples/notebook/Demo/Demo1.ipynb +623 -0
- hikyuu/examples/notebook/Demo/Demo2.ipynb +665 -0
- hikyuu/examples/notebook/Demo/__init__.py +1 -0
- hikyuu/examples/notebook/README.md +1 -0
- hikyuu/examples/notebook/__init__.py +1 -0
- hikyuu/examples/notebook/images/002_01_block_config.png +0 -0
- hikyuu/examples/notebook/images/008_01_tocsv.png +0 -0
- hikyuu/examples/notebook/images/008_02_tocsv_look.png +0 -0
- hikyuu/examples/notebook/images/008_03_pickle.png +0 -0
- hikyuu/examples/notebook/images/__init__.py +1 -0
- hikyuu/examples/quick_crtsg.py +40 -0
- hikyuu/extend.py +289 -0
- hikyuu/extend.pyi +658 -0
- hikyuu/fetcher/__init__.py +8 -0
- hikyuu/fetcher/proxy/__init__.py +12 -0
- hikyuu/fetcher/proxy/proxy.py +39 -0
- hikyuu/fetcher/proxy/zhima.py +63 -0
- hikyuu/fetcher/stock/__init__.py +8 -0
- hikyuu/fetcher/stock/zh_block_em.py +562 -0
- hikyuu/fetcher/stock/zh_stock_a_huatai.py +51 -0
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +129 -0
- hikyuu/fetcher/stock/zh_stock_a_qmt.py +57 -0
- hikyuu/fetcher/stock/zh_stock_a_sina_qq.py +185 -0
- hikyuu/flat/Spot.py +336 -0
- hikyuu/flat/SpotList.py +74 -0
- hikyuu/flat/__init__.py +4 -0
- hikyuu/gui/HikyuuTDX.py +1062 -0
- hikyuu/gui/__init__.py +1 -0
- hikyuu/gui/data/CollectSpotThread.py +43 -0
- hikyuu/gui/data/CollectToMemThread.py +123 -0
- hikyuu/gui/data/CollectToMySQLThread.py +178 -0
- hikyuu/gui/data/EscapetimeThread.py +32 -0
- hikyuu/gui/data/ImportBlockInfoTask.py +67 -0
- hikyuu/gui/data/ImportHistoryFinanceTask.py +161 -0
- hikyuu/gui/data/ImportPytdxTimeToH5Task.py +106 -0
- hikyuu/gui/data/ImportPytdxToH5Task.py +112 -0
- hikyuu/gui/data/ImportPytdxTransToH5Task.py +106 -0
- hikyuu/gui/data/ImportQmtToH5Task.py +209 -0
- hikyuu/gui/data/ImportTdxToH5Task.py +130 -0
- hikyuu/gui/data/ImportWeightToSqliteTask.py +128 -0
- hikyuu/gui/data/ImportZhBond10Task.py +59 -0
- hikyuu/gui/data/MainWindow.py +1003 -0
- hikyuu/gui/data/SchedImportThread.py +62 -0
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +394 -0
- hikyuu/gui/data/UseQmtImportToH5Thread.py +317 -0
- hikyuu/gui/data/UseTdxImportToH5Thread.py +357 -0
- hikyuu/gui/data/__init__.py +1 -0
- hikyuu/gui/data/tool.py +43 -0
- hikyuu/gui/dataserver.py +33 -0
- hikyuu/gui/hikyuu.ico +0 -0
- hikyuu/gui/images/hikyuu_small.png +0 -0
- hikyuu/gui/images/star.png +0 -0
- hikyuu/gui/importdata.py +166 -0
- hikyuu/gui/spot_server.py +326 -0
- hikyuu/gui/start_huatai_insight.py +510 -0
- hikyuu/gui/start_qmt.py +139 -0
- hikyuu/hub.py +771 -0
- hikyuu/hub.pyi +295 -0
- hikyuu/include/__init__.py +1 -0
- hikyuu/include/hikyuu/Block.h +193 -0
- hikyuu/include/hikyuu/DataType.h +179 -0
- hikyuu/include/hikyuu/GlobalInitializer.h +46 -0
- hikyuu/include/hikyuu/HistoryFinanceInfo.h +35 -0
- hikyuu/include/hikyuu/KData.h +334 -0
- hikyuu/include/hikyuu/KDataImp.h +83 -0
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
- hikyuu/include/hikyuu/KQuery.h +289 -0
- hikyuu/include/hikyuu/KRecord.h +97 -0
- hikyuu/include/hikyuu/MarketInfo.h +138 -0
- hikyuu/include/hikyuu/Stock.h +376 -0
- hikyuu/include/hikyuu/StockManager.h +418 -0
- hikyuu/include/hikyuu/StockMapIterator.h +72 -0
- hikyuu/include/hikyuu/StockTypeInfo.h +133 -0
- hikyuu/include/hikyuu/StockWeight.h +148 -0
- hikyuu/include/hikyuu/StrategyContext.h +116 -0
- hikyuu/include/hikyuu/TimeLineRecord.h +71 -0
- hikyuu/include/hikyuu/TransRecord.h +73 -0
- hikyuu/include/hikyuu/ZhBond10.h +36 -0
- hikyuu/include/hikyuu/__init__.py +1 -0
- hikyuu/include/hikyuu/analysis/__init__.py +1 -0
- hikyuu/include/hikyuu/analysis/analysis_sys.h +76 -0
- hikyuu/include/hikyuu/analysis/combinate.h +115 -0
- hikyuu/include/hikyuu/config.h +51 -0
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +236 -0
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +108 -0
- hikyuu/include/hikyuu/data_driver/DataDriverFactory.h +58 -0
- hikyuu/include/hikyuu/data_driver/DriverConnectPool.h +146 -0
- hikyuu/include/hikyuu/data_driver/HistoryFinanceReader.h +36 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +199 -0
- hikyuu/include/hikyuu/data_driver/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/base_info/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +54 -0
- hikyuu/include/hikyuu/data_driver/base_info/mysql/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +50 -0
- hikyuu/include/hikyuu/data_driver/base_info/sqlite/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceFieldTable.h +19 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceTable.h +23 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/HolidayTable.h +29 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/MarketInfoTable.h +127 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/StockTable.h +64 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/StockTypeInfoTable.h +108 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/StockWeightTable.h +52 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/ZhBond10Table.h +20 -0
- hikyuu/include/hikyuu/data_driver/base_info/table/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/block_info/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +36 -0
- hikyuu/include/hikyuu/data_driver/block_info/mysql/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +31 -0
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +36 -0
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +33 -0
- hikyuu/include/hikyuu/data_driver/kdata/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +106 -0
- hikyuu/include/hikyuu/data_driver/kdata/cvs/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +89 -0
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5Record.h +50 -0
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +164 -0
- hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +78 -0
- hikyuu/include/hikyuu/data_driver/kdata/mysql/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +62 -0
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/__init__.py +1 -0
- hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +63 -0
- hikyuu/include/hikyuu/data_driver/kdata/tdx/__init__.py +1 -0
- hikyuu/include/hikyuu/debug.h +32 -0
- hikyuu/include/hikyuu/doc.h +170 -0
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +41 -0
- hikyuu/include/hikyuu/global/SpotRecord.h +36 -0
- hikyuu/include/hikyuu/global/__init__.py +1 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +148 -0
- hikyuu/include/hikyuu/global/agent/__init__.py +1 -0
- hikyuu/include/hikyuu/global/agent/spot_generated.h +343 -0
- hikyuu/include/hikyuu/global/schedule/__init__.py +1 -0
- hikyuu/include/hikyuu/global/schedule/inner_tasks.h +16 -0
- hikyuu/include/hikyuu/global/schedule/scheduler.h +24 -0
- hikyuu/include/hikyuu/global/sysinfo.h +67 -0
- hikyuu/include/hikyuu/hikyuu.h +55 -0
- hikyuu/include/hikyuu/indicator/IndParam.h +39 -0
- hikyuu/include/hikyuu/indicator/Indicator.h +487 -0
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +75 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +490 -0
- hikyuu/include/hikyuu/indicator/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator/build_in.h +133 -0
- hikyuu/include/hikyuu/indicator/crt/ABS.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/ACOS.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/AD.h +28 -0
- hikyuu/include/hikyuu/indicator/crt/ADVANCE.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/ALIGN.h +42 -0
- hikyuu/include/hikyuu/indicator/crt/AMA.h +114 -0
- hikyuu/include/hikyuu/indicator/crt/ASIN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/ATAN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/ATR.h +33 -0
- hikyuu/include/hikyuu/indicator/crt/AVEDEV.h +45 -0
- hikyuu/include/hikyuu/indicator/crt/BACKSET.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/BARSCOUNT.h +37 -0
- hikyuu/include/hikyuu/indicator/crt/BARSLAST.h +41 -0
- hikyuu/include/hikyuu/indicator/crt/BARSLASTCOUNT.h +33 -0
- hikyuu/include/hikyuu/indicator/crt/BARSSINCE.h +53 -0
- hikyuu/include/hikyuu/indicator/crt/BETWEEN.h +85 -0
- hikyuu/include/hikyuu/indicator/crt/BLOCKSETNUM.h +23 -0
- hikyuu/include/hikyuu/indicator/crt/CEILING.h +38 -0
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/CORR.h +26 -0
- hikyuu/include/hikyuu/indicator/crt/COS.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/COST.h +37 -0
- hikyuu/include/hikyuu/indicator/crt/COUNT.h +54 -0
- hikyuu/include/hikyuu/indicator/crt/CROSS.h +48 -0
- hikyuu/include/hikyuu/indicator/crt/CVAL.h +35 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/DECLINE.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/DEVSQ.h +40 -0
- hikyuu/include/hikyuu/indicator/crt/DIFF.h +31 -0
- hikyuu/include/hikyuu/indicator/crt/DISCARD.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/DMA.h +35 -0
- hikyuu/include/hikyuu/indicator/crt/DOWNNDAY.h +43 -0
- hikyuu/include/hikyuu/indicator/crt/DROPNA.h +31 -0
- hikyuu/include/hikyuu/indicator/crt/EMA.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/EVERY.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/EXIST.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/EXP.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/FILTER.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/FINANCE.h +20 -0
- hikyuu/include/hikyuu/indicator/crt/FLOOR.h +38 -0
- hikyuu/include/hikyuu/indicator/crt/HHV.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/HHVBARS.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/HSL.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/IC.h +49 -0
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +55 -0
- hikyuu/include/hikyuu/indicator/crt/INBLOCK.h +31 -0
- hikyuu/include/hikyuu/indicator/crt/INDEX.h +60 -0
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +33 -0
- hikyuu/include/hikyuu/indicator/crt/INTPART.h +38 -0
- hikyuu/include/hikyuu/indicator/crt/IR.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/ISINF.h +28 -0
- hikyuu/include/hikyuu/indicator/crt/ISINFA.h +28 -0
- hikyuu/include/hikyuu/indicator/crt/ISLASTBAR.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/ISNA.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/JUMPDOWN.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/JUMPUP.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/KALMAN.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/KDATA.h +72 -0
- hikyuu/include/hikyuu/indicator/crt/LAST.h +100 -0
- hikyuu/include/hikyuu/indicator/crt/LASTVALUE.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/LIUTONGPAN.h +24 -0
- hikyuu/include/hikyuu/indicator/crt/LLV.h +46 -0
- hikyuu/include/hikyuu/indicator/crt/LLVBARS.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/LN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/LOG.h +35 -0
- hikyuu/include/hikyuu/indicator/crt/LONGCROSS.h +68 -0
- hikyuu/include/hikyuu/indicator/crt/MA.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/MACD.h +62 -0
- hikyuu/include/hikyuu/indicator/crt/MAX.h +45 -0
- hikyuu/include/hikyuu/indicator/crt/MDD.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/MIN.h +45 -0
- hikyuu/include/hikyuu/indicator/crt/MOD.h +49 -0
- hikyuu/include/hikyuu/indicator/crt/MRR.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/NDAY.h +43 -0
- hikyuu/include/hikyuu/indicator/crt/NOT.h +35 -0
- hikyuu/include/hikyuu/indicator/crt/POS.h +21 -0
- hikyuu/include/hikyuu/indicator/crt/POW.h +48 -0
- hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +47 -0
- hikyuu/include/hikyuu/indicator/crt/RECOVER.h +45 -0
- hikyuu/include/hikyuu/indicator/crt/REF.h +48 -0
- hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
- hikyuu/include/hikyuu/indicator/crt/REPLACE.h +29 -0
- hikyuu/include/hikyuu/indicator/crt/RESULT.h +20 -0
- hikyuu/include/hikyuu/indicator/crt/REVERSE.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/ROC.h +39 -0
- hikyuu/include/hikyuu/indicator/crt/ROCP.h +39 -0
- hikyuu/include/hikyuu/indicator/crt/ROCR.h +39 -0
- hikyuu/include/hikyuu/indicator/crt/ROCR100.h +39 -0
- hikyuu/include/hikyuu/indicator/crt/ROUND.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/ROUNDDOWN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/ROUNDUP.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/RSI.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/SAFTYLOSS.h +79 -0
- hikyuu/include/hikyuu/indicator/crt/SGN.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/SIN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/SLICE.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/SLOPE.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/SMA.h +72 -0
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +25 -0
- hikyuu/include/hikyuu/indicator/crt/SQRT.h +41 -0
- hikyuu/include/hikyuu/indicator/crt/STDEV.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/STDP.h +38 -0
- hikyuu/include/hikyuu/indicator/crt/SUM.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/SUMBARS.h +44 -0
- hikyuu/include/hikyuu/indicator/crt/TAN.h +36 -0
- hikyuu/include/hikyuu/indicator/crt/TIME.h +69 -0
- hikyuu/include/hikyuu/indicator/crt/TIMELINE.h +23 -0
- hikyuu/include/hikyuu/indicator/crt/TIMELINEVOL.h +21 -0
- hikyuu/include/hikyuu/indicator/crt/TR.h +32 -0
- hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +21 -0
- hikyuu/include/hikyuu/indicator/crt/UPNDAY.h +43 -0
- hikyuu/include/hikyuu/indicator/crt/VAR.h +40 -0
- hikyuu/include/hikyuu/indicator/crt/VARP.h +40 -0
- hikyuu/include/hikyuu/indicator/crt/VIGOR.h +34 -0
- hikyuu/include/hikyuu/indicator/crt/WINNER.h +38 -0
- hikyuu/include/hikyuu/indicator/crt/WMA.h +46 -0
- hikyuu/include/hikyuu/indicator/crt/ZHBOND10.h +27 -0
- hikyuu/include/hikyuu/indicator/crt/ZONGGUBEN.h +17 -0
- hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator/imp/IAbs.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IAcos.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IAd.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IAdvance.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IAlign.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IAma.h +38 -0
- hikyuu/include/hikyuu/indicator/imp/IAsin.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IAtan.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IAtr.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IBackset.h +33 -0
- hikyuu/include/hikyuu/indicator/imp/IBarsCount.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IBarsLast.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IBarsLastCount.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/IBarsSince.h +34 -0
- hikyuu/include/hikyuu/indicator/imp/IBlockSetNum.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ICeil.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/IContext.h +49 -0
- hikyuu/include/hikyuu/indicator/imp/ICorr.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/ICos.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ICost.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/ICount.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/ICval.h +35 -0
- hikyuu/include/hikyuu/indicator/imp/ICycle.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IDecline.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IDevsq.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IDiff.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IDiscard.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IDma.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IDropna.h +37 -0
- hikyuu/include/hikyuu/indicator/imp/IEma.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IEvery.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IExist.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IExp.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IFilter.h +34 -0
- hikyuu/include/hikyuu/indicator/imp/IFinance.h +25 -0
- hikyuu/include/hikyuu/indicator/imp/IFloor.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/IHhvbars.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IHighLine.h +34 -0
- hikyuu/include/hikyuu/indicator/imp/IHsl.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IIc.h +46 -0
- hikyuu/include/hikyuu/indicator/imp/IInBlock.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IInSum.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IIndex.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIntpart.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInf.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInfa.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IIsLastBar.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/IIsNa.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpDown.h +24 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpUp.h +24 -0
- hikyuu/include/hikyuu/indicator/imp/IKData.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IKalman.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/ILastValue.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/ILiuTongPan.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/ILn.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ILog.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ILowLine.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/ILowLineBars.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IMa.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/IMacd.h +41 -0
- hikyuu/include/hikyuu/indicator/imp/IMdd.h +23 -0
- hikyuu/include/hikyuu/indicator/imp/IMrr.h +23 -0
- hikyuu/include/hikyuu/indicator/imp/INot.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IPow.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IPriceList.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IRecover.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IRef.h +34 -0
- hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
- hikyuu/include/hikyuu/indicator/imp/IReplace.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IResult.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IReverse.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/IRoc.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IRocp.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IRocr.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IRocr100.h +29 -0
- hikyuu/include/hikyuu/indicator/imp/IRound.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IRoundDown.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IRoundUp.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/ISaftyLoss.h +44 -0
- hikyuu/include/hikyuu/indicator/imp/ISign.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ISin.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ISlice.h +25 -0
- hikyuu/include/hikyuu/indicator/imp/ISlope.h +25 -0
- hikyuu/include/hikyuu/indicator/imp/ISma.h +34 -0
- hikyuu/include/hikyuu/indicator/imp/ISpearman.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/ISqrt.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/IStdev.h +31 -0
- hikyuu/include/hikyuu/indicator/imp/IStdp.h +33 -0
- hikyuu/include/hikyuu/indicator/imp/ISum.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/ISumBars.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/ITan.h +28 -0
- hikyuu/include/hikyuu/indicator/imp/ITime.h +33 -0
- hikyuu/include/hikyuu/indicator/imp/ITimeLine.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/ITr.h +35 -0
- hikyuu/include/hikyuu/indicator/imp/IVar.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IVarp.h +32 -0
- hikyuu/include/hikyuu/indicator/imp/IVigor.h +35 -0
- hikyuu/include/hikyuu/indicator/imp/IWinner.h +26 -0
- hikyuu/include/hikyuu/indicator/imp/IWma.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IZScore.h +25 -0
- hikyuu/include/hikyuu/indicator/imp/IZhBond10.h +30 -0
- hikyuu/include/hikyuu/indicator/imp/IZongGuBen.h +25 -0
- hikyuu/include/hikyuu/indicator/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator_talib/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaAdosc.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaApo.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaBbands.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMa.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMacd.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMacdext.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMama.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMavp.h +27 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaPpo.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaSar.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaSarext.h +31 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStddev.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStoch.h +27 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStochf.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStochrsi.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaT3.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaUltosc.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaVar.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +237 -0
- hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +1328 -0
- hikyuu/include/hikyuu/indicator_talib/ta_crt.h +322 -0
- hikyuu/include/hikyuu/lang.h +27 -0
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +41 -0
- hikyuu/include/hikyuu/plugin/__init__.py +1 -0
- hikyuu/include/hikyuu/plugin/backtest.h +40 -0
- hikyuu/include/hikyuu/plugin/dataserver.h +43 -0
- hikyuu/include/hikyuu/plugin/device.h +33 -0
- hikyuu/include/hikyuu/plugin/extind.h +195 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +77 -0
- hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +27 -0
- hikyuu/include/hikyuu/plugin/interface/DataDriverPluginInterface.h +27 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +24 -0
- hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +26 -0
- hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +26 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +54 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +45 -0
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +81 -0
- hikyuu/include/hikyuu/plugin/interface/__init__.py +1 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +30 -0
- hikyuu/include/hikyuu/python/__init__.py +1 -0
- hikyuu/include/hikyuu/python/convert_any.h +299 -0
- hikyuu/include/hikyuu/python/pickle_support.h +90 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +128 -0
- hikyuu/include/hikyuu/serialization/Block_serialization.h +55 -0
- hikyuu/include/hikyuu/serialization/Datetime_serialization.h +40 -0
- hikyuu/include/hikyuu/serialization/KData_serialization.h +45 -0
- hikyuu/include/hikyuu/serialization/KQuery_serialization.h +79 -0
- hikyuu/include/hikyuu/serialization/KRecord_serialization.h +50 -0
- hikyuu/include/hikyuu/serialization/MarketInfo_serialization.h +68 -0
- hikyuu/include/hikyuu/serialization/PriceList_serialization.h +66 -0
- hikyuu/include/hikyuu/serialization/StockTypeInfo_serialization.h +62 -0
- hikyuu/include/hikyuu/serialization/StockWeight_serialization.h +65 -0
- hikyuu/include/hikyuu/serialization/Stock_serialization.h +47 -0
- hikyuu/include/hikyuu/serialization/TimeDelta_serialization.h +44 -0
- hikyuu/include/hikyuu/serialization/TimeLineRecord_serialization.h +42 -0
- hikyuu/include/hikyuu/serialization/TransRecord_serialization.h +44 -0
- hikyuu/include/hikyuu/serialization/__init__.py +1 -0
- hikyuu/include/hikyuu/serialization/all.h +26 -0
- hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +436 -0
- hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +37 -0
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +38 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +271 -0
- hikyuu/include/hikyuu/strategy/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_manage/BorrowRecord.h +91 -0
- hikyuu/include/hikyuu/trade_manage/CostRecord.h +67 -0
- hikyuu/include/hikyuu/trade_manage/FundsRecord.h +110 -0
- hikyuu/include/hikyuu/trade_manage/LoanRecord.h +64 -0
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +214 -0
- hikyuu/include/hikyuu/trade_manage/Performance.h +87 -0
- hikyuu/include/hikyuu/trade_manage/PositionExtInfo.h +92 -0
- hikyuu/include/hikyuu/trade_manage/PositionRecord.h +120 -0
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +179 -0
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +494 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +850 -0
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +163 -0
- hikyuu/include/hikyuu/trade_manage/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_manage/build_in.h +19 -0
- hikyuu/include/hikyuu/trade_manage/crt/TC_FixedA.h +45 -0
- hikyuu/include/hikyuu/trade_manage/crt/TC_FixedA2015.h +43 -0
- hikyuu/include/hikyuu/trade_manage/crt/TC_FixedA2017.h +44 -0
- hikyuu/include/hikyuu/trade_manage/crt/TC_TestStub.h +21 -0
- hikyuu/include/hikyuu/trade_manage/crt/TC_Zero.h +25 -0
- hikyuu/include/hikyuu/trade_manage/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_manage/crt/crtTM.h +33 -0
- hikyuu/include/hikyuu/trade_manage/imp/FixedA2015TradeCost.h +53 -0
- hikyuu/include/hikyuu/trade_manage/imp/FixedA2017TradeCost.h +56 -0
- hikyuu/include/hikyuu/trade_manage/imp/FixedATradeCost.h +88 -0
- hikyuu/include/hikyuu/trade_manage/imp/TradeCostStub.h +48 -0
- hikyuu/include/hikyuu/trade_manage/imp/ZeroTradeCost.h +50 -0
- hikyuu/include/hikyuu/trade_manage/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/all.h +24 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +234 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +17 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_EqualWeight.h +25 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedWeight.h +26 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedWeightList.h +22 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_MultiFactor.h +21 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/EqualWeightAllocateFunds.h +27 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixedWeightAllocateFunds.h +28 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixedWeightListAllocateFunds.h +25 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/MultiFactorAllocaterFunds.h +26 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +249 -0
- hikyuu/include/hikyuu/trade_sys/condition/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/condition/build_in.h +17 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/CN_Bool.h +22 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/CN_Logic.h +35 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/CN_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/CN_OPLine.h +26 -0
- hikyuu/include/hikyuu/trade_sys/condition/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/BoolCondition.h +40 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/ManualCondition.h +23 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/OPLineCondition.h +44 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/AddCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/AndCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/DivCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/MultiCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/OrCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/SubCondition.h +42 -0
- hikyuu/include/hikyuu/trade_sys/condition/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +197 -0
- hikyuu/include/hikyuu/trade_sys/environment/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/build_in.h +17 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/EV_Bool.h +23 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/EV_Logic.h +35 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/EV_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/EV_TwoLine.h +28 -0
- hikyuu/include/hikyuu/trade_sys/environment/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/BoolEnvironment.h +41 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/ManualEnvironment.h +23 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/TwoLineEnvironment.h +47 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/AddEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/AndEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/DivEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/MultiEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/OrEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/SubEnvironment.h +42 -0
- hikyuu/include/hikyuu/trade_sys/environment/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +248 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/build_in.h +22 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapital.h +26 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapitalFunds.h +26 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCount.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCountTps.h +27 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedPercent.h +27 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedRisk.h +26 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedUnits.h +26 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_Nothing.h +24 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_WilliamsFixedRisk.h +27 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalMoneyManager.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCountMoneyManager.h +38 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCountTpsMM.h +44 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedPercentMoneyManager.h +34 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedRiskMoneyManager.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedUnitsMoneyManager.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/NotMoneyManager.h +30 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/WilliamsFixedRiskMoneyManager.h +28 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +281 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoreRecord.h +51 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +13 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +32 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +33 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +33 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +33 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +26 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +41 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +258 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/build_in.h +15 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_Simple.h +47 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_WithoutAF.h +50 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +53 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +57 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +194 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/build_in.h +16 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/crt/PG_FixedHoldDays.h +26 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/crt/PG_FixedPercent.h +25 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/crt/PG_NoGoal.h +24 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/imp/FixedHoldDays.h +29 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/imp/FixedPercentProfitGoal.h +28 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/imp/NoGoalProfitGoal.h +27 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +251 -0
- hikyuu/include/hikyuu/trade_sys/selector/SystemWeight.h +70 -0
- hikyuu/include/hikyuu/trade_sys/selector/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/build_in.h +18 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Fixed.h +38 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Logic.h +43 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +40 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Optimal.h +34 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Signal.h +30 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/FixedSelector.h +28 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +59 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/SignalSelector.h +30 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorAddSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorAddValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorDivSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorDivValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorInvertDivValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorInvertSubValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorMulSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorMulValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +108 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSubSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSubValueSelector.h +19 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +94 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/MaxFundsOptimalSelector.h +27 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalEvaluateSelector.h +28 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +87 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +42 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +294 -0
- hikyuu/include/hikyuu/trade_sys/signal/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/build_in.h +24 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_AllwaysBuy.h +20 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Band.h +37 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Bool.h +29 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Cross.h +28 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_CrossGold.h +29 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Cycle.h +20 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Flex.h +29 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Logic.h +127 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Manual.h +20 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_OneSide.h +38 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Single.h +56 -0
- hikyuu/include/hikyuu/trade_sys/signal/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/AllwaysBuySignal.h +25 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +47 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/BoolSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/CrossGoldSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/CrossSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/CycleSignal.h +25 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/ManualSignal.h +23 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/OneSideSignal.h +46 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/SingleSignal.h +45 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/SingleSignal2.h +45 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AndSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +70 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +68 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OrSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubSignal.h +19 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +175 -0
- hikyuu/include/hikyuu/trade_sys/slippage/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/slippage/build_in.h +15 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_FixedPercent.h +26 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_FixedValue.h +26 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/FixedPercentSlippage.h +28 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/FixedValueSlippage.h +28 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +204 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/build_in.h +16 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/crt/ST_FixedPercent.h +25 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/crt/ST_Indicator.h +21 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/crt/ST_Saftyloss.h +37 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/imp/FixedPercentStoploss.h +30 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/imp/IndicatorStoploss.h +49 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/system/System.h +653 -0
- hikyuu/include/hikyuu/trade_sys/system/SystemPart.h +54 -0
- hikyuu/include/hikyuu/trade_sys/system/TradeRequest.h +97 -0
- hikyuu/include/hikyuu/trade_sys/system/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/system/build_in.h +15 -0
- hikyuu/include/hikyuu/trade_sys/system/crt/SYS_Simple.h +50 -0
- hikyuu/include/hikyuu/trade_sys/system/crt/SYS_WalkForward.h +21 -0
- hikyuu/include/hikyuu/trade_sys/system/crt/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +50 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +69 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +470 -0
- hikyuu/include/hikyuu/trade_sys/system/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/ConnectPool.h +163 -0
- hikyuu/include/hikyuu/utilities/DllLoader.h +226 -0
- hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
- hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
- hikyuu/include/hikyuu/utilities/Log.h +438 -0
- hikyuu/include/hikyuu/utilities/Null.h +176 -0
- hikyuu/include/hikyuu/utilities/Parameter.h +511 -0
- hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
- hikyuu/include/hikyuu/utilities/SpendTimer.h +305 -0
- hikyuu/include/hikyuu/utilities/TimerManager.h +552 -0
- hikyuu/include/hikyuu/utilities/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
- hikyuu/include/hikyuu/utilities/arithmetic.h +411 -0
- hikyuu/include/hikyuu/utilities/base64.h +52 -0
- hikyuu/include/hikyuu/utilities/config.h +39 -0
- hikyuu/include/hikyuu/utilities/cppdef.h +25 -0
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +460 -0
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +357 -0
- hikyuu/include/hikyuu/utilities/datetime/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/db_connect/AutoTransAction.h +124 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +252 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +30 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +658 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +28 -0
- hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +62 -0
- hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +248 -0
- hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +305 -0
- hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +2579 -0
- hikyuu/include/hikyuu/utilities/db_connect/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +60 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +88 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +89 -0
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +71 -0
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +80 -0
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/exception.h +52 -0
- hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
- hikyuu/include/hikyuu/utilities/http_client/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
- hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
- hikyuu/include/hikyuu/utilities/ini_parser/IniParser.h +104 -0
- hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/md5.h +41 -0
- hikyuu/include/hikyuu/utilities/moFileReader.h +836 -0
- hikyuu/include/hikyuu/utilities/node/NodeClient.h +175 -0
- hikyuu/include/hikyuu/utilities/node/NodeError.h +66 -0
- hikyuu/include/hikyuu/utilities/node/NodeMessage.h +80 -0
- hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
- hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/os.h +115 -0
- hikyuu/include/hikyuu/utilities/osdef.h +159 -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 +118 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +72 -0
- hikyuu/include/hikyuu/utilities/plugin/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/runtimeinfo.h +35 -0
- hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
- hikyuu/include/hikyuu/utilities/string_view.h +70 -0
- hikyuu/include/hikyuu/utilities/thread/FuncWrapper.h +85 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +315 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +271 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +310 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +224 -0
- hikyuu/include/hikyuu/utilities/thread/InterruptFlag.h +46 -0
- hikyuu/include/hikyuu/utilities/thread/MQStealQueue.h +112 -0
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +238 -0
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +203 -0
- hikyuu/include/hikyuu/utilities/thread/ThreadSafeQueue.h +105 -0
- hikyuu/include/hikyuu/utilities/thread/WorkStealQueue.h +105 -0
- hikyuu/include/hikyuu/utilities/thread/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +116 -0
- hikyuu/include/hikyuu/utilities/thread/thread.h +14 -0
- hikyuu/include/hikyuu/version.h +24 -0
- hikyuu/include/hikyuu/views/__init__.py +1 -0
- hikyuu/include/hikyuu/views/arrow_common.h +38 -0
- hikyuu/include/hikyuu/views/arrow_views.h +117 -0
- hikyuu/indicator/__init__.py +28 -0
- hikyuu/indicator/indicator.py +119 -0
- hikyuu/indicator/pyind.py +47 -0
- hikyuu/interactive.py +68 -0
- hikyuu/plugin/__init__.py +1 -0
- hikyuu/plugin/libbacktest.so +0 -0
- hikyuu/plugin/libclickhousedriver.so +0 -0
- hikyuu/plugin/libdataserver.so +0 -0
- hikyuu/plugin/libdevice.so +0 -0
- hikyuu/plugin/libextind.so +0 -0
- hikyuu/plugin/libhkuextra.so +0 -0
- hikyuu/plugin/libimport2hdf5.so +0 -0
- hikyuu/plugin/libtmreport.so +0 -0
- hikyuu/setup.py +104 -0
- hikyuu/shell/__init__.py +0 -0
- hikyuu/shell/cmdserver.py +126 -0
- hikyuu/shell/hkucmd.py +110 -0
- hikyuu/shell/hkushell.py +20 -0
- hikyuu/strategy/__init__.py +2 -0
- hikyuu/strategy/strategy_demo1.py +53 -0
- hikyuu/strategy/strategy_demo2.py +47 -0
- hikyuu/strategy/strategy_demo3.py +24 -0
- hikyuu/test/AllocateFunds.py +25 -0
- hikyuu/test/Condition.py +95 -0
- hikyuu/test/Datetime.py +61 -0
- hikyuu/test/Environment.py +88 -0
- hikyuu/test/Indicator.py +233 -0
- hikyuu/test/KData.py +64 -0
- hikyuu/test/MarketInfo.py +26 -0
- hikyuu/test/MoneyManager.py +88 -0
- hikyuu/test/Parameter.py +62 -0
- hikyuu/test/ProfitGoal.py +83 -0
- hikyuu/test/Signal.py +160 -0
- hikyuu/test/Slippage.py +88 -0
- hikyuu/test/Stock.py +127 -0
- hikyuu/test/StockTypeInfo.py +47 -0
- hikyuu/test/Stoploss.py +86 -0
- hikyuu/test/TradeCost.py +71 -0
- hikyuu/test/__init__.py +0 -0
- hikyuu/test/test.py +63 -0
- hikyuu/test/test_init.py +95 -0
- hikyuu/test/test_real_tdx_import.py +336 -0
- hikyuu/test/test_tdx_import.py +315 -0
- hikyuu/test/test_tdx_real_data_import.py +281 -0
- hikyuu/tools/__init__.py +1 -0
- hikyuu/tools/copy_file.py +16 -0
- hikyuu/tools/delete_index.py +50 -0
- hikyuu/tools/fenge.py +139 -0
- hikyuu/tools/h5_data_clear.py +163 -0
- hikyuu/tools/mysql_clear_last_day_data.py +61 -0
- hikyuu/tools/update_block_info.py +168 -0
- hikyuu/trade_manage/__init__.py +30 -0
- hikyuu/trade_manage/__init__.pyi +656 -0
- hikyuu/trade_manage/broker.py +95 -0
- hikyuu/trade_manage/broker.pyi +54 -0
- hikyuu/trade_manage/broker_easytrader.py +63 -0
- hikyuu/trade_manage/broker_easytrader.pyi +21 -0
- hikyuu/trade_manage/broker_mail.py +101 -0
- hikyuu/trade_manage/broker_mail.pyi +55 -0
- hikyuu/trade_manage/trade.py +56 -0
- hikyuu/trade_manage/trade.pyi +650 -0
- hikyuu/trade_sys/__init__.py +42 -0
- hikyuu/trade_sys/trade_sys.py +252 -0
- hikyuu/util/__init__.py +51 -0
- hikyuu/util/__init__.pyi +56 -0
- hikyuu/util/check.py +161 -0
- hikyuu/util/check.pyi +63 -0
- hikyuu/util/mylog.py +291 -0
- hikyuu/util/mylog.pyi +72 -0
- hikyuu/util/notebook.py +47 -0
- hikyuu/util/notebook.pyi +23 -0
- hikyuu/util/singleton.py +29 -0
- hikyuu/util/singleton.pyi +18 -0
- hikyuu/util/slice.py +43 -0
- hikyuu/util/timeout.py +83 -0
- hikyuu-2.6.8.dist-info/METADATA +172 -0
- hikyuu-2.6.8.dist-info/RECORD +1066 -0
- hikyuu-2.6.8.dist-info/WHEEL +5 -0
- hikyuu-2.6.8.dist-info/entry_points.txt +4 -0
- hikyuu-2.6.8.dist-info/licenses/LICENSE +201 -0
- hikyuu-2.6.8.dist-info/top_level.txt +123 -0
|
@@ -0,0 +1,1620 @@
|
|
|
1
|
+
# -*- coding: utf8 -*-
|
|
2
|
+
# cp936
|
|
3
|
+
"""
|
|
4
|
+
交互模式下绘制相关图形,如K线图,美式K线图
|
|
5
|
+
"""
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
import logging
|
|
9
|
+
import numpy as np
|
|
10
|
+
import matplotlib
|
|
11
|
+
import seaborn as sns
|
|
12
|
+
import math
|
|
13
|
+
from typing import Union
|
|
14
|
+
from matplotlib.pylab import Rectangle, gca, gcf, figure, ylabel, axes, draw
|
|
15
|
+
from matplotlib import rcParams
|
|
16
|
+
from matplotlib.font_manager import FontManager, _log as fm_logger
|
|
17
|
+
from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
|
|
18
|
+
from matplotlib.ticker import FuncFormatter, FixedLocator
|
|
19
|
+
from matplotlib.image import imread
|
|
20
|
+
|
|
21
|
+
from hikyuu import *
|
|
22
|
+
from hikyuu import constant, isnan, Indicator, KData, IF
|
|
23
|
+
|
|
24
|
+
from .common import get_draw_title
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
ICON_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def set_mpl_params():
|
|
31
|
+
'''设置交互及中文环境参数'''
|
|
32
|
+
if in_interactive_session():
|
|
33
|
+
rcParams['interactive'] = True
|
|
34
|
+
|
|
35
|
+
if sys.platform == 'darwin':
|
|
36
|
+
matplotlib.rcParams['font.sans-serif'] = 'Arial Unicode MS'
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
rcParams['font.family'] = 'sans-serif'
|
|
40
|
+
rcParams['axes.unicode_minus'] = False
|
|
41
|
+
|
|
42
|
+
expected_fonts = ['Microsoft YaHei', 'SimSun', 'SimHei',
|
|
43
|
+
'Source Han Sans CN', 'Noto Sans CJK JP', 'Arial Unicode MS']
|
|
44
|
+
current_fonts = matplotlib.rcParams['font.sans-serif']
|
|
45
|
+
for font in expected_fonts:
|
|
46
|
+
if font in current_fonts:
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
with LoggingContext(fm_logger, level=logging.WARNING):
|
|
50
|
+
all_fonts = [f.name for f in FontManager().ttflist]
|
|
51
|
+
for font in expected_fonts:
|
|
52
|
+
if font in all_fonts:
|
|
53
|
+
current_fonts.insert(0, font)
|
|
54
|
+
break
|
|
55
|
+
matplotlib.rcParams['font.sans-serif'] = current_fonts
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def create_one_axes_figure(figsize=(10, 6)):
|
|
59
|
+
"""生成一个仅含有1个坐标轴的figure,并返回其坐标轴对象
|
|
60
|
+
|
|
61
|
+
:param figsize: (宽, 高)
|
|
62
|
+
:return: ax
|
|
63
|
+
"""
|
|
64
|
+
rect1 = [0.05, 0.05, 0.9, 0.90]
|
|
65
|
+
fg = figure(figsize=figsize)
|
|
66
|
+
ax1 = fg.add_axes(rect1)
|
|
67
|
+
return ax1
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def create_two_axes_figure(figsize=(10, 8)):
|
|
71
|
+
"""生成一个含有2个坐标轴的figure,并返回坐标轴列表
|
|
72
|
+
|
|
73
|
+
:param figsize: (宽, 高)
|
|
74
|
+
:return: (ax1, ax2)
|
|
75
|
+
"""
|
|
76
|
+
rect1 = [0.05, 0.35, 0.9, 0.60]
|
|
77
|
+
rect2 = [0.05, 0.05, 0.9, 0.30]
|
|
78
|
+
|
|
79
|
+
fg = figure(figsize=figsize)
|
|
80
|
+
ax1 = fg.add_axes(rect1)
|
|
81
|
+
ax2 = fg.add_axes(rect2, sharex=ax1)
|
|
82
|
+
|
|
83
|
+
return ax1, ax2
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def create_three_axes_figure(figsize=(10, 8)):
|
|
87
|
+
"""生成一个含有3个坐标轴的figure,并返回坐标轴列表
|
|
88
|
+
|
|
89
|
+
:param figsize: (宽, 高)
|
|
90
|
+
:return: (ax1, ax2, ax3)
|
|
91
|
+
"""
|
|
92
|
+
rect1 = [0.05, 0.45, 0.9, 0.50]
|
|
93
|
+
rect2 = [0.05, 0.25, 0.9, 0.20]
|
|
94
|
+
rect3 = [0.05, 0.05, 0.9, 0.20]
|
|
95
|
+
|
|
96
|
+
fg = figure(figsize=figsize)
|
|
97
|
+
ax1 = fg.add_axes(rect1)
|
|
98
|
+
ax2 = fg.add_axes(rect2, sharex=ax1)
|
|
99
|
+
ax3 = fg.add_axes(rect3, sharex=ax1)
|
|
100
|
+
|
|
101
|
+
return ax1, ax2, ax3
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def create_four_axes_figure(figsize=(10, 8)):
|
|
105
|
+
"""生成一个含有4个坐标轴的figure,并返回坐标轴列表
|
|
106
|
+
|
|
107
|
+
:param figsize: (宽, 高)
|
|
108
|
+
:return: (ax1, ax2, ax3, ax4)
|
|
109
|
+
"""
|
|
110
|
+
rect1 = [0.05, 0.50, 0.9, 0.45]
|
|
111
|
+
rect2 = [0.05, 0.35, 0.9, 0.15]
|
|
112
|
+
rect3 = [0.05, 0.20, 0.9, 0.15]
|
|
113
|
+
rect4 = [0.05, 0.05, 0.9, 0.15]
|
|
114
|
+
|
|
115
|
+
fg = figure(figsize=figsize)
|
|
116
|
+
ax1 = fg.add_axes(rect1)
|
|
117
|
+
ax2 = fg.add_axes(rect2, sharex=ax1)
|
|
118
|
+
ax3 = fg.add_axes(rect3, sharex=ax1)
|
|
119
|
+
ax4 = fg.add_axes(rect4, sharex=ax1)
|
|
120
|
+
|
|
121
|
+
return ax1, ax2, ax3, ax4
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def create_figure(n=1, figsize=(10, 8)):
|
|
125
|
+
"""生成含有指定坐标轴数量的窗口,最大只支持4个坐标轴。
|
|
126
|
+
|
|
127
|
+
:param int n: 坐标轴数量
|
|
128
|
+
:param figsize: (宽, 高)
|
|
129
|
+
:return: (ax1, ax2, ...) 根据指定的坐标轴数量而定,超出[1,4]个坐标轴时,返回None
|
|
130
|
+
"""
|
|
131
|
+
if n == 1:
|
|
132
|
+
return create_one_axes_figure(figsize)
|
|
133
|
+
elif n == 2:
|
|
134
|
+
return create_two_axes_figure(figsize)
|
|
135
|
+
elif n == 3:
|
|
136
|
+
return create_three_axes_figure(figsize)
|
|
137
|
+
elif n == 4:
|
|
138
|
+
return create_four_axes_figure(figsize)
|
|
139
|
+
else:
|
|
140
|
+
print("Max support axes number is 4!")
|
|
141
|
+
return None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class StockFuncFormatter(object):
|
|
145
|
+
"""用于坐标轴显示日期
|
|
146
|
+
关于matplotlib中FuncFormatter的使用方法,请参见:
|
|
147
|
+
http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
def __init__(self, ix2date):
|
|
151
|
+
self.__ix2date = ix2date
|
|
152
|
+
|
|
153
|
+
def __call__(self, x, pos=None): # IGNORE:W0613
|
|
154
|
+
result = ''
|
|
155
|
+
ix = int(x)
|
|
156
|
+
if ix in self.__ix2date:
|
|
157
|
+
result = self.__ix2date[ix]
|
|
158
|
+
return result
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def getDayLocatorAndFormatter(dates):
|
|
162
|
+
"""获取显示日线时使用的Major Locator和Major Formatter"""
|
|
163
|
+
sep = int(len(dates) / 10)
|
|
164
|
+
loc = [
|
|
165
|
+
(i, str(d) if (i != (len(dates) - 1)) and (i % sep != 0) else "{}-{}-{}".format(d.year, d.month, d.day))
|
|
166
|
+
for i, d in enumerate(dates)
|
|
167
|
+
]
|
|
168
|
+
fixed_loc = [i for i in range(len(dates)) if (i == (len(dates) - 1)) or (i != 0 and i % sep == 0)]
|
|
169
|
+
|
|
170
|
+
month_loc = FixedLocator(fixed_loc)
|
|
171
|
+
month_fm = FuncFormatter(StockFuncFormatter(dict(loc)))
|
|
172
|
+
return month_loc, month_fm
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def getMinLocatorAndFormatter(dates):
|
|
176
|
+
"""获取显示分钟线时使用的Major Locator和Major Formatter"""
|
|
177
|
+
sep = len(dates) / 5
|
|
178
|
+
loc = [
|
|
179
|
+
(i, str(d) if i % sep != 0 else "{}-{}-{} {}:{}".format(d.year, d.month, d.day, d.hour, d.minute))
|
|
180
|
+
for i, d in enumerate(dates)
|
|
181
|
+
]
|
|
182
|
+
fixed_loc = [i for i in range(len(dates)) if i != 0 and i % sep == 0]
|
|
183
|
+
|
|
184
|
+
month_loc = FixedLocator(fixed_loc)
|
|
185
|
+
month_fm = FuncFormatter(StockFuncFormatter(dict(loc)))
|
|
186
|
+
return month_loc, month_fm
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def ax_set_locator_formatter(axes, dates, typ):
|
|
190
|
+
""" 设置指定坐标轴的日期显示,根据指定的K线类型优化X轴坐标显示
|
|
191
|
+
|
|
192
|
+
:param axes: 指定的坐标轴
|
|
193
|
+
:param dates: Datetime构成可迭代序列
|
|
194
|
+
:param Query.KType typ: K线类型
|
|
195
|
+
"""
|
|
196
|
+
major_loc, major_fm = None, None
|
|
197
|
+
if typ == Query.DAY:
|
|
198
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
199
|
+
elif typ == Query.WEEK:
|
|
200
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
201
|
+
elif typ == Query.MONTH:
|
|
202
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
203
|
+
elif typ == Query.QUARTER:
|
|
204
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
205
|
+
elif typ == Query.HALFYEAR:
|
|
206
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
207
|
+
elif typ == Query.YEAR:
|
|
208
|
+
major_loc, major_fm = getDayLocatorAndFormatter(dates)
|
|
209
|
+
else:
|
|
210
|
+
major_loc, major_fm = getMinLocatorAndFormatter(dates)
|
|
211
|
+
|
|
212
|
+
axes.xaxis.set_major_locator(major_loc)
|
|
213
|
+
axes.xaxis.set_major_formatter(major_fm)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def adjust_axes_show(axeslist):
|
|
217
|
+
"""用于调整上下紧密相连的坐标轴显示时,其上一坐标轴最小值刻度和下一坐标轴最大值刻度
|
|
218
|
+
显示重叠的问题。
|
|
219
|
+
|
|
220
|
+
:param axeslist: 上下相连的坐标轴列表 (ax1,ax2,...)
|
|
221
|
+
"""
|
|
222
|
+
for ax in axeslist[:-1]:
|
|
223
|
+
for label in ax.get_xticklabels():
|
|
224
|
+
label.set_visible(False)
|
|
225
|
+
ylabels = ax.get_yticklabels()
|
|
226
|
+
ylabels[0].set_visible(False)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def kplot(kdata, new=True, axes=None, colorup='r', colordown='g'):
|
|
230
|
+
"""绘制K线图
|
|
231
|
+
|
|
232
|
+
:param KData kdata: K线数据
|
|
233
|
+
:param bool new: 是否在新窗口中显示,只在没有指定axes时生效
|
|
234
|
+
:param axes: 指定的坐标轴
|
|
235
|
+
:param colorup: the color of the rectangle where close >= open
|
|
236
|
+
:param colordown: the color of the rectangle where close < open
|
|
237
|
+
"""
|
|
238
|
+
if not kdata:
|
|
239
|
+
print("kdata is None")
|
|
240
|
+
return
|
|
241
|
+
|
|
242
|
+
if not axes:
|
|
243
|
+
axes = create_figure() if new else gca()
|
|
244
|
+
|
|
245
|
+
alpha = 1.0
|
|
246
|
+
width = 0.6
|
|
247
|
+
OFFSET = width / 2.0
|
|
248
|
+
rfcolor = matplotlib.rcParams['axes.facecolor']
|
|
249
|
+
for i in range(len(kdata)):
|
|
250
|
+
record = kdata[i]
|
|
251
|
+
open, high, low, close = record.open, record.high, record.low, record.close
|
|
252
|
+
if close >= open:
|
|
253
|
+
color = colorup
|
|
254
|
+
lower = open
|
|
255
|
+
height = close - open
|
|
256
|
+
rect = Rectangle(xy=(i - OFFSET, lower), width=width, height=height, facecolor=rfcolor, edgecolor=color)
|
|
257
|
+
else:
|
|
258
|
+
color = colordown
|
|
259
|
+
lower = close
|
|
260
|
+
height = open - close
|
|
261
|
+
rect = Rectangle(xy=(i - OFFSET, lower), width=width, height=height, facecolor=color, edgecolor=color)
|
|
262
|
+
|
|
263
|
+
vline1 = Line2D(xdata=(i, i), ydata=(low, lower), color=color, linewidth=0.5, antialiased=True)
|
|
264
|
+
vline2 = Line2D(xdata=(i, i), ydata=(lower + height, high), color=color, linewidth=0.5, antialiased=True)
|
|
265
|
+
rect.set_alpha(alpha)
|
|
266
|
+
|
|
267
|
+
axes.add_line(vline1)
|
|
268
|
+
axes.add_line(vline2)
|
|
269
|
+
axes.add_patch(rect)
|
|
270
|
+
|
|
271
|
+
title = get_draw_title(kdata)
|
|
272
|
+
axes.set_title(title)
|
|
273
|
+
last_record = kdata[-1]
|
|
274
|
+
color = 'r' if last_record.close > kdata[-2].close else 'g'
|
|
275
|
+
text = u'%s 开:%.2f 高:%.2f 低:%.2f 收:%.2f 涨幅:%.2f%%' % (
|
|
276
|
+
last_record.datetime.number / 10000, last_record.open, last_record.high, last_record.low, last_record.close,
|
|
277
|
+
100 * (last_record.close - kdata[-2].close) / kdata[-2].close
|
|
278
|
+
)
|
|
279
|
+
axes.text(
|
|
280
|
+
0.99, 0.97, text, horizontalalignment='right', verticalalignment='top', transform=axes.transAxes, color=color
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
axes.autoscale_view()
|
|
284
|
+
axes.set_xlim(-1, len(kdata) + 1)
|
|
285
|
+
ax_set_locator_formatter(axes, kdata.get_datetime_list(), kdata.get_query().ktype)
|
|
286
|
+
# draw()
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def mkplot(kdata, new=True, axes=None, colorup='r', colordown='g', ticksize=3):
|
|
290
|
+
"""绘制美式K线图
|
|
291
|
+
|
|
292
|
+
:param KData kdata: K线数据
|
|
293
|
+
:param bool new: 是否在新窗口中显示,只在没有指定axes时生效
|
|
294
|
+
:param axes: 指定的坐标轴
|
|
295
|
+
:param colorup: the color of the lines where close >= open
|
|
296
|
+
:param colordown: the color of the lines where close < open
|
|
297
|
+
:param ticksize: open/close tick marker in points
|
|
298
|
+
"""
|
|
299
|
+
if not kdata:
|
|
300
|
+
print("kdata is None")
|
|
301
|
+
return
|
|
302
|
+
|
|
303
|
+
if not axes:
|
|
304
|
+
axes = create_figure() if new else gca()
|
|
305
|
+
|
|
306
|
+
for t in range(len(kdata)):
|
|
307
|
+
record = kdata[t]
|
|
308
|
+
open, high, low, close = record.open, record.high, record.low, record.close
|
|
309
|
+
color = colorup if close >= open else colordown
|
|
310
|
+
|
|
311
|
+
vline = Line2D(xdata=(t, t), ydata=(low, high), color=color, antialiased=False)
|
|
312
|
+
oline = Line2D(
|
|
313
|
+
xdata=(t, t), ydata=(open, open), color=color, antialiased=False, marker=TICKLEFT, markersize=ticksize
|
|
314
|
+
)
|
|
315
|
+
cline = Line2D(
|
|
316
|
+
xdata=(t, t), ydata=(close, close), color=color, antialiased=False, markersize=ticksize, marker=TICKRIGHT
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
axes.add_line(vline)
|
|
320
|
+
axes.add_line(oline)
|
|
321
|
+
axes.add_line(cline)
|
|
322
|
+
|
|
323
|
+
title = get_draw_title(kdata)
|
|
324
|
+
axes.set_title(title)
|
|
325
|
+
last_record = kdata[-1]
|
|
326
|
+
color = 'r' if last_record.close > kdata[-2].close else 'g'
|
|
327
|
+
text = u'%s 开:%.2f 高:%.2f 低:%.2f 收:%.2f' % (
|
|
328
|
+
last_record.datetime.number / 10000, last_record.open, last_record.high, last_record.low, last_record.close
|
|
329
|
+
)
|
|
330
|
+
axes.text(
|
|
331
|
+
0.99, 0.97, text, horizontalalignment='right', verticalalignment='top', transform=axes.transAxes, color=color
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
axes.autoscale_view()
|
|
335
|
+
axes.set_xlim(-1, len(kdata) + 1)
|
|
336
|
+
ax_set_locator_formatter(axes, kdata.get_datetime_list(), kdata.get_query().ktype)
|
|
337
|
+
# draw()
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def iplot(
|
|
341
|
+
indicator,
|
|
342
|
+
new=True,
|
|
343
|
+
axes=None,
|
|
344
|
+
kref=None,
|
|
345
|
+
legend_on=False,
|
|
346
|
+
text_on=False,
|
|
347
|
+
text_color='k',
|
|
348
|
+
zero_on=False,
|
|
349
|
+
label=None,
|
|
350
|
+
linestyle='-',
|
|
351
|
+
*args,
|
|
352
|
+
**kwargs
|
|
353
|
+
):
|
|
354
|
+
"""绘制indicator曲线
|
|
355
|
+
|
|
356
|
+
:param Indicator indicator: indicator实例
|
|
357
|
+
:param axes: 指定的坐标轴
|
|
358
|
+
:param new: 是否在新窗口中显示,只在没有指定axes时生效
|
|
359
|
+
:param kref: 参考的K线数据,以便绘制日期X坐标
|
|
360
|
+
:param legend_on: 是否打开图例
|
|
361
|
+
:param text_on: 是否在左上角显示指标名称及其参数
|
|
362
|
+
:param text_color: 指标名称解释文字的颜色,默认为黑色
|
|
363
|
+
:param zero_on: 是否需要在y=0轴上绘制一条直线
|
|
364
|
+
:param str label: label显示文字信息,text_on 及 legend_on 为 True 时生效
|
|
365
|
+
:param args: pylab plot参数
|
|
366
|
+
:param kwargs: pylab plot参数,如:marker(标记类型)、
|
|
367
|
+
markerfacecolor(标记颜色)、
|
|
368
|
+
markeredgecolor(标记的边缘颜色)
|
|
369
|
+
"""
|
|
370
|
+
if not indicator:
|
|
371
|
+
print("indicator is None")
|
|
372
|
+
return
|
|
373
|
+
|
|
374
|
+
if not axes:
|
|
375
|
+
axes = create_figure() if new else gca()
|
|
376
|
+
|
|
377
|
+
if not label:
|
|
378
|
+
label = "%s %.2f" % (indicator.long_name, indicator[-1])
|
|
379
|
+
|
|
380
|
+
py_indicatr = [None if x == constant.null_price else x for x in indicator]
|
|
381
|
+
axes.plot(py_indicatr, linestyle=linestyle, label=label, *args, **kwargs)
|
|
382
|
+
|
|
383
|
+
if legend_on:
|
|
384
|
+
leg = axes.legend(loc='upper left')
|
|
385
|
+
leg.get_frame().set_alpha(0.5)
|
|
386
|
+
|
|
387
|
+
if text_on:
|
|
388
|
+
if not axes.texts:
|
|
389
|
+
axes.text(
|
|
390
|
+
0.01,
|
|
391
|
+
0.97,
|
|
392
|
+
label,
|
|
393
|
+
horizontalalignment='left',
|
|
394
|
+
verticalalignment='top',
|
|
395
|
+
transform=axes.transAxes,
|
|
396
|
+
color=text_color
|
|
397
|
+
)
|
|
398
|
+
else:
|
|
399
|
+
temp_str = axes.texts[0].get_text() + ' ' + label
|
|
400
|
+
axes.texts[0].set_text(temp_str)
|
|
401
|
+
|
|
402
|
+
if zero_on:
|
|
403
|
+
ylim = axes.get_ylim()
|
|
404
|
+
if ylim[0] < 0 < ylim[1]:
|
|
405
|
+
axes.hlines(0, 0, len(indicator))
|
|
406
|
+
|
|
407
|
+
axes.autoscale_view()
|
|
408
|
+
axes.set_xlim(-1, len(indicator) + 1)
|
|
409
|
+
if kref:
|
|
410
|
+
ax_set_locator_formatter(axes, kref.get_datetime_list(), kref.get_query().ktype)
|
|
411
|
+
else:
|
|
412
|
+
k = indicator.get_context()
|
|
413
|
+
if len(k) > 0:
|
|
414
|
+
ax_set_locator_formatter(axes, k.get_datetime_list(), k.get_query().ktype)
|
|
415
|
+
# draw()
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def ibar(
|
|
419
|
+
indicator,
|
|
420
|
+
new=True,
|
|
421
|
+
axes=None,
|
|
422
|
+
kref=None,
|
|
423
|
+
legend_on=False,
|
|
424
|
+
text_on=False,
|
|
425
|
+
text_color='k',
|
|
426
|
+
label=None,
|
|
427
|
+
width=0.4,
|
|
428
|
+
color='r',
|
|
429
|
+
edgecolor='r',
|
|
430
|
+
zero_on=False,
|
|
431
|
+
*args,
|
|
432
|
+
**kwargs
|
|
433
|
+
):
|
|
434
|
+
"""绘制indicator柱状图
|
|
435
|
+
|
|
436
|
+
:param Indicator indicator: Indicator实例
|
|
437
|
+
:param axes: 指定的坐标轴
|
|
438
|
+
:param new: 是否在新窗口中显示,只在没有指定axes时生效
|
|
439
|
+
:param kref: 参考的K线数据,以便绘制日期X坐标
|
|
440
|
+
:param legend_on: 是否打开图例
|
|
441
|
+
:param text_on: 是否在左上角显示指标名称及其参数
|
|
442
|
+
:param text_color: 指标名称解释文字的颜色,默认为黑色
|
|
443
|
+
:param str label: label显示文字信息,text_on 及 legend_on 为 True 时生效
|
|
444
|
+
:param zero_on: 是否需要在y=0轴上绘制一条直线
|
|
445
|
+
:param width: Bar的宽度
|
|
446
|
+
:param color: Bar的颜色
|
|
447
|
+
:param edgecolor: Bar边缘颜色
|
|
448
|
+
:param args: pylab plot参数
|
|
449
|
+
:param kwargs: pylab plot参数
|
|
450
|
+
"""
|
|
451
|
+
if not indicator:
|
|
452
|
+
print("indicator is None")
|
|
453
|
+
return
|
|
454
|
+
|
|
455
|
+
if not axes:
|
|
456
|
+
axes = create_figure() if new else gca()
|
|
457
|
+
|
|
458
|
+
if not label:
|
|
459
|
+
label = "%s %.2f" % (indicator.long_name, indicator[-1])
|
|
460
|
+
|
|
461
|
+
py_indicatr = [None if x == constant.null_price else x for x in indicator]
|
|
462
|
+
x = [i - 0.2 for i in range(len(indicator))]
|
|
463
|
+
y = py_indicatr
|
|
464
|
+
|
|
465
|
+
axes.bar(x, py_indicatr, width=width, color=color, edgecolor=edgecolor, *args, **kwargs)
|
|
466
|
+
|
|
467
|
+
if legend_on:
|
|
468
|
+
leg = axes.legend(loc='upper left')
|
|
469
|
+
leg.get_frame().set_alpha(0.5)
|
|
470
|
+
|
|
471
|
+
if text_on:
|
|
472
|
+
if not axes.texts:
|
|
473
|
+
axes.text(
|
|
474
|
+
0.01,
|
|
475
|
+
0.97,
|
|
476
|
+
label,
|
|
477
|
+
horizontalalignment='left',
|
|
478
|
+
verticalalignment='top',
|
|
479
|
+
transform=axes.transAxes,
|
|
480
|
+
color=text_color
|
|
481
|
+
)
|
|
482
|
+
else:
|
|
483
|
+
temp_str = axes.texts[0].get_text() + ' ' + label
|
|
484
|
+
axes.texts[0].set_text(temp_str)
|
|
485
|
+
|
|
486
|
+
if zero_on:
|
|
487
|
+
ylim = axes.get_ylim()
|
|
488
|
+
if ylim[0] < 0 < ylim[1]:
|
|
489
|
+
axes.hlines(0, 0, len(indicator))
|
|
490
|
+
|
|
491
|
+
axes.autoscale_view()
|
|
492
|
+
axes.set_xlim(-1, len(indicator) + 1)
|
|
493
|
+
if kref:
|
|
494
|
+
ax_set_locator_formatter(axes, kref.get_datetime_list(), kref.get_query().ktype)
|
|
495
|
+
else:
|
|
496
|
+
k = indicator.get_context()
|
|
497
|
+
if len(k) > 0:
|
|
498
|
+
ax_set_locator_formatter(axes, k.get_datetime_list(), k.get_query().ktype)
|
|
499
|
+
# draw()
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def iheatmap(ind, axes=None):
|
|
503
|
+
"""
|
|
504
|
+
绘制指标收益年-月收益热力图
|
|
505
|
+
|
|
506
|
+
指标收益率 = (当前月末值 - 上月末值) / 上月末值 * 100
|
|
507
|
+
|
|
508
|
+
指标应已计算(即有值),且为时间序列
|
|
509
|
+
|
|
510
|
+
:param ind: 指定指标
|
|
511
|
+
:param axes: 绘制的轴对象,默认为None,表示创建新的轴对象
|
|
512
|
+
:return: None
|
|
513
|
+
"""
|
|
514
|
+
if axes is None:
|
|
515
|
+
axes = create_figure()
|
|
516
|
+
|
|
517
|
+
if len(ind) == 0:
|
|
518
|
+
hku_error("指标长度为0, 指标应已计算(即有值")
|
|
519
|
+
return
|
|
520
|
+
|
|
521
|
+
dates = ind.get_datetime_list()
|
|
522
|
+
if len(dates) == 0:
|
|
523
|
+
hku_error("获取日期列表失败!指标应为时间序列")
|
|
524
|
+
return
|
|
525
|
+
|
|
526
|
+
data = pd.DataFrame({'date': dates, 'value': ind.value_to_np()})
|
|
527
|
+
data = data[(data[['value']] != 0).all(axis=1)]
|
|
528
|
+
|
|
529
|
+
# 提取年月信息
|
|
530
|
+
data['year'] = data['date'].apply(lambda v: v.year)
|
|
531
|
+
data['month'] = data['date'].apply(lambda v: v.month)
|
|
532
|
+
|
|
533
|
+
# 获取每个月的收益
|
|
534
|
+
monthly = data.groupby(['year', 'month']).last()['value'].reset_index()
|
|
535
|
+
if len(monthly) < 2:
|
|
536
|
+
hku_warn("月数据不足!")
|
|
537
|
+
return
|
|
538
|
+
|
|
539
|
+
monthly['return'] = ((monthly['value'] - monthly['value'].shift(1)) / monthly['value'].shift(1)) * 100.
|
|
540
|
+
|
|
541
|
+
pivot_data = monthly.pivot_table(index='year', columns='month', values='return')
|
|
542
|
+
|
|
543
|
+
sns.heatmap(pivot_data, cmap='RdYlGn_r', center=0, annot=True, fmt="<.2f", ax=axes)
|
|
544
|
+
# 设置标题和坐标轴标签
|
|
545
|
+
axes.set_title('年-月度收益率(%)热力图')
|
|
546
|
+
axes.set_xlabel('月度')
|
|
547
|
+
axes.set_ylabel('年份')
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def ax_draw_macd(axes, kdata, n1=12, n2=26, n3=9):
|
|
551
|
+
"""绘制MACD
|
|
552
|
+
|
|
553
|
+
:param axes: 指定的坐标轴
|
|
554
|
+
:param KData kdata: KData
|
|
555
|
+
:param int n1: 指标 MACD 的参数1
|
|
556
|
+
:param int n2: 指标 MACD 的参数2
|
|
557
|
+
:param int n3: 指标 MACD 的参数3
|
|
558
|
+
"""
|
|
559
|
+
macd = MACD(CLOSE(kdata), n1, n2, n3)
|
|
560
|
+
bmacd, fmacd, smacd = macd.get_result(0), macd.get_result(1), macd.get_result(2)
|
|
561
|
+
|
|
562
|
+
text = 'MACD(%s,%s,%s) DIF:%.2f, DEA:%.2f, BAR:%.2f' % (n1, n2, n3, fmacd[-1], smacd[-1], bmacd[-1])
|
|
563
|
+
axes.text(0.01, 0.97, text, horizontalalignment='left', verticalalignment='top', transform=axes.transAxes)
|
|
564
|
+
total = len(kdata)
|
|
565
|
+
x = [i - 0.2 for i in range(total)]
|
|
566
|
+
x1 = [x[i] for i, d in enumerate(bmacd) if d > 0]
|
|
567
|
+
y1 = [i for i in bmacd if i > 0]
|
|
568
|
+
x2 = [x[i] for i, d in enumerate(bmacd) if d <= 0]
|
|
569
|
+
y2 = [i for i in bmacd if i <= 0]
|
|
570
|
+
axes.bar(x1, y1, width=0.4, color='r', edgecolor='r')
|
|
571
|
+
axes.bar(x2, y2, width=0.4, color='g', edgecolor='g')
|
|
572
|
+
|
|
573
|
+
axt = axes.twinx()
|
|
574
|
+
axt.grid(False)
|
|
575
|
+
axt.set_yticks([])
|
|
576
|
+
|
|
577
|
+
# 计算MACD柱和DIF/DEA的y轴极值,并对齐
|
|
578
|
+
y_all = np.concatenate([np.asarray(bmacd), np.asarray(fmacd), np.asarray(smacd)])
|
|
579
|
+
y_min = np.nanmin(y_all)
|
|
580
|
+
y_max = np.nanmax(y_all)
|
|
581
|
+
y_pad = (y_max - y_min) * 0.1 # 上下各留10%空白
|
|
582
|
+
y_min -= y_pad
|
|
583
|
+
y_max += y_pad
|
|
584
|
+
axes.set_ylim(y_min, y_max) # 设置MACD柱y轴范围
|
|
585
|
+
axt.set_ylim(y_min, y_max) # 设置DIF/DEA的y轴范围
|
|
586
|
+
|
|
587
|
+
fmacd.plot(axes=axt, linestyle='--', legend_on=False, text_on=False)
|
|
588
|
+
smacd.plot(axes=axt, legend_on=False, text_on=False)
|
|
589
|
+
|
|
590
|
+
for label in axt.get_xticklabels():
|
|
591
|
+
label.set_visible(False)
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
def ax_draw_macd2(axes, ref, kdata, n1=12, n2=26, n3=9):
|
|
595
|
+
"""绘制MACD。
|
|
596
|
+
当BAR值变化与参考序列ref变化不一致时,显示为灰色,
|
|
597
|
+
当BAR和参考序列ref同时上涨,显示红色
|
|
598
|
+
当BAR和参考序列ref同时下跌,显示绿色
|
|
599
|
+
|
|
600
|
+
:param axes: 指定的坐标轴
|
|
601
|
+
:param ref: 参考序列,EMA
|
|
602
|
+
:param KData kdata: KData
|
|
603
|
+
:param int n1: 指标 MACD 的参数1
|
|
604
|
+
:param int n2: 指标 MACD 的参数2
|
|
605
|
+
:param int n3: 指标 MACD 的参数3
|
|
606
|
+
"""
|
|
607
|
+
macd = MACD(CLOSE(kdata), n1, n2, n3)
|
|
608
|
+
bmacd, fmacd, smacd = macd.get_result(0), macd.get_result(1), macd.get_result(2)
|
|
609
|
+
|
|
610
|
+
text = 'MACD(%s,%s,%s) DIF:%.2f, DEA:%.2f, BAR:%.2f' % (n1, n2, n3, fmacd[-1], smacd[-1], bmacd[-1])
|
|
611
|
+
axes.text(0.01, 0.97, text, horizontalalignment='left', verticalalignment='top', transform=axes.transAxes)
|
|
612
|
+
total = len(kdata)
|
|
613
|
+
x = [i - 0.2 for i in range(0, total)]
|
|
614
|
+
y = bmacd
|
|
615
|
+
x1, x2, x3 = [x[0]], [], []
|
|
616
|
+
y1, y2, y3 = [y[0]], [], []
|
|
617
|
+
for i in range(1, total):
|
|
618
|
+
if ref[i] - ref[i - 1] > 0 and y[i] - y[i - 1] > 0:
|
|
619
|
+
x2.append(x[i])
|
|
620
|
+
y2.append(y[i])
|
|
621
|
+
elif ref[i] - ref[i - 1] < 0 and y[i] - y[i - 1] < 0:
|
|
622
|
+
x3.append(x[i])
|
|
623
|
+
y3.append(y[i])
|
|
624
|
+
else:
|
|
625
|
+
x1.append(x[i])
|
|
626
|
+
y1.append(y[i])
|
|
627
|
+
|
|
628
|
+
axes.bar(x1, y1, width=0.4, color='#BFBFBF', edgecolor='#BFBFBF')
|
|
629
|
+
axes.bar(x2, y2, width=0.4, color='r', edgecolor='r')
|
|
630
|
+
axes.bar(x3, y3, width=0.4, color='g', edgecolor='g')
|
|
631
|
+
|
|
632
|
+
axt = axes.twinx()
|
|
633
|
+
axt.grid(False)
|
|
634
|
+
axt.set_yticks([])
|
|
635
|
+
|
|
636
|
+
# 计算MACD柱和DIF/DEA的y轴极值,并对齐
|
|
637
|
+
y_all = np.concatenate([np.asarray(bmacd), np.asarray(fmacd), np.asarray(smacd)])
|
|
638
|
+
y_min = np.nanmin(y_all)
|
|
639
|
+
y_max = np.nanmax(y_all)
|
|
640
|
+
y_pad = (y_max - y_min) * 0.1 # 上下各留10%空白
|
|
641
|
+
y_min -= y_pad
|
|
642
|
+
y_max += y_pad
|
|
643
|
+
axes.set_ylim(y_min, y_max) # 设置MACD柱y轴范围
|
|
644
|
+
axt.set_ylim(y_min, y_max) # 设置DIF/DEA的y轴范围
|
|
645
|
+
|
|
646
|
+
fmacd.plot(axes=axt, linestyle='--', legend_on=False, text_on=False)
|
|
647
|
+
smacd.plot(axes=axt, legend_on=False, text_on=False)
|
|
648
|
+
|
|
649
|
+
for label in axt.get_xticklabels():
|
|
650
|
+
label.set_visible(False)
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def sgplot(sg, new=True, axes=None, style=1, kdata=None):
|
|
654
|
+
"""绘制买入/卖出信号
|
|
655
|
+
|
|
656
|
+
:param SignalBase sg: 信号指示器
|
|
657
|
+
:param new: 仅在未指定axes的情况下生效,当为True时,创建新的窗口对象并在其中进行绘制
|
|
658
|
+
:param axes: 指定在那个轴对象中进行绘制
|
|
659
|
+
:param style: 1 | 2 信号箭头绘制样式
|
|
660
|
+
:param KData kdata: 指定的KData(即信号发生器的交易对象),
|
|
661
|
+
如该值为None,则认为该信号发生器已经指定了交易对象,
|
|
662
|
+
否则,使用该参数作为交易对象
|
|
663
|
+
"""
|
|
664
|
+
kdata = sg.to if kdata is None else kdata
|
|
665
|
+
refdates = kdata.get_datetime_list()
|
|
666
|
+
date_index = dict([(d, i) for i, d in enumerate(refdates)])
|
|
667
|
+
|
|
668
|
+
if axes is None:
|
|
669
|
+
if new:
|
|
670
|
+
axes = create_figure()
|
|
671
|
+
kplot(kdata, axes=axes)
|
|
672
|
+
else:
|
|
673
|
+
axes = gca()
|
|
674
|
+
|
|
675
|
+
ylim = axes.get_ylim()
|
|
676
|
+
height = ylim[1] - ylim[0]
|
|
677
|
+
|
|
678
|
+
if style == 1:
|
|
679
|
+
arrow_buy = dict(arrowstyle="->")
|
|
680
|
+
arrow_sell = arrow_buy
|
|
681
|
+
else:
|
|
682
|
+
arrow_buy = dict(facecolor='red', frac=0.5)
|
|
683
|
+
arrow_sell = dict(facecolor='blue', frac=0.5)
|
|
684
|
+
|
|
685
|
+
dates = sg.get_buy_signal()
|
|
686
|
+
for d in dates:
|
|
687
|
+
if d not in date_index:
|
|
688
|
+
continue
|
|
689
|
+
pos = date_index[d]
|
|
690
|
+
krecord = kdata[pos]
|
|
691
|
+
axes.annotate(
|
|
692
|
+
'B', (pos, krecord.low - height * 0.01), (pos, krecord.low - height * 0.1),
|
|
693
|
+
arrowprops=arrow_buy,
|
|
694
|
+
horizontalalignment='center',
|
|
695
|
+
verticalalignment='bottom',
|
|
696
|
+
color='red'
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
dates = sg.get_sell_signal()
|
|
700
|
+
for d in dates:
|
|
701
|
+
if d not in date_index:
|
|
702
|
+
continue
|
|
703
|
+
pos = date_index[d]
|
|
704
|
+
krecord = kdata[pos]
|
|
705
|
+
axes.annotate(
|
|
706
|
+
'S', (pos, krecord.high + height * 0.01), (pos, krecord.high + height * 0.1),
|
|
707
|
+
arrowprops=arrow_sell,
|
|
708
|
+
horizontalalignment='center',
|
|
709
|
+
verticalalignment='top',
|
|
710
|
+
color='blue'
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
def evplot(ev, ref_kdata, new=True, axes=None, upcolor='red', downcolor='blue', alpha=0.2):
|
|
715
|
+
"""绘制市场有效判断
|
|
716
|
+
|
|
717
|
+
:param EnvironmentBase cn: 系统有效条件
|
|
718
|
+
:param KData ref_kdata: 用于日期参考
|
|
719
|
+
:param new: 仅在未指定axes的情况下生效,当为True时,创建新的窗口对象并在其中进行绘制
|
|
720
|
+
:param axes: 指定在那个轴对象中进行绘制
|
|
721
|
+
:param upcolor: 有效时的颜色
|
|
722
|
+
:param downcolor: 无效时的颜色
|
|
723
|
+
:param alpha: 透明度
|
|
724
|
+
"""
|
|
725
|
+
refdates = ref_kdata.get_datetime_list()
|
|
726
|
+
if axes is None:
|
|
727
|
+
if new:
|
|
728
|
+
axes = create_figure(2)
|
|
729
|
+
kplot(ref_kdata, axes=axes[0])
|
|
730
|
+
axes = axes[1]
|
|
731
|
+
else:
|
|
732
|
+
axes = gca()
|
|
733
|
+
|
|
734
|
+
x = np.array([i for i in range(len(refdates))])
|
|
735
|
+
y1 = np.array([1 if ev.is_valid(d) else -1 for d in refdates])
|
|
736
|
+
y2 = np.array([-1 if ev.is_valid(d) else 1 for d in refdates])
|
|
737
|
+
axes.fill_between(x, y1, y2, where=y2 > y1, facecolor=downcolor, alpha=alpha)
|
|
738
|
+
axes.fill_between(x, y1, y2, where=y2 < y1, facecolor=upcolor, alpha=alpha)
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def cnplot(cn, new=True, axes=None, kdata=None, upcolor='red', downcolor='blue', alpha=0.2):
|
|
742
|
+
"""绘制系统有效条件
|
|
743
|
+
|
|
744
|
+
:param ConditionBase cn: 系统有效条件
|
|
745
|
+
:param new: 仅在未指定axes的情况下生效,当为True时,创建新的窗口对象并在其中进行绘制
|
|
746
|
+
:param axes: 指定在那个轴对象中进行绘制
|
|
747
|
+
:param KData kdata: 指定的KData,如该值为None,则认为该系统有效条件已经
|
|
748
|
+
指定了交易对象,否则,使用该参数作为交易对象
|
|
749
|
+
:param upcolor: 有效数时的颜色
|
|
750
|
+
:param downcolor: 无效时的颜色
|
|
751
|
+
:param alpha: 透明度
|
|
752
|
+
"""
|
|
753
|
+
if kdata is None:
|
|
754
|
+
kdata = cn.to
|
|
755
|
+
else:
|
|
756
|
+
cn.to = kdata
|
|
757
|
+
|
|
758
|
+
refdates = kdata.get_datetime_list()
|
|
759
|
+
if axes is None:
|
|
760
|
+
if new:
|
|
761
|
+
axes = create_figure(2)
|
|
762
|
+
kplot(kdata, axes=axes[0])
|
|
763
|
+
axes = axes[1]
|
|
764
|
+
else:
|
|
765
|
+
axes = gca()
|
|
766
|
+
|
|
767
|
+
x = np.array([i for i in range(len(refdates))])
|
|
768
|
+
y1 = np.array([1 if cn.is_valid(d) else -1 for d in refdates])
|
|
769
|
+
y2 = np.array([-1 if cn.is_valid(d) else 1 for d in refdates])
|
|
770
|
+
axes.fill_between(x, y1, y2, where=y2 > y1, facecolor=downcolor, alpha=alpha)
|
|
771
|
+
axes.fill_between(x, y1, y2, where=y2 < y1, facecolor=upcolor, alpha=alpha)
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
def sysplot(sys, new=True, axes=None, style=1, only_draw_close=False):
|
|
775
|
+
"""绘制系统实际买入/卖出信号
|
|
776
|
+
|
|
777
|
+
:param SystemBase sys: 系统实例
|
|
778
|
+
:param new: 仅在未指定axes的情况下生效,当为True时,
|
|
779
|
+
创建新的窗口对象并在其中进行绘制
|
|
780
|
+
:param axes: 指定在那个轴对象中进行绘制
|
|
781
|
+
:param style: 1 | 2 信号箭头绘制样式
|
|
782
|
+
:param bool only_draw_close: 不绘制K线,仅绘制 close
|
|
783
|
+
"""
|
|
784
|
+
kdata = sys.to
|
|
785
|
+
|
|
786
|
+
refdates = kdata.get_datetime_list()
|
|
787
|
+
date_index = dict([(d, i) for i, d in enumerate(refdates)])
|
|
788
|
+
|
|
789
|
+
if axes is None:
|
|
790
|
+
if new:
|
|
791
|
+
axes = create_figure()
|
|
792
|
+
else:
|
|
793
|
+
axes = gca()
|
|
794
|
+
|
|
795
|
+
if only_draw_close:
|
|
796
|
+
iplot(kdata.close, axes=axes)
|
|
797
|
+
else:
|
|
798
|
+
kplot(kdata, axes=axes)
|
|
799
|
+
|
|
800
|
+
ylim = axes.get_ylim()
|
|
801
|
+
height = ylim[1] - ylim[0]
|
|
802
|
+
|
|
803
|
+
if style == 1:
|
|
804
|
+
arrow_buy = dict(arrowstyle="->")
|
|
805
|
+
arrow_sell = arrow_buy
|
|
806
|
+
else:
|
|
807
|
+
arrow_buy = dict(facecolor='red', frac=0.5)
|
|
808
|
+
arrow_sell = dict(facecolor='blue', frac=0.5)
|
|
809
|
+
|
|
810
|
+
tds = sys.tm.get_trade_list()
|
|
811
|
+
buy_dates = []
|
|
812
|
+
sell_dates = []
|
|
813
|
+
for t in tds:
|
|
814
|
+
if t.business == BUSINESS.BUY:
|
|
815
|
+
buy_dates.append(t.datetime)
|
|
816
|
+
elif t.business == BUSINESS.SELL:
|
|
817
|
+
sell_dates.append(t.datetime)
|
|
818
|
+
else:
|
|
819
|
+
pass
|
|
820
|
+
|
|
821
|
+
for d in buy_dates:
|
|
822
|
+
if d not in date_index:
|
|
823
|
+
continue
|
|
824
|
+
pos = date_index[d]
|
|
825
|
+
krecord = kdata[pos]
|
|
826
|
+
axes.annotate(
|
|
827
|
+
'B', (pos, krecord.low - height * 0.01), (pos, krecord.low - height * 0.1),
|
|
828
|
+
arrowprops=arrow_buy,
|
|
829
|
+
horizontalalignment='center',
|
|
830
|
+
verticalalignment='bottom',
|
|
831
|
+
color='red'
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
for d in sell_dates:
|
|
835
|
+
if d not in date_index:
|
|
836
|
+
continue
|
|
837
|
+
pos = date_index[d]
|
|
838
|
+
krecord = kdata[pos]
|
|
839
|
+
axes.annotate(
|
|
840
|
+
'S', (pos, krecord.high + height * 0.01), (pos, krecord.high + height * 0.1),
|
|
841
|
+
arrowprops=arrow_sell,
|
|
842
|
+
horizontalalignment='center',
|
|
843
|
+
verticalalignment='top',
|
|
844
|
+
color='blue'
|
|
845
|
+
)
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
def tm_performance(tm: TradeManager, query: Query, ref_stk: Stock = None):
|
|
849
|
+
"""
|
|
850
|
+
绘制系统绩效,即账户累积收益率曲线
|
|
851
|
+
|
|
852
|
+
:param SystemBase | PortfolioBase sys: SYS或PF实例
|
|
853
|
+
:param Stock ref_stk: 参考股票, 默认为沪深300: sh000300, 绘制参考标的的收益曲线
|
|
854
|
+
:return: None
|
|
855
|
+
"""
|
|
856
|
+
if ref_stk is None:
|
|
857
|
+
ref_stk = get_stock('sh000300')
|
|
858
|
+
|
|
859
|
+
sh000001_k = get_kdata('sh000001', query)
|
|
860
|
+
ref_dates = sh000001_k.get_datetime_list()
|
|
861
|
+
|
|
862
|
+
ref_k = ref_stk.get_kdata(query)
|
|
863
|
+
|
|
864
|
+
funds_list = tm.get_funds_list(ref_dates)
|
|
865
|
+
funds = [f.total_assets for f in funds_list]
|
|
866
|
+
funds = VALUE(funds)
|
|
867
|
+
funds_return = [f.total_assets / f.total_base if f.total_base != 0.0 else constant.null_price for f in funds_list]
|
|
868
|
+
funds_return = VALUE(funds_return, align_dates=ref_dates)
|
|
869
|
+
funds_return.name = "系统累积收益率"
|
|
870
|
+
ref_return = ALIGN(ROCR(ref_k.close, 0), ref_dates)
|
|
871
|
+
ref_return.name = f"{ref_stk.name}({ref_stk.market_code})"
|
|
872
|
+
|
|
873
|
+
per = tm.get_performance(sh000001_k[-1].datetime)
|
|
874
|
+
text = per.report()
|
|
875
|
+
|
|
876
|
+
# 计算最大回撤
|
|
877
|
+
max_pullback = min(MDD(funds))
|
|
878
|
+
|
|
879
|
+
# 计算 sharp
|
|
880
|
+
bond = ZHBOND10(ref_dates)
|
|
881
|
+
sigma = STDEV(ROCP(funds), len(ref_dates))
|
|
882
|
+
sigma = 15.874507866387544 * sigma[-1] # 15.874 = sqrt(252)
|
|
883
|
+
sharp = (per['帐户平均年收益率%'] - bond[-1]) * 0.01 / sigma if sigma != 0.0 else 0.0
|
|
884
|
+
|
|
885
|
+
invest_total = per['累计投入本金'] + per['累计投入资产']
|
|
886
|
+
cur_fund = per['当前总资产']
|
|
887
|
+
t1 = '投入总资产: {:<.2f} 当前总资产: {:<.2f} 当前盈利: {:<.2f}'.format(
|
|
888
|
+
invest_total, cur_fund, cur_fund - invest_total)
|
|
889
|
+
t2 = '当前策略收益: {:<.2f}% 年化收益率: {:<.2f}% 最大回撤: {:<.2f}%'.format(
|
|
890
|
+
funds_return[-1]*100 - 100, per["帐户平均年收益率%"], max_pullback)
|
|
891
|
+
t3 = '系统胜率: {:<.2f}% 盈/亏比: 1 : {:<.2f} 夏普比率: {:<.2f}'.format(
|
|
892
|
+
per['赢利交易比例%'], per['净赢利/亏损比例'], sharp)
|
|
893
|
+
|
|
894
|
+
import matplotlib.pyplot as plt
|
|
895
|
+
fg = plt.figure(figsize=(15, 10))
|
|
896
|
+
gs = fg.add_gridspec(5, 4)
|
|
897
|
+
ax1 = fg.add_subplot(gs[:4, :3])
|
|
898
|
+
ax2 = fg.add_subplot(gs[:, 3:])
|
|
899
|
+
ax3 = fg.add_subplot(gs[4:, :3])
|
|
900
|
+
ref_return.plot(axes=ax1, legend_on=True)
|
|
901
|
+
funds_return.plot(axes=ax1, legend_on=True)
|
|
902
|
+
ax1.set_title(f"账户({tm.name}) 累积收益率")
|
|
903
|
+
label = t1 + '\n\n' + t2 + '\n\n' + t3
|
|
904
|
+
ax2.text(0,
|
|
905
|
+
1,
|
|
906
|
+
text,
|
|
907
|
+
horizontalalignment='left',
|
|
908
|
+
verticalalignment='top',
|
|
909
|
+
transform=ax2.transAxes,
|
|
910
|
+
# color='r'
|
|
911
|
+
)
|
|
912
|
+
ax3.text(0.02,
|
|
913
|
+
0.9,
|
|
914
|
+
label,
|
|
915
|
+
horizontalalignment='left',
|
|
916
|
+
verticalalignment='top',
|
|
917
|
+
transform=ax3.transAxes,
|
|
918
|
+
# color='r'
|
|
919
|
+
)
|
|
920
|
+
ax2.xaxis.set_visible(False)
|
|
921
|
+
ax2.yaxis.set_visible(False)
|
|
922
|
+
ax2.set_frame_on(False)
|
|
923
|
+
ax3.xaxis.set_visible(False)
|
|
924
|
+
ax3.yaxis.set_visible(False)
|
|
925
|
+
ax3.set_frame_on(False)
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
def sys_performance(sys, ref_stk=None):
|
|
929
|
+
"""
|
|
930
|
+
绘制系统绩效,即账户累积收益率曲线
|
|
931
|
+
|
|
932
|
+
:param SystemBase | PortfolioBase sys: SYS或PF实例
|
|
933
|
+
:param Stock ref_stk: 参考股票, 默认为沪深300: sh000300, 绘制参考标的的收益曲线
|
|
934
|
+
:return: None
|
|
935
|
+
"""
|
|
936
|
+
if ref_stk is None:
|
|
937
|
+
ref_stk = get_stock('sh000300')
|
|
938
|
+
|
|
939
|
+
query = sys.query
|
|
940
|
+
sh000001_k = get_kdata('sh000001', query)
|
|
941
|
+
ref_dates = sh000001_k.get_datetime_list()
|
|
942
|
+
|
|
943
|
+
ref_k = ref_stk.get_kdata(query)
|
|
944
|
+
|
|
945
|
+
funds_list = sys.tm.get_funds_list(ref_dates)
|
|
946
|
+
funds = [f.total_assets for f in funds_list]
|
|
947
|
+
funds = VALUE(funds)
|
|
948
|
+
funds_return = [f.total_assets / f.total_base if f.total_base != 0.0 else constant.null_price for f in funds_list]
|
|
949
|
+
funds_return = VALUE(funds_return, align_dates=ref_dates)
|
|
950
|
+
funds_return.name = "系统累积收益率"
|
|
951
|
+
ref_return = ALIGN(ROCR(ref_k.close, 0), ref_dates)
|
|
952
|
+
ref_return.name = f"{ref_stk.name}({ref_stk.market_code})"
|
|
953
|
+
|
|
954
|
+
per = sys.tm.get_performance(sh000001_k[-1].datetime)
|
|
955
|
+
text = per.report()
|
|
956
|
+
|
|
957
|
+
# 计算最大回撤
|
|
958
|
+
max_pullback = min(MDD(funds))
|
|
959
|
+
|
|
960
|
+
# 计算 sharp
|
|
961
|
+
bond = ZHBOND10(ref_dates)
|
|
962
|
+
sigma = STDEV(ROCP(funds), len(ref_dates))
|
|
963
|
+
sigma = 15.874507866387544 * sigma[-1] # 15.874 = sqrt(252)
|
|
964
|
+
sharp = (per['帐户平均年收益率%'] - bond[-1]) * 0.01 / sigma if sigma != 0.0 else 0.0
|
|
965
|
+
|
|
966
|
+
invest_total = per['累计投入本金'] + per['累计投入资产']
|
|
967
|
+
cur_fund = per['当前总资产']
|
|
968
|
+
t1 = '投入总资产: {:<.2f} 当前总资产: {:<.2f} 当前盈利: {:<.2f}'.format(
|
|
969
|
+
invest_total, cur_fund, cur_fund - invest_total)
|
|
970
|
+
t2 = '当前策略收益: {:<.2f}% 年化收益率: {:<.2f}% 最大回撤: {:<.2f}%'.format(
|
|
971
|
+
funds_return[-1]*100 - 100, per["帐户平均年收益率%"], max_pullback)
|
|
972
|
+
t3 = '系统胜率: {:<.2f}% 盈/亏比: 1 : {:<.2f} 夏普比率: {:<.2f}'.format(
|
|
973
|
+
per['赢利交易比例%'], per['净赢利/亏损比例'], sharp)
|
|
974
|
+
|
|
975
|
+
import matplotlib.pyplot as plt
|
|
976
|
+
fg = plt.figure(figsize=(15, 10))
|
|
977
|
+
gs = fg.add_gridspec(5, 4)
|
|
978
|
+
ax1 = fg.add_subplot(gs[:4, :3])
|
|
979
|
+
ax2 = fg.add_subplot(gs[:, 3:])
|
|
980
|
+
ax3 = fg.add_subplot(gs[4:, :3])
|
|
981
|
+
ref_return.plot(axes=ax1, legend_on=True)
|
|
982
|
+
funds_return.plot(axes=ax1, legend_on=True)
|
|
983
|
+
if isinstance(sys, System):
|
|
984
|
+
stk = sys.get_stock()
|
|
985
|
+
ax1.set_title(f"{sys.name} {stk.name}({stk.market_code}) 累积收益率")
|
|
986
|
+
else:
|
|
987
|
+
ax1.set_title(f"{sys.name} 累积收益率")
|
|
988
|
+
label = t1 + '\n\n' + t2 + '\n\n' + t3
|
|
989
|
+
ax2.text(0,
|
|
990
|
+
1,
|
|
991
|
+
text,
|
|
992
|
+
horizontalalignment='left',
|
|
993
|
+
verticalalignment='top',
|
|
994
|
+
transform=ax2.transAxes,
|
|
995
|
+
# color='r'
|
|
996
|
+
)
|
|
997
|
+
ax3.text(0.02,
|
|
998
|
+
0.9,
|
|
999
|
+
label,
|
|
1000
|
+
horizontalalignment='left',
|
|
1001
|
+
verticalalignment='top',
|
|
1002
|
+
transform=ax3.transAxes,
|
|
1003
|
+
# color='r'
|
|
1004
|
+
)
|
|
1005
|
+
ax2.xaxis.set_visible(False)
|
|
1006
|
+
ax2.yaxis.set_visible(False)
|
|
1007
|
+
ax2.set_frame_on(False)
|
|
1008
|
+
ax3.xaxis.set_visible(False)
|
|
1009
|
+
ax3.yaxis.set_visible(False)
|
|
1010
|
+
ax3.set_frame_on(False)
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
def tm_heatmap(tm, start_date, end_date=None, axes=None):
|
|
1014
|
+
"""
|
|
1015
|
+
绘制账户收益年-月收益热力图
|
|
1016
|
+
|
|
1017
|
+
:param tm: 交易账户
|
|
1018
|
+
:param start_date: 开始日期
|
|
1019
|
+
:param end_date: 结束日期,默认为今天
|
|
1020
|
+
:param axes: 绘制的轴对象,默认为None,表示创建新的轴对象
|
|
1021
|
+
:return: None
|
|
1022
|
+
"""
|
|
1023
|
+
if axes is None:
|
|
1024
|
+
axes = create_figure()
|
|
1025
|
+
|
|
1026
|
+
if end_date is None:
|
|
1027
|
+
end_date = Datetime.today() + Days(1)
|
|
1028
|
+
|
|
1029
|
+
dates = get_date_range(start_date, end_date)
|
|
1030
|
+
if len(dates) == 0:
|
|
1031
|
+
hku_error("没有数据,请检查日期范围!start_date={}, end_date={}", start_date, end_date)
|
|
1032
|
+
return
|
|
1033
|
+
|
|
1034
|
+
funds = tm.get_funds_curve(dates)
|
|
1035
|
+
if len(funds) == 0:
|
|
1036
|
+
hku_error("获取 tm 收益曲线失败,请检查 tm 初始日期!tm.init_datetime={} start_date={}, end_date={}",
|
|
1037
|
+
tm.init_datetime, start_date, end_date)
|
|
1038
|
+
return
|
|
1039
|
+
|
|
1040
|
+
data = pd.DataFrame({'date': dates, 'value': funds})
|
|
1041
|
+
data = data[(data[['value']] != 0).all(axis=1)]
|
|
1042
|
+
|
|
1043
|
+
# 提取年月信息
|
|
1044
|
+
data['year'] = data['date'].apply(lambda v: v.year)
|
|
1045
|
+
data['month'] = data['date'].apply(lambda v: v.month)
|
|
1046
|
+
|
|
1047
|
+
# 获取每个月的收益
|
|
1048
|
+
monthly = data.groupby(['year', 'month']).last()['value'].reset_index()
|
|
1049
|
+
if len(monthly) < 2:
|
|
1050
|
+
hku_warn("月数据不足!")
|
|
1051
|
+
return
|
|
1052
|
+
|
|
1053
|
+
monthly['return'] = ((monthly['value'] - monthly['value'].shift(1)) / monthly['value'].shift(1)) * 100.
|
|
1054
|
+
|
|
1055
|
+
pivot_data = monthly.pivot_table(index='year', columns='month', values='return')
|
|
1056
|
+
|
|
1057
|
+
sns.heatmap(pivot_data, cmap='RdYlGn_r', center=0, annot=True, fmt="<.2f", ax=axes)
|
|
1058
|
+
# 设置标题和坐标轴标签
|
|
1059
|
+
axes.set_title('年-月度收益率(%)热力图')
|
|
1060
|
+
axes.set_xlabel('月度')
|
|
1061
|
+
axes.set_ylabel('年份')
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
def sys_heatmap(sys, axes=None):
|
|
1065
|
+
"""
|
|
1066
|
+
绘制系统收益年-月收益热力图
|
|
1067
|
+
"""
|
|
1068
|
+
hku_check(sys.tm is not None, "系统未初始化交易账户")
|
|
1069
|
+
query = sys.query
|
|
1070
|
+
k = get_kdata('sh000001', query)
|
|
1071
|
+
tm_heatmap(sys.tm, k[0].datetime, k[-1].datetime, axes)
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
# ============================================================================
|
|
1075
|
+
# 通达信画图函数
|
|
1076
|
+
# ============================================================================
|
|
1077
|
+
DRAWNULL = constant.null_price
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
def RGB(r: int, g: int, b: int):
|
|
1081
|
+
hku_check(0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255, "r,g,b must in [0,255]!")
|
|
1082
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
def STICKLINE(cond: Indicator, price1: Indicator, price2: Indicator, width: float = 2.0,
|
|
1086
|
+
empty: bool = False, color='m', alpha=1.0, kdata=None, new=False, axes=None):
|
|
1087
|
+
"""在满足cond的条件下,在 price1 和 price2 之间绘制一个宽度为 width 的柱状图。
|
|
1088
|
+
|
|
1089
|
+
注意: cond, price1, price2 应含有数据,否则请指定 kdata 作为指标计算的上下文
|
|
1090
|
+
|
|
1091
|
+
参数说明:
|
|
1092
|
+
cond (Indicator): 条件表达式,用于确定是否绘制柱状线
|
|
1093
|
+
price1 (Indicator): 第一个价格
|
|
1094
|
+
price2 (Indicator): 第二个价格
|
|
1095
|
+
width (float, optional): 柱状宽度. Defaults to 2.0.
|
|
1096
|
+
empty (bool, optional): 空心. Defaults to False.
|
|
1097
|
+
kdata (_type_, optional): 指定的上下文K线. Defaults to None.
|
|
1098
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1099
|
+
axes (_type_, optional): 在指定的坐标轴中绘制. Defaults to None.
|
|
1100
|
+
color (str, optional): 颜色. Defaults to 'm'.
|
|
1101
|
+
alpha (float, optional): 透明度. Defaults to 1.0.
|
|
1102
|
+
"""
|
|
1103
|
+
hku_check(cond is not None and price1 is not None and price2 is not None, "cond, price1, price2 cannot be None")
|
|
1104
|
+
|
|
1105
|
+
if kdata is not None:
|
|
1106
|
+
cond = cond(kdata)
|
|
1107
|
+
price1 = price1(kdata)
|
|
1108
|
+
price2 = price2(kdata)
|
|
1109
|
+
hku_check(len(cond) == len(price1) == len(price2), "cond, price1, price2 length not match")
|
|
1110
|
+
hku_warn_if(len(cond) <= 0, "cond, price1, price2 length <=0")
|
|
1111
|
+
|
|
1112
|
+
if axes is None:
|
|
1113
|
+
axes = create_figure() if new else gca()
|
|
1114
|
+
|
|
1115
|
+
width = 0.3 * width
|
|
1116
|
+
OFFSET = width / 2.0
|
|
1117
|
+
for i in range(len(cond)):
|
|
1118
|
+
if cond[i] > 0.:
|
|
1119
|
+
height = abs(price1[i] - price2[i])
|
|
1120
|
+
lower = min(price1[i], price2[i])
|
|
1121
|
+
rect = Rectangle(xy=(i - OFFSET, lower), width=width, height=height,
|
|
1122
|
+
facecolor=color, edgecolor=color, fill=(not empty))
|
|
1123
|
+
rect.set_alpha(alpha)
|
|
1124
|
+
axes.add_patch(rect)
|
|
1125
|
+
|
|
1126
|
+
axes.autoscale_view()
|
|
1127
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
def DRAWBAND(val1: Indicator, color1='m', val2: Indicator = None, color2='b', kdata=None, alpha=0.2, new=False, axes=None, linestyle='-'):
|
|
1131
|
+
"""画出带状线
|
|
1132
|
+
|
|
1133
|
+
用法:DRAWBAND(val1, color1, val2, color2), 当 val1 > val2 时,在 val1 和 val2 之间填充 color1;
|
|
1134
|
+
当 val1 < val2 时,填充 color2,这里的颜色均使用 matplotlib 颜色代码.
|
|
1135
|
+
例如:DRAWBAND(OPEN, 'r', CLOSE, 'b')
|
|
1136
|
+
|
|
1137
|
+
Args:
|
|
1138
|
+
val1 (Indicator): 指标1
|
|
1139
|
+
color1 (str, optional): 颜色1. Defaults to 'm'.
|
|
1140
|
+
val2 (Indicator, optional): 指标2. Defaults to None.
|
|
1141
|
+
color2 (str, optional): 颜色2. Defaults to 'b'.
|
|
1142
|
+
kdata (_type_, optional): 指定指标上下文. Defaults to None.
|
|
1143
|
+
alpha (float, optional): 透明度. Defaults to 0.2.
|
|
1144
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1145
|
+
axes (_type_, optional): 在指定的坐标轴中绘制. Defaults to None.
|
|
1146
|
+
linestyle (str, optional): 包络线类型. Defaults to '-'.
|
|
1147
|
+
"""
|
|
1148
|
+
hku_check(val1 is not None, "val1 cannot be None")
|
|
1149
|
+
|
|
1150
|
+
if kdata is not None:
|
|
1151
|
+
val1 = val1(kdata)
|
|
1152
|
+
if val2 is not None:
|
|
1153
|
+
val2 = val2(kdata)
|
|
1154
|
+
|
|
1155
|
+
if val2 is None:
|
|
1156
|
+
val2 = CVAL(val1, 0.)
|
|
1157
|
+
|
|
1158
|
+
hku_check(len(val1) == len(val2), "val1, val2 length not match")
|
|
1159
|
+
hku_warn_if(len(val1) <= 0, "val1, val2 length <=0")
|
|
1160
|
+
|
|
1161
|
+
if axes is None:
|
|
1162
|
+
axes = create_figure() if new else gca()
|
|
1163
|
+
|
|
1164
|
+
cond = IF(val1 <= val2, val1, val2)
|
|
1165
|
+
axes.fill_between(range(cond.discard, len(val1)), val1[cond.discard:], cond[cond.discard:], alpha=alpha,
|
|
1166
|
+
color=color1, facecolor=color1, edgecolor=color1, linestyle=linestyle)
|
|
1167
|
+
|
|
1168
|
+
cond = IF(val1 > val2, val1, val2)
|
|
1169
|
+
axes.fill_between(range(cond.discard, len(val1)), val1[cond.discard:], cond[cond.discard:], alpha=alpha,
|
|
1170
|
+
color=color2, facecolor=color2, edgecolor=color2, linestyle=linestyle)
|
|
1171
|
+
|
|
1172
|
+
axes.autoscale_view()
|
|
1173
|
+
axes.set_xlim(-1, len(val1) + 1)
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
def PLOYLINE(cond: Indicator, price: Indicator, kdata: KData = None, color: str = 'm', linewidth=1.0, new=False, axes=None, *args, **kwargs):
|
|
1177
|
+
"""在图形上绘制折线段。
|
|
1178
|
+
|
|
1179
|
+
用法:PLOYLINE(COND,PRICE),当COND条件满足时,以PRICE位置为顶点画折线连接。
|
|
1180
|
+
例如:PLOYLINE(HIGH>=HHV(HIGH,20),HIGH, kdata=k)表示在创20天新高点之间画折线。
|
|
1181
|
+
|
|
1182
|
+
Args:
|
|
1183
|
+
cond (Indicator): 指定条件
|
|
1184
|
+
price (Indicator): 位置
|
|
1185
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1186
|
+
color (str, optional): 颜色. Defaults to 'b'.
|
|
1187
|
+
linewidth (float, optional): 宽度. Defaults to 1.0.
|
|
1188
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1189
|
+
axes (_type_, optional): 指定的axes. Defaults to None.
|
|
1190
|
+
"""
|
|
1191
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1192
|
+
|
|
1193
|
+
ind = IF(cond, price, constant.null_price)
|
|
1194
|
+
if kdata is not None:
|
|
1195
|
+
ind = ind(kdata)
|
|
1196
|
+
price = price(kdata)
|
|
1197
|
+
hku_check(len(ind) == len(price), "cond, price length not match!")
|
|
1198
|
+
hku_warn_if(len(ind) <= 0, "cond length <=0")
|
|
1199
|
+
|
|
1200
|
+
if axes is None:
|
|
1201
|
+
axes = create_figure() if new else gca()
|
|
1202
|
+
|
|
1203
|
+
# ind.plot(new=new, axes=axes, color=color, linewidth=linewidth, *args, **kwargs)
|
|
1204
|
+
x, y = [], []
|
|
1205
|
+
for i in range(ind.discard, len(ind)):
|
|
1206
|
+
val = ind[i]
|
|
1207
|
+
if not isnan(val):
|
|
1208
|
+
x.append(i)
|
|
1209
|
+
y.append(val)
|
|
1210
|
+
if len(x) > 0:
|
|
1211
|
+
axes.plot(x, y, color=color, linewidth=linewidth, *args, **kwargs)
|
|
1212
|
+
|
|
1213
|
+
axes.autoscale_view()
|
|
1214
|
+
axes.set_xlim(-1, len(ind) + 1)
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
def DRAWLINE(cond1: Indicator, price1: Indicator, cond2: Indicator, price2: Indicator, expand: int = 0, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1218
|
+
"""在图形上绘制直线段。
|
|
1219
|
+
|
|
1220
|
+
用法:DRAWLINE(cond1, price1, cond2, price2, expand)
|
|
1221
|
+
当COND1条件满足时,在PRICE1位置画直线起点,当COND2条件满足时,在PRICE2位置画直线终点,EXPAND为延长类型。
|
|
1222
|
+
例如:DRAWLINE(HIGH>=HHV(HIGH,20),HIGH,LOW<=LLV(LOW,20),LOW,1)表示在创20天新高与创20天新低之间画直线并且向右延长
|
|
1223
|
+
|
|
1224
|
+
Args:
|
|
1225
|
+
cond1 (Indicator): 条件1
|
|
1226
|
+
price1 (Indicator): 位置1
|
|
1227
|
+
cond2 (Indicator): 条件2
|
|
1228
|
+
price2 (Indicator): 位置2
|
|
1229
|
+
expand (int, optional): 0: 不延长 | 1: 向右延长 | 10: 向左延长 | 11: 双向延长. Defaults to 0.
|
|
1230
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1231
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1232
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1233
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1234
|
+
"""
|
|
1235
|
+
hku_check(cond1 is not None and cond2 is not None and price1 is not None and price2 is not None,
|
|
1236
|
+
"cond1, cond2, price1, price2 cannot be None")
|
|
1237
|
+
hku_check(expand in (0, 1, 10, 11), "expand must be 0, 1, 10 or 11")
|
|
1238
|
+
|
|
1239
|
+
if kdata is not None:
|
|
1240
|
+
cond1 = cond1(kdata)
|
|
1241
|
+
price1 = price1(kdata)
|
|
1242
|
+
cond2 = cond2(kdata)
|
|
1243
|
+
price2 = price2(kdata)
|
|
1244
|
+
hku_check(len(cond1) == len(cond2) == len(price1) == len(price2), "cond1, cond2, price1, price2 length not match")
|
|
1245
|
+
hku_warn_if(len(cond1) <= 0, "cond1, cond2, price1, price2 length <=0")
|
|
1246
|
+
|
|
1247
|
+
if axes is None:
|
|
1248
|
+
axes = create_figure() if new else gca()
|
|
1249
|
+
|
|
1250
|
+
length = len(cond1)
|
|
1251
|
+
x1, y1 = None, None
|
|
1252
|
+
for i in range(cond1.discard, length):
|
|
1253
|
+
cond1_val = cond1[i]
|
|
1254
|
+
if cond1_val > 0.:
|
|
1255
|
+
if x1 is None:
|
|
1256
|
+
x1, y1 = i, price1[i]
|
|
1257
|
+
else:
|
|
1258
|
+
x1, y1 = None, None
|
|
1259
|
+
cond2_val = cond2[i]
|
|
1260
|
+
if cond2_val > 0.:
|
|
1261
|
+
if x1 is not None:
|
|
1262
|
+
if expand == 0:
|
|
1263
|
+
x = [x1, i]
|
|
1264
|
+
y = [y1, price2[i]]
|
|
1265
|
+
elif expand == 1:
|
|
1266
|
+
x = [n for n in range(i, length)]
|
|
1267
|
+
x.insert(0, x1)
|
|
1268
|
+
val = price2[i]
|
|
1269
|
+
y = [val for n in range(i, length)]
|
|
1270
|
+
y.insert(0, y1)
|
|
1271
|
+
elif expand == 10:
|
|
1272
|
+
x = [n for n in range(0, i+1)]
|
|
1273
|
+
val = price2[i]
|
|
1274
|
+
y = [val for n in range(0, i+1)]
|
|
1275
|
+
elif expand == 11:
|
|
1276
|
+
x = [n for n in range(0, length)]
|
|
1277
|
+
val = price2[i]
|
|
1278
|
+
y = [val for n in range(0, length)]
|
|
1279
|
+
axes.plot(x, y, color=color, *args, **kwargs)
|
|
1280
|
+
x1, y1 = None, None
|
|
1281
|
+
|
|
1282
|
+
axes.autoscale_view()
|
|
1283
|
+
axes.set_xlim(-1, len(cond1) + 1)
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
def DRAWTEXT(cond: Indicator, price: Indicator, text: str, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1287
|
+
"""在图形上显示文字。
|
|
1288
|
+
|
|
1289
|
+
用法: DRAWTEXT(cond, price, text), 当 cond 条件满足时, 在 price 位置书写文字 text。
|
|
1290
|
+
例如: DRAWTEXT(CLOSE/OPEN>1.08,LOW,'大阳线')表示当日实体阳线大于8%时在最低价位置显示'大阳线'字样.
|
|
1291
|
+
|
|
1292
|
+
Args:
|
|
1293
|
+
cond (Indicator): 条件
|
|
1294
|
+
price (Indicator): 显示位置
|
|
1295
|
+
text (str): 待显示文字
|
|
1296
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1297
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1298
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1299
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1300
|
+
"""
|
|
1301
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1302
|
+
|
|
1303
|
+
if kdata is not None:
|
|
1304
|
+
cond = cond(kdata)
|
|
1305
|
+
price = price(kdata)
|
|
1306
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1307
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1308
|
+
|
|
1309
|
+
if axes is None:
|
|
1310
|
+
axes = create_figure() if new else gca()
|
|
1311
|
+
|
|
1312
|
+
for i in range(cond.discard, len(cond)):
|
|
1313
|
+
if cond[i] > 0.:
|
|
1314
|
+
axes.text(i, price[i], text, color=color, *args, **kwargs)
|
|
1315
|
+
|
|
1316
|
+
axes.autoscale_view()
|
|
1317
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
def DRAWTEXT_FIX(cond: Indicator, x: float, y: float, type: int, text: str, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1321
|
+
"""固定位置显示文字
|
|
1322
|
+
|
|
1323
|
+
用法:DRAWTEXT_FIX(cond,x y, text), cond 中一般需要加 ISLASTBAR,当 cond 条件满足时,
|
|
1324
|
+
在当前指标窗口内(X,Y)位置书写文字TEXT,X,Y为书写点在窗口中相对于左上角的百分比
|
|
1325
|
+
|
|
1326
|
+
例如:DRAWTEXT_FIX(ISLASTBAR() & (CLOSE/OPEN>1.08),0.5,0.5,0,'大阳线')表示最后一个交易日实体阳线
|
|
1327
|
+
大于8%时在窗口中间位置显示'大阳线'字样.
|
|
1328
|
+
|
|
1329
|
+
Args:
|
|
1330
|
+
cond (Indicator): 条件
|
|
1331
|
+
x (float): x轴坐标
|
|
1332
|
+
y (float): y轴坐标
|
|
1333
|
+
type (int, optional): 0 左对齐 | 1 右对齐.
|
|
1334
|
+
text (str): 待显示文字
|
|
1335
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1336
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1337
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1338
|
+
axes (_type_, optional): 指定坐标轴. Defaults to None.
|
|
1339
|
+
"""
|
|
1340
|
+
hku_check(cond is not None, "cond cannot be None")
|
|
1341
|
+
if kdata is not None:
|
|
1342
|
+
cond = cond(kdata)
|
|
1343
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1344
|
+
|
|
1345
|
+
if axes is None:
|
|
1346
|
+
axes = create_figure() if new else gca()
|
|
1347
|
+
|
|
1348
|
+
for i in range(cond.discard, len(cond)):
|
|
1349
|
+
if cond[i] > 0.:
|
|
1350
|
+
axes.text(x, 1-y, text, horizontalalignment='left' if type == 0 else 'right', verticalalignment='top',
|
|
1351
|
+
transform=axes.transAxes, color=color, *args, **kwargs)
|
|
1352
|
+
|
|
1353
|
+
axes.autoscale_view()
|
|
1354
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
def DRAWNUMBER(cond: Indicator, price: Indicator, number: Indicator, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1358
|
+
"""画出数字.
|
|
1359
|
+
|
|
1360
|
+
用法:DRAWNUMBER(cond, price, number),当 cond 条件满足时,在 price 位置书写数字 number.
|
|
1361
|
+
例如:DRAWNUMBER(CLOSE/OPEN>1.08,LOW,C)表示当日实体阳线大于8%时在最低价位置显示收盘价。
|
|
1362
|
+
|
|
1363
|
+
Args:
|
|
1364
|
+
cond (Indicator): 条件
|
|
1365
|
+
price (Indicator): 绘制位置
|
|
1366
|
+
number (Indicator): 待绘制数字
|
|
1367
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1368
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1369
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1370
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1371
|
+
"""
|
|
1372
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1373
|
+
|
|
1374
|
+
if kdata is not None:
|
|
1375
|
+
cond = cond(kdata)
|
|
1376
|
+
price = price(kdata)
|
|
1377
|
+
number = number(kdata)
|
|
1378
|
+
hku_check(len(cond) == len(price), "cond, price, number length not match")
|
|
1379
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1380
|
+
|
|
1381
|
+
if axes is None:
|
|
1382
|
+
axes = create_figure() if new else gca()
|
|
1383
|
+
|
|
1384
|
+
for i in range(cond.discard, len(cond)):
|
|
1385
|
+
if cond[i] > 0.:
|
|
1386
|
+
axes.text(i, price[i], str(number[i]), color=color, *args, **kwargs)
|
|
1387
|
+
|
|
1388
|
+
axes.autoscale_view()
|
|
1389
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
def DRAWNUMBER_FIX(cond: Indicator, x: float, y: float, type: int, number: float, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1393
|
+
"""固定位置显示数字.
|
|
1394
|
+
|
|
1395
|
+
用法:DRAWNUMBER_FIX(cond,x,y,type,number), cond 中一般需要加 ISLASTBAR, 当 cond 条件满足时,
|
|
1396
|
+
在当前指标窗口内 (x, y) 位置书写数字 number, x,y为书写点在窗口中相对于左上角的百分比,type:0为左对齐,1为右对齐。
|
|
1397
|
+
|
|
1398
|
+
例如:DRAWNUMBER_FIX(ISLASTBAR() & (CLOSE/OPEN>1.08), 0.5,0.5,0,C)表示最后一个交易日实体阳线大于8%时在窗口中间位置显示收盘价
|
|
1399
|
+
|
|
1400
|
+
Args:
|
|
1401
|
+
cond (Indicator): _description_
|
|
1402
|
+
x (float): _description_
|
|
1403
|
+
y (float): _description_
|
|
1404
|
+
type (int): _description_
|
|
1405
|
+
number (Indicator): _description_
|
|
1406
|
+
kdata (KData, optional): _description_. Defaults to None.
|
|
1407
|
+
color (str, optional): _description_. Defaults to 'm'.
|
|
1408
|
+
new (bool, optional): _description_. Defaults to False.
|
|
1409
|
+
axes (_type_, optional): _description_. Defaults to None.
|
|
1410
|
+
"""
|
|
1411
|
+
DRAWTEXT_FIX(cond, x, y, type, str(number), kdata, color, new, axes, *args, **kwargs)
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
def DRAWSL(cond: Indicator, price: Indicator, slope: Union[Indicator, float, int], length: Union[Indicator, float, int], direct: int, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1415
|
+
"""绘制斜线.
|
|
1416
|
+
|
|
1417
|
+
用法:DRAWSL(cond,price,slope,length,diect),当 cond 条件满足时,在 price 位置画斜线, slope 为斜率,
|
|
1418
|
+
lengh为长度, direct 为0向右延伸,1向左延伸,2双向延伸。
|
|
1419
|
+
|
|
1420
|
+
注意:
|
|
1421
|
+
1. K线间的纵向高度差为 slope;
|
|
1422
|
+
2. slope 为 0 时, 为水平线;
|
|
1423
|
+
3. slope 为 10000 时, 为垂直线, length 为向上的像素高度, direct 表示向上或向下延伸
|
|
1424
|
+
4. slope 和 length 支持变量;
|
|
1425
|
+
|
|
1426
|
+
Args:
|
|
1427
|
+
cond (Indicator): 条件指标
|
|
1428
|
+
price (Indicator): 价格
|
|
1429
|
+
slope (int|float|Indicator): 斜率
|
|
1430
|
+
length (int|float|Indicator): 长度
|
|
1431
|
+
direct (int): 方向
|
|
1432
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1433
|
+
color (str, optional): 颜色. Defaults to 'm'.
|
|
1434
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1435
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1436
|
+
"""
|
|
1437
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1438
|
+
hku_check(direct in (0, 1, 2), "direct must be 0,1,2")
|
|
1439
|
+
|
|
1440
|
+
if kdata is not None:
|
|
1441
|
+
cond = cond(kdata)
|
|
1442
|
+
price = price(kdata)
|
|
1443
|
+
slope = slope(kdata) if isinstance(slope, Indicator) else [slope for i in range(len(kdata))]
|
|
1444
|
+
length = length(kdata) if isinstance(length, Indicator) else [length for i in range(len(kdata))]
|
|
1445
|
+
|
|
1446
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1447
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1448
|
+
|
|
1449
|
+
if axes is None:
|
|
1450
|
+
axes = create_figure() if new else gca()
|
|
1451
|
+
|
|
1452
|
+
for i in range(cond.discard, len(cond)):
|
|
1453
|
+
val = price[i]
|
|
1454
|
+
if not isnan(val):
|
|
1455
|
+
if slope[i] < 10000:
|
|
1456
|
+
x = length[i] / math.sqrt(1+slope[i]**2)
|
|
1457
|
+
y = x * slope[i]
|
|
1458
|
+
if direct == 0:
|
|
1459
|
+
axes.plot([i, i+x], [val, val+y], color=color, *args, **kwargs)
|
|
1460
|
+
elif direct == 1:
|
|
1461
|
+
axes.plot([i-x, i], [val-y, val], color=color, *args, **kwargs)
|
|
1462
|
+
else:
|
|
1463
|
+
axes.plot([i-x*0.5, i, i+x*0.5], [val-y*0.5, val, val+y*0.5], color=color, *args, **kwargs)
|
|
1464
|
+
else:
|
|
1465
|
+
y = length[i]
|
|
1466
|
+
if direct == 0:
|
|
1467
|
+
axes.plot([i, i], [val, val+y], color=color, *args, **kwargs)
|
|
1468
|
+
elif direct == 1:
|
|
1469
|
+
axes.plot([i, i], [val, val-y], color=color, *args, **kwargs)
|
|
1470
|
+
else:
|
|
1471
|
+
axes.plot([i, i, i], [val-y*0.5, val, val+y*0.5], color=color, *args, **kwargs)
|
|
1472
|
+
|
|
1473
|
+
axes.autoscale_view()
|
|
1474
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
def DRAWIMG(cond: Indicator, price: Indicator, img: str, kdata: KData = None, new=False, axes=None, *args, **kwargs):
|
|
1478
|
+
"""画图片
|
|
1479
|
+
|
|
1480
|
+
用法:DRAWIMG(cond,price,'图像文件文件名'),当条件 cond 满足时,在 price 位置画指定的图片
|
|
1481
|
+
例如:DRAWIMG(O>C,CLOSE, '123.png')。
|
|
1482
|
+
|
|
1483
|
+
Args:
|
|
1484
|
+
cond (Indicator): 指定条件
|
|
1485
|
+
price (Indicator): 指定价格
|
|
1486
|
+
img (str): 图像文件名
|
|
1487
|
+
kdata (KData, optional): 指定上下文. Defaults to None.
|
|
1488
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1489
|
+
axes (_type_, optional): 在指定坐标轴中绘制. Defaults to None.
|
|
1490
|
+
"""
|
|
1491
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1492
|
+
|
|
1493
|
+
if kdata is not None:
|
|
1494
|
+
cond = cond(kdata)
|
|
1495
|
+
price = price(kdata)
|
|
1496
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1497
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1498
|
+
|
|
1499
|
+
if axes is None:
|
|
1500
|
+
axes = create_figure() if new else gca()
|
|
1501
|
+
|
|
1502
|
+
image = imread(img)
|
|
1503
|
+
|
|
1504
|
+
p = axes.get_window_extent()
|
|
1505
|
+
pw = p.x1 - p.x0
|
|
1506
|
+
ph = p.y1 - p.y0
|
|
1507
|
+
x0, x1 = axes.get_xlim()
|
|
1508
|
+
y0, y1 = axes.get_ylim()
|
|
1509
|
+
xw = x1 - x0
|
|
1510
|
+
yh = y1 - y0
|
|
1511
|
+
pixel = 20. # 显示像素大小
|
|
1512
|
+
w = xw / pw * pixel
|
|
1513
|
+
h = yh / ph * pixel
|
|
1514
|
+
for i in range(cond.discard, len(cond)):
|
|
1515
|
+
if (not isnan(cond[i])) and cond[i] > 0. and (not isinf(cond[i])) and (not isnan(price[i])) and (not isinf(price[i])):
|
|
1516
|
+
axes.imshow(image, extent=[i-w, i+w, price[i]-h, price[i]+h], *args, **kwargs)
|
|
1517
|
+
|
|
1518
|
+
axes.set_aspect('auto')
|
|
1519
|
+
axes.autoscale_view()
|
|
1520
|
+
axes.set_ylim(y0, y1)
|
|
1521
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
DRAWBMP = DRAWIMG
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
def DRAWICON(cond: Indicator, price: Indicator, type: int, kdata: KData = None, new=False, axes=None, *args, **kwargs):
|
|
1528
|
+
"""绘制内置 icon
|
|
1529
|
+
|
|
1530
|
+
用法:DRAWICON(cond,price,1),当条件 cond 满足时,在 price 位置编号为1的内置图标
|
|
1531
|
+
例如:DRAWICON(O>C,CLOSE, 1)。
|
|
1532
|
+
|
|
1533
|
+
可以使用 SHOWICONS() 显示所有内置图标。
|
|
1534
|
+
|
|
1535
|
+
Args:
|
|
1536
|
+
cond (Indicator): 指定条件
|
|
1537
|
+
price (Indicator): 指定价格
|
|
1538
|
+
type (int): icon 编号
|
|
1539
|
+
kdata (KData, optional): 指定上下文. Defaults to None.
|
|
1540
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1541
|
+
axes (_type_, optional): 在指定坐标轴中绘制. Defaults to None.
|
|
1542
|
+
"""
|
|
1543
|
+
DRAWIMG(cond, price, f'{ICON_PATH}/icon/{type}.png', kdata, new, axes, *args, **kwargs)
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
def SHOWICONS():
|
|
1547
|
+
"""显示所有内置图标"""
|
|
1548
|
+
axes = create_one_axes_figure([8, 6])
|
|
1549
|
+
p = axes.get_window_extent()
|
|
1550
|
+
pw = p.x1 - p.x0
|
|
1551
|
+
ph = p.y1 - p.y0
|
|
1552
|
+
x0, x1 = axes.get_xlim()
|
|
1553
|
+
y0, y1 = axes.get_ylim()
|
|
1554
|
+
xw = x1 - x0
|
|
1555
|
+
yh = y1 - y0
|
|
1556
|
+
pixel = 100. # 显示像素大小
|
|
1557
|
+
w = xw / pw * pixel
|
|
1558
|
+
h = yh / ph * pixel
|
|
1559
|
+
|
|
1560
|
+
row, col = 5, 10
|
|
1561
|
+
for i in range(row):
|
|
1562
|
+
for j in range(col):
|
|
1563
|
+
n = i*col+j + 1
|
|
1564
|
+
name = f'{ICON_PATH}/icon/{n}.png'
|
|
1565
|
+
if os.path.exists(name):
|
|
1566
|
+
try:
|
|
1567
|
+
x = j*w
|
|
1568
|
+
y = i*h
|
|
1569
|
+
axes.imshow(imread(name), extent=[x, x+w, 1-(y+h), 1-y])
|
|
1570
|
+
except:
|
|
1571
|
+
pass
|
|
1572
|
+
axes.set_aspect('auto')
|
|
1573
|
+
axes.autoscale_view()
|
|
1574
|
+
axes.set_ylim(y0, y1)
|
|
1575
|
+
axes.set_xlim(x0, x1)
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
def DRAWRECTREL(left: int, top: int, right: int, bottom: int, color='m', frame=True, fill=True, alpha=0.1, new=False, axes=None, *args, **kwargs):
|
|
1579
|
+
"""相对位置上画矩形.
|
|
1580
|
+
|
|
1581
|
+
注意:原点为坐标轴左上角(0, 0),和 matplotlib 不同。
|
|
1582
|
+
用法: DRAWRECTREL(left,top,right,bottom,color), 以图形窗口 (left, top) 为左上角, (right, bottom) 为
|
|
1583
|
+
右下角绘制矩形, 坐标单位是窗口沿水平和垂直方向的1/1000,取值范围是0—999,超出范围则可能显示在图形窗口外,矩形
|
|
1584
|
+
中间填充颜色COLOR,COLOR为0表示不填充.
|
|
1585
|
+
例如:DRAWRECTREL(0,0,500,500,RGB(255,255,0)) 表示在图形最左上部1/4位置用黄色绘制矩形
|
|
1586
|
+
|
|
1587
|
+
Args:
|
|
1588
|
+
left (int): 左上角x
|
|
1589
|
+
top (int): 左上角y
|
|
1590
|
+
right (int): 右下角x
|
|
1591
|
+
bottom (int): 右下角y
|
|
1592
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1593
|
+
frame (bool, optional): 添加边框. Defaults to False.
|
|
1594
|
+
fill (bool, optional): 颜色填充. Defaults to True.
|
|
1595
|
+
alpha (float, optional): 透明度. Defaults to 0.1.
|
|
1596
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1597
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1598
|
+
"""
|
|
1599
|
+
if axes is None:
|
|
1600
|
+
axes = create_figure() if new else gca()
|
|
1601
|
+
|
|
1602
|
+
x0, x1 = axes.get_xlim()
|
|
1603
|
+
y0, y1 = axes.get_ylim()
|
|
1604
|
+
w = x1 - x0
|
|
1605
|
+
h = y1 - y0
|
|
1606
|
+
|
|
1607
|
+
limit = 1000
|
|
1608
|
+
cx = w / limit
|
|
1609
|
+
cy = h / limit
|
|
1610
|
+
x = left * cx + x0
|
|
1611
|
+
y = (limit - bottom) * cy + y0
|
|
1612
|
+
width = (right - left) * cx
|
|
1613
|
+
height = (bottom - top) * cy
|
|
1614
|
+
print(x, y, width, height)
|
|
1615
|
+
if frame:
|
|
1616
|
+
rect = Rectangle(xy=(x, y), width=width, height=height, facecolor=color, edgecolor=color, fill=fill)
|
|
1617
|
+
else:
|
|
1618
|
+
rect = Rectangle(xy=(x, y), width=width, height=height, facecolor=color, fill=fill)
|
|
1619
|
+
rect.set_alpha(alpha)
|
|
1620
|
+
axes.add_patch(rect)
|