Full Code of bbfamily/abu for AI

master d602d847677e cached
327 files
33.4 MB
4.0M tokens
2158 symbols
1 requests
Copy disabled (too large) Download .txt
Showing preview only (16,070K chars total). Download the full file to get everything.
Repository: bbfamily/abu
Branch: master
Commit: d602d847677e
Files: 327
Total size: 33.4 MB

Directory structure:
gitextract_odeghj84/

├── .gitattributes
├── .gitignore
├── LICENSE
├── abupy/
│   ├── AlphaBu/
│   │   ├── ABuAlpha.py
│   │   ├── ABuPickBase.py
│   │   ├── ABuPickStockExecute.py
│   │   ├── ABuPickStockMaster.py
│   │   ├── ABuPickStockWorker.py
│   │   ├── ABuPickTimeExecute.py
│   │   ├── ABuPickTimeMaster.py
│   │   ├── ABuPickTimeWorker.py
│   │   └── __init__.py
│   ├── BetaBu/
│   │   ├── ABuAtrPosition.py
│   │   ├── ABuBeta.py
│   │   ├── ABuKellyPosition.py
│   │   ├── ABuPositionBase.py
│   │   ├── ABuPtPosition.py
│   │   └── __init__.py
│   ├── CheckBu/
│   │   ├── ABuChecker.py
│   │   ├── ABuChecks.py
│   │   ├── ABuFuncUtil.py
│   │   ├── ABuProcessor.py
│   │   └── __init__.py
│   ├── CoreBu/
│   │   ├── ABu.py
│   │   ├── ABuBase.py
│   │   ├── ABuDeprecated.py
│   │   ├── ABuEnv.py
│   │   ├── ABuEnvProcess.py
│   │   ├── ABuFixes.py
│   │   ├── ABuParallel.py
│   │   ├── ABuPdHelper.py
│   │   ├── ABuStore.py
│   │   └── __init__.py
│   ├── CrawlBu/
│   │   ├── ABuXqApi.py
│   │   ├── ABuXqConsts.py
│   │   ├── ABuXqCrawl.py
│   │   ├── ABuXqCrawlImp.py
│   │   ├── ABuXqFile.py
│   │   └── __init__.py
│   ├── DLBu/
│   │   ├── ABuDL.py
│   │   ├── ABuDLImgStd.py
│   │   ├── ABuDLTVSplit.py
│   │   ├── __init__.py
│   │   ├── pb/
│   │   │   ├── deploy.prototxt
│   │   │   ├── solver.prototxt
│   │   │   └── train_val.prototxt
│   │   └── sh/
│   │       ├── Lmdb.sh
│   │       ├── Mean.sh
│   │       └── Train.sh
│   ├── ExtBu/
│   │   ├── __init__.py
│   │   ├── empyrical/
│   │   │   ├── __init__.py
│   │   │   ├── _version.py
│   │   │   ├── stats.py
│   │   │   └── utils.py
│   │   ├── funcsigs.py
│   │   ├── futures/
│   │   │   ├── __init__.py
│   │   │   ├── _base.py
│   │   │   ├── process.py
│   │   │   └── thread.py
│   │   ├── joblib/
│   │   │   ├── __init__.py
│   │   │   ├── _compat.py
│   │   │   ├── _memory_helpers.py
│   │   │   ├── _multiprocessing_helpers.py
│   │   │   ├── _parallel_backends.py
│   │   │   ├── disk.py
│   │   │   ├── format_stack.py
│   │   │   ├── func_inspect.py
│   │   │   ├── hashing.py
│   │   │   ├── logger.py
│   │   │   ├── memory.py
│   │   │   ├── my_exceptions.py
│   │   │   ├── numpy_pickle.py
│   │   │   ├── numpy_pickle_compat.py
│   │   │   ├── numpy_pickle_utils.py
│   │   │   ├── parallel.py
│   │   │   ├── pool.py
│   │   │   └── testing.py
│   │   ├── odict.py
│   │   └── six.py
│   ├── FactorBuyBu/
│   │   ├── ABuBuyFactorWrap.py
│   │   ├── ABuFactorBuyBase.py
│   │   ├── ABuFactorBuyBreak.py
│   │   ├── ABuFactorBuyDM.py
│   │   ├── ABuFactorBuyDemo.py
│   │   ├── ABuFactorBuyTrend.py
│   │   ├── ABuFactorBuyWD.py
│   │   └── __init__.py
│   ├── FactorSellBu/
│   │   ├── ABuFS.py
│   │   ├── ABuFactorAtrNStop.py
│   │   ├── ABuFactorCloseAtrNStop.py
│   │   ├── ABuFactorPreAtrNStop.py
│   │   ├── ABuFactorSellBase.py
│   │   ├── ABuFactorSellBreak.py
│   │   ├── ABuFactorSellDM.py
│   │   ├── ABuFactorSellNDay.py
│   │   └── __init__.py
│   ├── IndicatorBu/
│   │   ├── ABuND.py
│   │   ├── ABuNDAtr.py
│   │   ├── ABuNDBase.py
│   │   ├── ABuNDBoll.py
│   │   ├── ABuNDMa.py
│   │   ├── ABuNDMacd.py
│   │   ├── ABuNDRsi.py
│   │   └── __init__.py
│   ├── MLBu/
│   │   ├── ABuML.py
│   │   ├── ABuMLApi.py
│   │   ├── ABuMLBinsCs.py
│   │   ├── ABuMLCreater.py
│   │   ├── ABuMLExecute.py
│   │   ├── ABuMLGrid.py
│   │   ├── ABuMLPd.py
│   │   └── __init__.py
│   ├── MarketBu/
│   │   ├── ABuDataBase.py
│   │   ├── ABuDataCache.py
│   │   ├── ABuDataCheck.py
│   │   ├── ABuDataFeed.py
│   │   ├── ABuDataParser.py
│   │   ├── ABuDataSource.py
│   │   ├── ABuHkUnit.py
│   │   ├── ABuIndustries.py
│   │   ├── ABuMarket.py
│   │   ├── ABuMarketDrawing.py
│   │   ├── ABuNetWork.py
│   │   ├── ABuSymbol.py
│   │   ├── ABuSymbolFutures.py
│   │   ├── ABuSymbolPd.py
│   │   ├── ABuSymbolStock.py
│   │   └── __init__.py
│   ├── MetricsBu/
│   │   ├── ABuCrossVal.py
│   │   ├── ABuGridHelper.py
│   │   ├── ABuGridSearch.py
│   │   ├── ABuMetrics.py
│   │   ├── ABuMetricsBase.py
│   │   ├── ABuMetricsFutures.py
│   │   ├── ABuMetricsScore.py
│   │   ├── ABuMetricsTC.py
│   │   └── __init__.py
│   ├── PickStockBu/
│   │   ├── ABuPickRegressAngMinMax.py
│   │   ├── ABuPickSimilarNTop.py
│   │   ├── ABuPickStock.py
│   │   ├── ABuPickStockBase.py
│   │   ├── ABuPickStockDemo.py
│   │   ├── ABuPickStockPriceMinMax.py
│   │   └── __init__.py
│   ├── RomDataBu/
│   │   ├── futures_cn.csv
│   │   ├── futures_gb.csv
│   │   ├── hk_unit.csv
│   │   ├── hq_nav.txt
│   │   ├── ml_test.csv
│   │   ├── stock_code_CN.csv
│   │   ├── stock_code_HK.csv
│   │   ├── stock_code_US.csv
│   │   ├── stock_code_cn.txt
│   │   ├── stock_code_hk.txt
│   │   └── stock_code_us.txt
│   ├── SimilarBu/
│   │   ├── ABuCorrcoef.py
│   │   ├── ABuSimilar.py
│   │   ├── ABuSimilarCache.py
│   │   ├── ABuSimilarDrawing.py
│   │   └── __init__.py
│   ├── SlippageBu/
│   │   ├── ABuSlippage.py
│   │   ├── ABuSlippageBuyBase.py
│   │   ├── ABuSlippageBuyMean.py
│   │   ├── ABuSlippageSellBase.py
│   │   ├── ABuSlippageSellMean.py
│   │   └── __init__.py
│   ├── TLineBu/
│   │   ├── ABuTL.py
│   │   ├── ABuTLAtr.py
│   │   ├── ABuTLExecute.py
│   │   ├── ABuTLGolden.py
│   │   ├── ABuTLJump.py
│   │   ├── ABuTLSimilar.py
│   │   ├── ABuTLVwap.py
│   │   ├── ABuTLWave.py
│   │   ├── ABuTLine.py
│   │   └── __init__.py
│   ├── TradeBu/
│   │   ├── ABuBenchmark.py
│   │   ├── ABuCapital.py
│   │   ├── ABuCommission.py
│   │   ├── ABuKLManager.py
│   │   ├── ABuMLFeature.py
│   │   ├── ABuOrder.py
│   │   ├── ABuTradeDrawer.py
│   │   ├── ABuTradeExecute.py
│   │   ├── ABuTradeProxy.py
│   │   └── __init__.py
│   ├── UmpBu/
│   │   ├── ABuUmp.py
│   │   ├── ABuUmpBase.py
│   │   ├── ABuUmpEdgeBase.py
│   │   ├── ABuUmpEdgeDeg.py
│   │   ├── ABuUmpEdgeFull.py
│   │   ├── ABuUmpEdgeMul.py
│   │   ├── ABuUmpEdgePrice.py
│   │   ├── ABuUmpEdgeWave.py
│   │   ├── ABuUmpMainBase.py
│   │   ├── ABuUmpMainDeg.py
│   │   ├── ABuUmpMainFull.py
│   │   ├── ABuUmpMainJump.py
│   │   ├── ABuUmpMainMul.py
│   │   ├── ABuUmpMainPrice.py
│   │   ├── ABuUmpMainWave.py
│   │   ├── ABuUmpManager.py
│   │   └── __init__.py
│   ├── UtilBu/
│   │   ├── ABuDTUtil.py
│   │   ├── ABuDateUtil.py
│   │   ├── ABuDelegateUtil.py
│   │   ├── ABuFileUtil.py
│   │   ├── ABuKLUtil.py
│   │   ├── ABuLazyUtil.py
│   │   ├── ABuMacUtil.py
│   │   ├── ABuMd5.py
│   │   ├── ABuOsUtil.py
│   │   ├── ABuPlatform.py
│   │   ├── ABuProgress.py
│   │   ├── ABuRegUtil.py
│   │   ├── ABuScalerUtil.py
│   │   ├── ABuStatsUtil.py
│   │   ├── ABuStrUtil.py
│   │   ├── ABuWinUtil.py
│   │   └── __init__.py
│   ├── WidgetBu/
│   │   ├── ABuWGBFBase.py
│   │   ├── ABuWGBRun.py
│   │   ├── ABuWGBRunBase.py
│   │   ├── ABuWGBSymbol.py
│   │   ├── ABuWGBase.py
│   │   ├── ABuWGBuyFactor.py
│   │   ├── ABuWGCrossVal.py
│   │   ├── ABuWGDATool.py
│   │   ├── ABuWGGridSearch.py
│   │   ├── ABuWGPSBase.py
│   │   ├── ABuWGPickStock.py
│   │   ├── ABuWGPosBase.py
│   │   ├── ABuWGPosition.py
│   │   ├── ABuWGQuantTool.py
│   │   ├── ABuWGSFBase.py
│   │   ├── ABuWGSMTool.py
│   │   ├── ABuWGSellFactor.py
│   │   ├── ABuWGStockInfo.py
│   │   ├── ABuWGTLTool.py
│   │   ├── ABuWGToolBase.py
│   │   ├── ABuWGUmp.py
│   │   ├── ABuWGUpdate.py
│   │   ├── ABuWGVerifyTool.py
│   │   └── __init__.py
│   └── __init__.py
├── abupy_lecture/
│   ├── 0-abupy量化环境部署(ABU量化使用文档).ipynb
│   ├── 1-择时策略的开发(ABU量化使用文档).ipynb
│   ├── 10-比特币莱特币的回测(ABU量化使用文档).ipynb
│   ├── 11-期货市场的回测(ABU量化使用文档).ipynb
│   ├── 12-机器学习与比特币示例(ABU量化使用文档).ipynb
│   ├── 13-量化技术分析应用(ABU量化使用文档).ipynb
│   ├── 14-量化相关性分析应用(ABU量化使用文档).ipynb
│   ├── 15-量化交易和搜索引擎(ABU量化使用文档).ipynb
│   ├── 16-UMP主裁交易决策(ABU量化使用文档).ipynb
│   ├── 17-UMP边裁交易决策(ABU量化使用文档).ipynb
│   ├── 18-自定义裁判决策交易(ABU量化使用文档).ipynb
│   ├── 19-数据源(ABU量化使用文档).ipynb
│   ├── 2-择时策略的优化(ABU量化使用文档).ipynb
│   ├── 20-A股全市场回测(ABU量化使用文档).ipynb
│   ├── 21-A股UMP决策(ABU量化使用文档).ipynb
│   ├── 22-美股全市场回测(ABU量化使用文档).ipynb
│   ├── 23-美股UMP决策(ABU量化使用文档).ipynb
│   ├── 24-比特币vs黄金,莱特币vs白银(ABU量化使用文档).ipynb
│   ├── 25-期货市场内外盘低频统计套利.ipynb
│   ├── 26-星期几是这个股票的好日子.ipynb
│   ├── 27-狗股选股策略与择时策略的配合.ipynb
│   ├── 28-真 • 动态自适应双均线策略.ipynb
│   ├── 29-多因子策略并行执行配合.ipynb
│   ├── 3-滑点策略与交易手续费(ABU量化使用文档).ipynb
│   ├── 30-趋势跟踪与均值回复的长短线搭配.ipynb
│   ├── 31-资金仓位管理与买入策略的搭配.ipynb
│   ├── 32-策略有效性的验证.ipynb
│   ├── 4-多支股票择时回测与仓位管理(ABU量化使用文档).ipynb
│   ├── 5-选股策略的开发(ABU量化使用文档).ipynb
│   ├── 6-回测结果的度量(ABU量化使用文档).ipynb
│   ├── 7-寻找策略最优参数和评分(ABU量化使用文档).ipynb
│   ├── 8-A股市场的回测(ABU量化使用文档).ipynb
│   └── 9-港股市场的回测(ABU量化使用文档).ipynb
├── abupy_ui/
│   ├── readme.md
│   ├── widget_base.py
│   ├── widget_loop_back.py
│   ├── widget_quant_tool.py
│   ├── widget_stock_info.py
│   ├── widget_update_ui.py
│   ├── widget_verify_tool.py
│   ├── 历史回测界面操作.ipynb
│   ├── 参数最优交叉验证.ipynb
│   ├── 数据下载界面操作.ipynb
│   ├── 股票基本信息查询.ipynb
│   └── 量化分析工具操作.ipynb
├── gen/
│   └── stock_day_change.npy
├── ipython/
│   ├── readme.md
│   ├── 第七章-量化系统——入门.ipynb
│   ├── 第三章-量化工具——NumPy.ipynb
│   ├── 第九章-量化系统——度量与优化.ipynb
│   ├── 第二章-量化语言——Python.ipynb
│   ├── 第五章-量化工具——可视化.ipynb
│   ├── 第八章-量化系统——开发.ipynb
│   ├── 第六章-量化工具——数学.ipynb
│   ├── 第十一章-量化系统——机器学习•ABU.ipynb
│   ├── 第十章-量化系统——机器学习•猪老三.ipynb
│   ├── 第四章-量化工具——pandas.ipynb
│   ├── 附录A-量化环境部署.ipynb
│   ├── 附录B-量化相关性分析.ipynb
│   └── 附录C-量化统计分析及指标应用.ipynb
├── python/
│   ├── abu_local_env.py
│   ├── c10.py
│   ├── c11.py
│   ├── c2.py
│   ├── c3.py
│   ├── c4.py
│   ├── c5.py
│   ├── c6.py
│   ├── c7.py
│   ├── c8.py
│   ├── c9.py
│   ├── extA.py
│   ├── extB.py
│   ├── extC.py
│   ├── happy_life.py
│   ├── readme.md
│   ├── stock_days.py
│   └── stock_dream_ml.py
├── readme-en.md
├── readme.md
└── 界面操作视频教程/
    ├── 第26节星期几是这个股票的好日子界面操作视频.md
    └── 第一节界面操作视频教程.md

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
*.ipynb linguist-language=Python

================================================
FILE: .gitignore
================================================
.ipynb_checkpoints*
.idea
.DS_Store
logging.log
p.sh
*.pyc
tmp
test.py
/abupy/RomDataBu/df_kl.h5

================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    阿布量化系统(股票,期权,期货,比特币,机器学习) http://www.abuquant.com/
    Copyright (C) 2017  阿布

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    阿布量化  Copyright (C) 2017  阿布
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

================================================
FILE: abupy/AlphaBu/ABuAlpha.py
================================================
from __future__ import absolute_import

# noinspection PyUnresolvedReferences
from .ABuPickStockExecute import do_pick_stock_work
# noinspection PyUnresolvedReferences
from .ABuPickTimeExecute import do_symbols_with_same_factors, do_symbols_with_diff_factors
# noinspection all
from . import ABuPickTimeWorker as pick_time_worker


================================================
FILE: abupy/AlphaBu/ABuPickBase.py
================================================
# -*- encoding:utf-8 -*-
"""
    择时与选股抽象基类
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

from abc import ABCMeta, abstractmethod

from ..CoreBu.ABuFixes import six
from ..CoreBu.ABuBase import AbuParamBase

__author__ = '阿布'
__weixin__ = 'abu_quant'


class AbuPickTimeWorkBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    """择时抽象基类"""

    @abstractmethod
    def fit(self, *args, **kwargs):
        """
        fit在整个项目中的意义为开始对象最重要的工作,
        对于择时对象即为开始择时操作,或者从字面理解
        开始针对交易数据进行拟合择时操作
        """
        pass

    @abstractmethod
    def init_sell_factors(self, *args, **kwargs):
        """
        初始化择时卖出因子
        """
        pass

    @abstractmethod
    def init_buy_factors(self, *args, **kwargs):
        """
        初始化择时买入因子
        """
        pass


class AbuPickStockWorkBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    """选股抽象基"""

    @abstractmethod
    def fit(self, *args, **kwargs):
        """
        fit在整个项目中的意义为开始对象最重要的工作,
        对于选股对象即为开始选股操作,或者从字面理解
        开始针对交易数据进行拟合选股操作
        """
        pass

    @abstractmethod
    def init_stock_pickers(self, *args, **kwargs):
        """
        初始化选股因子
        """
        pass


================================================
FILE: abupy/AlphaBu/ABuPickStockExecute.py
================================================
# -*- encoding:utf-8 -*-
"""
    包装选股worker进行,完善前后工作
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

from .ABuPickStockWorker import AbuPickStockWorker
from ..CoreBu.ABuEnvProcess import add_process_env_sig
from ..MarketBu.ABuMarket import split_k_market
from ..TradeBu.ABuKLManager import AbuKLManager
from ..CoreBu.ABuFixes import ThreadPoolExecutor

__author__ = '阿布'
__weixin__ = 'abu_quant'


@add_process_env_sig
def do_pick_stock_work(choice_symbols, benchmark, capital, stock_pickers):
    """
    包装AbuPickStockWorker进行选股
    :param choice_symbols: 初始备选交易对象序列
    :param benchmark: 交易基准对象,AbuBenchmark实例对象
    :param capital: 资金类AbuCapital实例化对象
    :param stock_pickers: 选股因子序列
    :return:
    """
    kl_pd_manager = AbuKLManager(benchmark, capital)
    stock_pick = AbuPickStockWorker(capital, benchmark, kl_pd_manager, choice_symbols=choice_symbols,
                                    stock_pickers=stock_pickers)
    stock_pick.fit()
    return stock_pick.choice_symbols


@add_process_env_sig
def do_pick_stock_thread_work(choice_symbols, benchmark, capital, stock_pickers, n_thread):
    """包装AbuPickStockWorker启动线程进行选股"""
    result = []

    def when_thread_done(r):
        result.extend(r.result())

    with ThreadPoolExecutor(max_workers=n_thread) as pool:
        thread_symbols = split_k_market(n_thread, market_symbols=choice_symbols)
        for symbols in thread_symbols:
            future_result = pool.submit(do_pick_stock_work, symbols, benchmark, capital, stock_pickers)
            future_result.add_done_callback(when_thread_done)

    return result


================================================
FILE: abupy/AlphaBu/ABuPickStockMaster.py
================================================
# -*- encoding:utf-8 -*-
"""
    选股并行多任务调度模块
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import itertools
import logging


from .ABuPickStockExecute import do_pick_stock_work, do_pick_stock_thread_work
from ..CoreBu import ABuEnv
from ..CoreBu.ABuEnv import EMarketDataFetchMode
from ..CoreBu.ABuEnvProcess import AbuEnvProcess
from ..MarketBu.ABuMarket import split_k_market, all_symbol
from ..MarketBu import ABuMarket
from ..CoreBu.ABuFixes import partial
from ..CoreBu.ABuParallel import delayed, Parallel
from ..CoreBu.ABuDeprecated import AbuDeprecated


class AbuPickStockMaster(object):
    """选股并行多任务调度类"""

    @classmethod
    def do_pick_stock_with_process(cls, capital, benchmark, stock_pickers, choice_symbols=None,
                                   n_process_pick_stock=ABuEnv.g_cpu_cnt,
                                   callback=None):
        """
        选股并行多任务对外接口
        :param capital: 资金类AbuCapital实例化对象
        :param benchmark: 交易基准对象,AbuBenchmark实例对象
        :param stock_pickers: 选股因子序列
        :param choice_symbols: 初始备选交易对象序列
        :param n_process_pick_stock: 控制启动多少进程并行选股操作
        :param callback: 并行选股工作函数
        :return: 最终选股结果序列
        """
        input_choice_symbols = True
        if choice_symbols is None or len(choice_symbols) == 0:
            choice_symbols = all_symbol()
            input_choice_symbols = False

        if n_process_pick_stock <= 0:
            # 因为下面要n_process > 1做判断而且要根据n_process_pick_stock来split_k_market
            n_process_pick_stock = ABuEnv.g_cpu_cnt
        if stock_pickers is not None:

            # TODO 需要区分hdf5和csv不同存贮情况,csv存贮模式下可以并行读写
            # 只有E_DATA_FETCH_FORCE_LOCAL才进行多任务模式,否则回滚到单进程模式n_process = 1
            if n_process_pick_stock > 1 and ABuEnv.g_data_fetch_mode != EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL:
                # 1. hdf5多进程容易写坏数据,所以只多进程读取,不并行写入
                # 2. MAC OS 10.9 之后并行联网+numpy 系统bug crash,卡死等问题
                logging.info('batch get only support E_DATA_FETCH_FORCE_LOCAL for Parallel!')
                n_process_pick_stock = 1

            # 根据输入的choice_symbols和要并行的进程数,分配symbol到n_process_pick_stock进程中
            process_symbols = split_k_market(n_process_pick_stock, market_symbols=choice_symbols)

            # 因为切割会有余数,所以将原始设置的进程数切换为分割好的个数, 即32 -> 33 16 -> 17
            if n_process_pick_stock > 1:
                n_process_pick_stock = len(process_symbols)

            parallel = Parallel(
                n_jobs=n_process_pick_stock, verbose=0, pre_dispatch='2*n_jobs')

            if callback is None:
                callback = do_pick_stock_work

            # do_pick_stock_work被装饰器add_process_env_sig装饰,需要进程间内存拷贝对象AbuEnvProcess
            p_nev = AbuEnvProcess()
            # 开始并行任务执行
            out_choice_symbols = parallel(delayed(callback)(choice_symbols, benchmark,
                                                            capital,
                                                            stock_pickers, env=p_nev)
                                          for choice_symbols in process_symbols)

            # 将每一个进程返回的选股序列合并成一个序列
            choice_symbols = list(itertools.chain.from_iterable(out_choice_symbols))

        """
            如下通过env中的设置来切割训练集,测试集数据,或者直接使用训练集,测试集,
            注意现在的设置有优先级,即g_enable_last_split_test > g_enable_last_split_train > g_enable_train_test_split
            TODO: 使用enum替换g_enable_last_split_test, g_enable_last_split_train, g_enable_train_test_split设置
        """
        if not input_choice_symbols and ABuEnv.g_enable_last_split_test:
            # 只使用上次切割好的测试集交易对象
            choice_symbols = ABuMarket.market_last_split_test()
        elif not input_choice_symbols and ABuEnv.g_enable_last_split_train:
            # 只使用上次切割好的训练集交易对象
            choice_symbols = ABuMarket.market_last_split_train()
        elif ABuEnv.g_enable_train_test_split:
            # 切割训练集交易对象与测试集交易对象,返回训练集交易对象
            choice_symbols = ABuMarket.market_train_test_split(ABuEnv.g_split_tt_n_folds, choice_symbols)

        return choice_symbols

    @classmethod
    @AbuDeprecated('hdf5 store mode will crash or dead!')
    def do_pick_stock_with_process_mix_thread(cls, capital, benchmark, stock_pickers, choice_symbols=None, n_process=8,
                                              n_thread=10):
        """Deprecated不应该使用,因为默认hdf5多线程读取会有问题"""
        callback = partial(do_pick_stock_thread_work, n_thread=n_thread)
        return cls.do_pick_stock_with_process(capital, benchmark, stock_pickers, choice_symbols=choice_symbols,
                                              n_process_pick_stock=n_process, callback=callback)


================================================
FILE: abupy/AlphaBu/ABuPickStockWorker.py
================================================
# -*- encoding:utf-8 -*-
"""
    选股具体工作者,整合金融时间序列,选股因子,资金类进行
    选股操作,在择时金融时间序列之前一段时间上迭代初始交易对象
    进行选股因子的拟合操作
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import copy

from .ABuPickBase import AbuPickStockWorkBase
from ..MarketBu.ABuMarket import all_symbol
from ..PickStockBu.ABuPickStockBase import AbuPickStockBase
from ..UtilBu.ABuProgress import AbuMulPidProgress

__author__ = '阿布'
__weixin__ = 'abu_quant'


class AbuPickStockWorker(AbuPickStockWorkBase):
    """选股类"""

    def __init__(self, capital, benchmark, kl_pd_manager, choice_symbols=None, stock_pickers=None):
        """
        :param capital: 资金类AbuCapital实例化对象
        :param benchmark: 交易基准对象,AbuBenchmark实例对象
        :param kl_pd_manager: 金融时间序列管理对象,AbuKLManager实例
        :param choice_symbols: 初始备选交易对象序列
        :param stock_pickers: 选股因子序列
        """
        self.capital = capital
        self.benchmark = benchmark
        self.choice_symbols = choice_symbols
        self.kl_pd_manager = kl_pd_manager
        self.stock_pickers = []
        self.first_stock_pickers = []
        self.init_stock_pickers(stock_pickers)

    def __str__(self):
        """打印对象显示:选股因子序列+选股交易对象"""
        return 'stock_pickers:{}\nchoice_symbols:{}'.format(self.stock_pickers, self.choice_symbols)

    __repr__ = __str__

    def init_stock_pickers(self, stock_pickers):
        """
        通过stock_pickers实例化各个选股因子
        :param stock_pickers:list中元素为dict,每个dict为因子的构造元素,如class,构造参数等
        :return:
        """
        if stock_pickers is not None:
            for picker_class in stock_pickers:
                if picker_class is None:
                    continue

                if 'class' not in picker_class:
                    # 必须要有需要实例化的类信息
                    raise ValueError('picker_class class key must name class !!!')

                picker_class_cp = copy.deepcopy(picker_class)
                # pop出类信息后剩下的都为类需要的参数
                class_fac = picker_class_cp.pop('class')
                # 整合capital,benchmark等实例化因子对象
                picker = class_fac(self.capital, self.benchmark, **picker_class_cp)

                if not isinstance(picker, AbuPickStockBase):
                    # 因子对象类型检测
                    raise TypeError('factor must base AbuPickStockBase')

                if 'first_choice' in picker_class and picker_class['first_choice']:
                    # 如果参数设置first_choice且是True, 添加到first_stock_pickers选股序列
                    self.first_stock_pickers.append(picker)
                else:
                    self.stock_pickers.append(picker)
        if self.choice_symbols is None or len(self.choice_symbols) == 0:
            # 如果参数中初始备选交易对象序列为none, 从对应市场中获取所有的交易对象,详情查阅all_symbol
            self.choice_symbols = all_symbol()

    def fit(self):
        """
        选股开始工作,与择时不同,选股是数据多对多,
        即多个交易对象对多个选股因子配合资金基准等参数工作
        :return:
        """

        def _first_batch_fit():
            """
            first_choice选股:针对备选池进行选股,迭代选股因子,使用因子的fit_first_choice方法
            即因子内部提供批量选股高效的首选方法
            :return:
            """
            if self.first_stock_pickers is None or len(self.first_stock_pickers) == 0:
                # 如果没有first_stock_picker要返回self.choice_symbols,代表没有投任何反对票,全部通过
                return self.choice_symbols

            # 首选将所有备选对象赋予inner_first_choice_symbols
            inner_first_choice_symbols = self.choice_symbols
            with AbuMulPidProgress(len(self.first_stock_pickers), 'pick first_choice stocks complete') as progress:
                for epoch, first_choice in enumerate(self.first_stock_pickers):
                    progress.show(epoch + 1)
                    # 每一个选股因子通过fit_first_choice对inner_first_choice_symbols进行筛选,滤网一层一层过滤
                    inner_first_choice_symbols = first_choice.fit_first_choice(self, inner_first_choice_symbols)
            return inner_first_choice_symbols

        def _batch_fit():
            """
            普通选股:针对备选池进行选股,迭代初始选股序列,在迭代中再迭代选股因子,选股因子决定是否对
            symbol投出反对票,一旦一个因子投出反对票,即筛出序列,一票否决
            :return:
            """
            if self.stock_pickers is None or len(self.stock_pickers) == 0:
                # 如果没有stock_pickers要返回self.choice_symbols,代表没有投任何反对票,全部通过
                return self.choice_symbols

            with AbuMulPidProgress(len(self.choice_symbols), 'pick stocks complete') as progress:
                # 启动选股进度显示
                inner_choice_symbols = []
                for epoch, target_symbol in enumerate(self.choice_symbols):
                    progress.show(epoch + 1)

                    add = True
                    for picker in self.stock_pickers:
                        kl_pd = self.kl_pd_manager.get_pick_stock_kl_pd(target_symbol, picker.xd, picker.min_xd)
                        if kl_pd is None:
                            # 注意get_pick_stock_kl_pd内部对选股金融序列太少的情况进行过滤,详情get_pick_stock_kl_pd
                            add = False
                            break
                        sub_add = picker.fit_pick(kl_pd, target_symbol)
                        if sub_add is False:
                            # 只要一个选股因子投了反对票,就刷出
                            add = False
                            break
                    if add:
                        inner_choice_symbols.append(target_symbol)
                return inner_choice_symbols

        # 筛选各个因first_choice序列,返回给self.choice_symbols,_batch_fit继续晒
        self.choice_symbols = _first_batch_fit()
        # 通过两次迭代继续筛选
        self.choice_symbols = _batch_fit()


================================================
FILE: abupy/AlphaBu/ABuPickTimeExecute.py
================================================
# -*- encoding:utf-8 -*-
"""
    多支交易对象进行择时操作封装模块,内部通过AbuPickTimeWorker进行
    择时,包装完善前后工作,包括多进程下的进度显示,错误处理捕获,结果
    处理等事务
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import logging

import numpy as np
import pandas as pd
from enum import Enum

from .ABuPickTimeWorker import AbuPickTimeWorker
from ..CoreBu.ABuEnvProcess import add_process_env_sig
from ..TradeBu import ABuTradeExecute
from ..TradeBu import ABuTradeProxy
from ..TradeBu.ABuKLManager import AbuKLManager
from ..UtilBu.ABuProgress import AbuMulPidProgress

__author__ = '阿布'
__weixin__ = 'abu_quant'


class EFitError(Enum):
    """
        择时操作的错误码
    """

    # 择时操作正常完成,且至少生成一个order
    FIT_OK = 0
    # 择时对象数据获取错误
    NET_ERROR = 1
    # 择时对象数据错误
    DATE_ERROR = 2
    # 择时操作正常完成,但没有生成一个order
    NO_ORDER_GEN = 3
    # 其它错误
    OTHER_ERROR = 4


def _do_pick_time_work(capital, buy_factors, sell_factors, kl_pd, benchmark, draw=False,
                       show_info=False, show_pg=False):
    """
    内部方法:包装AbuPickTimeWorker进行fit,分配错误码,通过trade_summary生成orders_pd,action_pd
    :param capital: AbuCapital实例对象
    :param buy_factors: 买入因子序列
    :param sell_factors: 卖出因子序列
    :param kl_pd: 金融时间序列
    :param benchmark: 交易基准对象,AbuBenchmark实例对象
    :param draw: 是否绘制在对应的金融时间序列上的交易行为
    :param show_info: 是否显示在整个金融时间序列上的交易结果
    :param show_pg: 是否择时内部启动进度条,适合单进程或者每个进程里只有一个symbol进行择时
    :return:
    """
    if kl_pd is None or kl_pd.shape[0] == 0:
        return None, EFitError.NET_ERROR

    pick_timer_worker = AbuPickTimeWorker(capital, kl_pd, benchmark, buy_factors, sell_factors)
    if show_pg:
        pick_timer_worker.enable_task_pg()
    pick_timer_worker.fit()

    if len(pick_timer_worker.orders) == 0:
        # 择时金融时间序列拟合操作后,没有任何order生成
        return None, EFitError.NO_ORDER_GEN

    # 生成关键的orders_pd与action_pd
    orders_pd, action_pd, _ = ABuTradeProxy.trade_summary(pick_timer_worker.orders, kl_pd, draw=draw,
                                                          show_info=show_info)

    # 最后生成list是因为tuple无法修改导致之后不能灵活处理
    return [orders_pd, action_pd], EFitError.FIT_OK


@add_process_env_sig
def do_symbols_with_same_factors(target_symbols, benchmark, buy_factors, sell_factors, capital,
                                 apply_capital=True, kl_pd_manager=None,
                                 show=False, back_target_symbols=None, func_factors=None, show_progress=True):
    """
    输入为多个择时交易对象,以及相同的择时买入,卖出因子序列,对多个交易对象上实施相同的因子
    :param target_symbols: 多个择时交易对象序列
    :param benchmark: 交易基准对象,AbuBenchmark实例对象
    :param buy_factors: 买入因子序列
    :param sell_factors: 卖出因子序列
    :param capital: AbuCapital实例对象
    :param apply_capital: 是否进行资金对象的融合,多进程环境下将是False
    :param kl_pd_manager: 金融时间序列管理对象,AbuKLManager实例
    :param show: 是否显示每个交易对象的交易细节
    :param back_target_symbols:  补位targetSymbols为了忽略网络问题及数据不足导致的问题
    :param func_factors: funcFactors在内层解开factors dicts为了do_symbols_with_diff_factors
    :param show_progress: 进度条显示,默认True
    """
    if kl_pd_manager is None:
        kl_pd_manager = AbuKLManager(benchmark, capital)

    def _batch_symbols_with_same_factors(p_buy_factors, p_sell_factors):
        r_orders_pd = None
        r_action_pd = None
        r_all_fit_symbols_cnt = 0
        # 启动多进程进度显示AbuMulPidProgress
        with AbuMulPidProgress(len(target_symbols), 'pick times complete', show_progress=show_progress) as progress:
            for epoch, target_symbol in enumerate(target_symbols):
                # 如果symbol只有一个就不show了,留给下面_do_pick_time_work中show_pg内部显示进度
                if len(target_symbols) > 1:
                    # 如果要绘制交易细节就不要clear了
                    progress.show(epoch + 1, clear=not show)

                if func_factors is not None and callable(func_factors):
                    # 针对do_symbols_with_diff_factors mul factors等情况嵌入可变因子
                    p_buy_factors, p_sell_factors = func_factors(target_symbol)
                try:
                    kl_pd = kl_pd_manager.get_pick_time_kl_pd(target_symbol)
                    ret, fit_error = _do_pick_time_work(capital, p_buy_factors, p_sell_factors, kl_pd, benchmark,
                                                        draw=show, show_info=show,
                                                        show_pg=(len(target_symbols) == 1 and show_progress))
                except Exception as e:
                    logging.exception(e)
                    continue

                if ret is None and back_target_symbols is not None:
                    # 择时结果错误或者没有order生成的情况下,如果有补位序列,择从序列中pop出一个,进行补位
                    if fit_error is not None and fit_error == EFitError.NO_ORDER_GEN:
                        # 没有order生成的要统计进去
                        r_all_fit_symbols_cnt += 1
                    while True:
                        if len(back_target_symbols) <= 0:
                            break
                        # pop出来代替原先的target
                        target_symbol = back_target_symbols.pop()
                        kl_pd = kl_pd_manager.get_pick_time_kl_pd(target_symbol)
                        ret, fit_error = _do_pick_time_work(capital, p_buy_factors, p_sell_factors, kl_pd, benchmark,
                                                            draw=show, show_info=show)
                        if fit_error == EFitError.NO_ORDER_GEN:
                            r_all_fit_symbols_cnt += 1
                        if ret is not None:
                            break
                if ret is None:
                    continue
                r_all_fit_symbols_cnt += 1
                # 连接每一个交易对象生成的orders_pd和action_pd
                r_orders_pd = ret[0] if r_orders_pd is None else pd.concat([r_orders_pd, ret[0]])
                r_action_pd = ret[1] if r_action_pd is None else pd.concat([r_action_pd, ret[1]])
        return r_orders_pd, r_action_pd, r_all_fit_symbols_cnt

    orders_pd, action_pd, all_fit_symbols_cnt = _batch_symbols_with_same_factors(buy_factors, sell_factors)
    if orders_pd is not None and action_pd is not None:

        # 要sort'Date', 'action'两项,不然之后的行apply_action_to_capital后有问题
        # noinspection PyUnresolvedReferences
        action_pd = action_pd.sort_values(['Date', 'action'])
        action_pd.index = np.arange(0, action_pd.shape[0])
        # noinspection PyUnresolvedReferences
        orders_pd = orders_pd.sort_values(['buy_date'])
        if apply_capital:
            # 如果非多进程环境下开始融合资金对象
            ABuTradeExecute.apply_action_to_capital(capital, action_pd, kl_pd_manager, show_progress=show_progress)

    return orders_pd, action_pd, all_fit_symbols_cnt


def do_symbols_with_diff_factors(target_symbols, benchmark, factor_dict, capital, apply_capital=True,
                                 kl_pd_manager=None,
                                 show=False,
                                 back_target_symbols=None):
    """
        输入为多个择时交易对象,每个交易对象有属于自己的买入,卖出因子,
        在factor_dict中通过对象唯一标识进行提取
    """

    def _func_factors(target_symbol):
        """
            定义do_symbols_with_same_factors中使用的对交易因子dict进行解包的方法
        """
        sub_dict = factor_dict[target_symbol]
        buy_factors = sub_dict['buy_factors']
        sell_factors = sub_dict['sell_factors']
        return buy_factors, sell_factors

    # 通过funcFactors在内层解开factors dict
    return do_symbols_with_same_factors(target_symbols, benchmark, None, None, capital, apply_capital=apply_capital,
                                        kl_pd_manager=kl_pd_manager,
                                        show=show,
                                        back_target_symbols=back_target_symbols,
                                        func_factors=_func_factors)


================================================
FILE: abupy/AlphaBu/ABuPickTimeMaster.py
================================================
# -*- encoding:utf-8 -*-
"""
    择时并行多任务调度模块
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
import pandas as pd

from .ABuPickTimeExecute import do_symbols_with_same_factors
from ..CoreBu.ABuEnvProcess import AbuEnvProcess
from ..CoreBu import ABuEnv
from ..CoreBu.ABuEnv import EMarketDataFetchMode
from ..MarketBu.ABuMarket import split_k_market
from ..TradeBu import ABuTradeExecute
from ..TradeBu.ABuKLManager import AbuKLManager
from ..CoreBu.ABuParallel import delayed, Parallel

__author__ = '阿布'
__weixin__ = 'abu_quant'


class AbuPickTimeMaster(object):
    """择时并行多任务调度类"""

    @classmethod
    def do_symbols_with_same_factors_process(cls, target_symbols, benchmark, buy_factors, sell_factors, capital,
                                             kl_pd_manager=None,
                                             n_process_kl=ABuEnv.g_cpu_cnt * 2 if ABuEnv.g_is_mac_os
                                             else ABuEnv.g_cpu_cnt,
                                             n_process_pick_time=ABuEnv.g_cpu_cnt,
                                             show_progress=True):
        """
        将多个交易对象拆解为多份交易对象序列,多任务并行完成择时工作
        :param target_symbols: 多个择时交易对象序列
        :param benchmark: 交易基准对象,AbuBenchmark实例对象
        :param buy_factors: 买入因子序列
        :param sell_factors: 卖出因子序列
        :param capital: AbuCapital实例对象
        :param kl_pd_manager: 金融时间序列管理对象,AbuKLManager实例
        :param n_process_kl: 控制金融时间序列管理对象内部启动n_process_kl进程获取金融序列数据
        :param n_process_pick_time: 控制择时操作并行任务数量
        :param show_progress: 显示进度条,透传do_symbols_with_same_factors,默认True
        """

        if kl_pd_manager is None:
            kl_pd_manager = AbuKLManager(benchmark, capital)
            # 一次性在主进程中执行多进程获取k线数据,全部放入kl_pd_manager中,内部启动n_process_kl个进程执行
            kl_pd_manager.batch_get_pick_time_kl_pd(target_symbols, n_process=n_process_kl, show_progress=show_progress)

        if n_process_pick_time <= 0:
            # 因为下面要根据n_process_pick_time来split_k_market
            n_process_pick_time = ABuEnv.g_cpu_cnt

        # 将target_symbols切割为n_process_pick_time个子序列,这样可以每个进程处理一个子序列
        process_symbols = split_k_market(n_process_pick_time, market_symbols=target_symbols)

        # 因为切割会有余数,所以将原始设置的进程数切换为分割好的个数, 即32 -> 33 16 -> 17
        n_process_pick_time = len(process_symbols)

        parallel = Parallel(
            n_jobs=n_process_pick_time, verbose=0, pre_dispatch='2*n_jobs')

        tmp_fetch_mode = ABuEnv.g_data_fetch_mode
        if n_process_pick_time > 1:
            # TODO 需要区分hdf5和csv不同存贮情况,csv存贮模式下可以并行读写
            # 因为上面已经并行或者单进程进行数据采集kl_pd_manager,之后的并行,为确保hdf5不会多进程读写设置LOCAL
            ABuEnv.g_data_fetch_mode == EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL

        # do_symbols_with_same_factors被装饰器add_process_env_sig装饰,需要进程间内存拷贝对象AbuEnvProcess
        p_nev = AbuEnvProcess()
        # 每个并行的进程通过do_symbols_with_same_factors及自己独立的子序列独立工作,注意kl_pd_manager装载了所有需要的数据
        out = parallel(delayed(do_symbols_with_same_factors)(choice_symbols, benchmark, buy_factors, sell_factors,
                                                             capital, apply_capital=False,
                                                             kl_pd_manager=kl_pd_manager, env=p_nev,
                                                             show_progress=show_progress)
                       for choice_symbols in process_symbols)
        # 择时并行结束后恢复之前的数据获取模式
        ABuEnv.g_data_fetch_mode = tmp_fetch_mode
        orders_pd = None
        action_pd = None
        all_fit_symbols_cnt = 0
        for sub_out in out:
            # 将每个子序列进程的处理结果进行合并
            sub_orders_pd, sub_action_pd, sub_all_fit_symbols_cnt = sub_out
            orders_pd = sub_orders_pd if orders_pd is None else pd.concat([orders_pd, sub_orders_pd])
            action_pd = sub_action_pd if action_pd is None else pd.concat([action_pd, sub_action_pd])
            all_fit_symbols_cnt += sub_all_fit_symbols_cnt

        if orders_pd is not None and action_pd is not None:
            # 将合并后的结果按照时间及行为进行排序
            # noinspection PyUnresolvedReferences
            action_pd = action_pd.sort_values(['Date', 'action'])
            action_pd.index = np.arange(0, action_pd.shape[0])
            # noinspection PyUnresolvedReferences
            orders_pd = orders_pd.sort_values(['buy_date'])
            # 最后将所有的action作用在资金上,生成资金时序,及判断是否能买入
            ABuTradeExecute.apply_action_to_capital(capital, action_pd, kl_pd_manager, show_progress=show_progress)

        return orders_pd, action_pd, all_fit_symbols_cnt


================================================
FILE: abupy/AlphaBu/ABuPickTimeWorker.py
================================================
# -*- encoding:utf-8 -*-
"""
    择时具体工作者,整合金融时间序列,买入因子,卖出因子,资金类进行
    择时操作,以时间驱动择时事件的发生
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import copy

import numpy as np

from ..MarketBu import ABuSymbolPd
from ..FactorBuyBu.ABuFactorBuyBase import AbuFactorBuyBase
from ..FactorSellBu.ABuFactorSellBase import AbuFactorSellBase
from .ABuPickBase import AbuPickTimeWorkBase
# noinspection PyUnresolvedReferences
from ..CoreBu.ABuFixes import filter
from ..UtilBu.ABuProgress import AbuMulPidProgress

__author__ = '阿布'
__weixin__ = 'abu_quant'

"""
    是否使用自然周,自然月,默认开启,如需关闭使用下面代码:
    abupy.alpha.pick_time_worker.g_natural_long_task = False
"""
g_natural_long_task = True


# noinspection PyAttributeOutsideInit
class AbuPickTimeWorker(AbuPickTimeWorkBase):
    """择时类"""

    def __init__(self, cap, kl_pd, benchmark, buy_factors, sell_factors):
        """
        :param cap: 资金类AbuCapital实例化对象
        :param kl_pd: 择时时间段交易数据
        :param benchmark: 交易基准对象,AbuBenchmark实例对象
        :param buy_factors: 买入因子序列,序列中的对象为dict,每一个dict针对一个具体因子
        :param sell_factors: 卖出因子序列,序列中的对象为dict,每一个dict针对一个具体因子
        """
        self.capital = cap
        # 回测阶段kl
        self.kl_pd = kl_pd
        # 合并加上回测之前1年的数据,为了生成特征数据
        self.combine_kl_pd = ABuSymbolPd.combine_pre_kl_pd(self.kl_pd, n_folds=1)
        # 如特别在乎效率性能,打开下面注释的方式,只在g_enable_ml_feature模式下开启, 注释上一行
        # self.combine_kl_pd = ABuSymbolPd.combine_pre_kl_pd(self.kl_pd,
        #                                                    n_folds=1) if ABuEnv.g_enable_ml_feature else None
        # 传递给因子系列,因子内部可有选择性使用
        self.benchmark = benchmark
        # 初始化买入因子列表
        self.init_buy_factors(buy_factors)
        # 初始化卖出因子列表
        self.init_sell_factors(sell_factors)
        # 根据因子是否支持周,月任务属性,筛选周月任务因子对象列表,在初始化时做,提高时间驱动效率
        self.filter_long_task_factors()
        # 择时最终买入卖出行为列表,列表中每一个对象都为AbuOrder对象
        self.orders = list()
        # 择时进度条,默认空, 即不打开,不显示择时进度
        self.task_pg = None

    def __str__(self):
        """打印对象显示:买入因子列表+卖出因子列表"""
        return 'buy_factors:{}\nsell_factors:{}'.format(self.buy_factors, self.sell_factors)

    __repr__ = __str__

    def enable_task_pg(self):
        """启动择时内部任务进度条"""
        if self.kl_pd is not None and hasattr(self.kl_pd, 'name') and len(self.kl_pd) > 120:
            self.task_pg = AbuMulPidProgress(len(self.kl_pd), 'pick {} times'.format(self.kl_pd.name))
            self.task_pg.init_ui_progress()
            self.task_pg.display_step = 42

    def _week_task(self, today):
        """
        周任务:使用self.week_buy_factors,self.week_sell_factors进行迭代
        不需再使用hasattr进行是否支持判断fit_week
        """
        # 优先执行买入择时因子专属卖出择时因子,而且即使买入因子被锁但附属于买入因子的卖出不能锁
        self._task_attached_sell(today, how='week')

        # 周任务中不建议生成买单,执行卖单,全部在日任务完成,如需判断通过today.exec_week,today.exec_month
        for sell_factor in self.week_sell_factors:
            sell_factor.fit_week(today, self.orders)

        # 执行买入择时因子专属选股因子,决策是否封锁择时买入因子,注意需要从self.buy_factors遍历不是self.week_buy_factors
        self._task_attached_ps(today, is_week=True)

        for buy_factor in self.week_buy_factors:
            if not buy_factor.lock_factor:
                # 如果买入因子没有被封锁执行任务
                buy_factor.fit_week(today)

    def _month_task(self, today):
        """
        月任务:使用self.month_buy_factors,self.month_sell_factors进行迭代
        不需再使用hasattr进行是否支持判断fit_month
        """
        # 优先执行买入择时因子专属卖出择时因子,而且即使买入因子被锁但附属于买入因子的卖出不能锁
        self._task_attached_sell(today, how='month')

        # 月任务中不建议生成买单,执行卖单,全部在日任务完成,如需判断通过today.exec_week,today.exec_month
        for sell_factor in self.month_sell_factors:
            sell_factor.fit_month(today, self.orders)

        # 执行择时因子专属选股因子,决策是否封锁择时买入因子,注意需要从self.buy_factors遍历不是self.month_buy_factors
        self._task_attached_ps(today, is_week=False)

        # 执行带有fit_month的择时买入因子
        for buy_factor in self.month_buy_factors:
            if not buy_factor.lock_factor:
                # 如果买入因子没有被封锁执行任务
                buy_factor.fit_month(today)

    def _day_task(self, today):
        """
        日任务:迭代买入卖出因子序列进行择时
        :param today: 今日的交易数据
        :return:
        """
        # 优先执行买入择时因子专属卖出择时因子,不受买入因子是否被锁的影响
        self._task_attached_sell(today, how='day')

        # 注意回测模式下始终非高频,非当日买卖,不区分美股,A股市场,卖出因子要先于买入因子的执行
        for sell_factor in self.sell_factors:
            # 迭代卖出因子,每个卖出因子针对今日交易数据,已经所以交易单进行择时
            sell_factor.read_fit_day(today, self.orders)

        # 买入因子行为要在卖出因子下面,否则为高频日交易模式
        for buy_factor in self.buy_factors:
            # 如果择时买入因子没有被封锁执行任务
            if not buy_factor.lock_factor:
                # 迭代买入因子,每个因子都对今天进行择时,如果生成order加入self.orders
                order = buy_factor.read_fit_day(today)
                if order and order.order_deal:
                    self.orders.append(order)

    def _task_attached_sell(self, today, how):
        """专属择时买入因子的择时卖出因子任务:日任务择时卖出因子, 周任务择时卖出因子,月任务择时卖出因子"""

        for buy_factor in self.buy_factors:
            # 筛选出当前买入因子所对应的所有单子, 注意这里使用buy_factor_class不是buy_factor,buy_factor带参数做为唯一标示
            factor_orders = list(filter(lambda order: order.buy_factor_class == buy_factor.__class__.__name__,
                                        self.orders))
            if len(factor_orders) == 0:
                # 当前因子没有对应单子
                continue

            # TODO 不要使用字符串进行eq比对
            for sell_factor in buy_factor.sell_factors:
                if how == 'day':
                    # 所有日任务都要用read_fit_day,且一定存在
                    sell_factor.read_fit_day(today, factor_orders)
                elif how == 'week' and hasattr(sell_factor, 'fit_week'):
                    # 周任务,可选择
                    sell_factor.fit_week(today, factor_orders)
                elif how == 'month'and hasattr(sell_factor, 'fit_month'):
                    # 月任务,可选择
                    sell_factor.fit_month(today, factor_orders)

    def _task_attached_ps(self, today, is_week):
        """专属择时买入因子的选股因子任务:周任务选股因子,月任务选股因子"""
        for buy_factor in self.buy_factors:
            # 不能使用today.exec_week或者today.exec_month来判定,因为有可能都时true
            buy_factor.fit_ps_week(today) if is_week else buy_factor.fit_ps_month(today)

    def _task_loop(self, today):
        """
        开始时间驱动,进行日任务,周任务,月任务,
        如果使用自然周,就会在每个周五进行择时操作
        自然月在每个月末最后一天进行择时,否则就以
        天数作为触发条件,这个时候定性任务本身的性质
        只是以时间跨度作为阀值,触发条件
        :param today: 对self.kl_pd apply操作,且axis=1结果为一天的交易数据
        :return:
        """
        if self.task_pg is not None:
            self.task_pg.show()

        day_cnt = today.key
        # 判断是否执行周任务, 返回结果赋予today对象
        today.exec_week = today.week_task == 1 if g_natural_long_task else day_cnt % 5 == 0
        # 判断是否执行月任务, 返回结果赋予today对象
        today.exec_month = today.month_task == 1 if g_natural_long_task else day_cnt % 20 == 0

        if day_cnt == 0 and not today.exec_week:
            # 如果是择时第一天,且没有执行周任务,需要初始化买入因子专属周任务选股池子
            self._task_attached_ps(today, is_week=True)
        if day_cnt == 0 and not today.exec_month:
            # 如果是择时第一天,且没有执行月任务,需要初始化买入因子专属月任务选股池子
            self._task_attached_ps(today, is_week=False)

        if today.exec_month:
            # 执行因子月任务
            self._month_task(today)
        if today.exec_week:
            # 执行因子周任务
            self._week_task(today)
        # 执行择时因子日任务
        self._day_task(today)

    # noinspection PyTypeChecker
    def fit(self, *args, **kwargs):
        """
            根据交易数据,因子等输入数据,拟合择时
        """
        if g_natural_long_task:
            """如果要进行自然周,自然月择时任务,需要在kl_pd中添加自然周,自然月标记"""
            # 自然周: 每个周五进行标记
            self.kl_pd['week_task'] = np.where(self.kl_pd.date_week == 4, 1, 0)
            """
                自然月: 即前后两个日期,相互减,得到的数 > 60 必然为月末,20140801 - 20140731
                没有使用时间api,因为这样做运行效率快
                self.kl_pd.shift(-1)['date'] - self.kl_pd['date']
                ->
                >>>>
                2014-07-28     1.0
                2014-07-29     1.0
                2014-07-30     1.0
                2014-07-31    70.0
                2014-08-01     3.0
                2014-08-04     1.0
                2014-08-05     1.0
                >>>
                2014-08-22     3.0
                2014-08-25     1.0
                2014-08-26     1.0
                2014-08-27     1.0
                2014-08-28     1.0
                2014-08-29    73.0
                2014-09-02     1.0
                2014-09-03     1.0
                >>>>
            """
            self.kl_pd['month_task'] = np.where(self.kl_pd.shift(-1)['date'] - self.kl_pd['date'] > 60, 1, 0)
        # 通过pandas apply进行交易日递进择时
        self.kl_pd.apply(self._task_loop, axis=1)

        if self.task_pg is not None:
            self.task_pg.close_ui_progress()

    def init_sell_factors(self, sell_factors):
        """
        通过sell_factors实例化各个卖出因子
        :param sell_factors: list中元素为dict,每个dict为因子的构造元素,如class,构造参数等
        :return:
        """
        self.sell_factors = list()

        if sell_factors is None:
            return

        for factor_class in sell_factors:
            if factor_class is None:
                continue
            if 'class' not in factor_class:
                # 必须要有需要实例化的类信息
                raise ValueError('factor class key must name class !!!')

            factor_class_cp = copy.deepcopy(factor_class)
            # pop出类信息后剩下的都为类需要的参数
            class_fac = factor_class_cp.pop('class')
            # 整合capital,kl_pd等实例化因子对象
            factor = class_fac(self.capital, self.kl_pd, self.combine_kl_pd, self.benchmark, **factor_class_cp)

            if not isinstance(factor, AbuFactorSellBase):
                # 因子对象类型检测
                raise TypeError('factor must base AbuFactorSellBase')
            # 添加到卖出因子序列
            self.sell_factors.append(factor)

    def init_buy_factors(self, buy_factors):
        """
        通过buy_factors实例化各个买入因子
        :param buy_factors: list中元素为dict,每个dict为因子的构造元素,如class,构造参数等
        :return:
        """
        self.buy_factors = list()

        if buy_factors is None:
            return

        for factor_class in buy_factors:
            if factor_class is None:
                continue

            if 'class' not in factor_class:
                # 必须要有需要实例化的类信息
                raise ValueError('factor class key must name class !!!')

            factor_class_cp = copy.deepcopy(factor_class)
            # pop出类信息后剩下的都为类需要的参数
            class_fac = factor_class_cp.pop('class')
            # 整合capital,kl_pd等实例化因子对象
            factor = class_fac(self.capital, self.kl_pd, self.combine_kl_pd, self.benchmark, **factor_class_cp)

            if not isinstance(factor, AbuFactorBuyBase):
                # 因子对象类型检测
                raise TypeError('factor must base AbuFactorBuyBase')
            # 添加到买入因子序列
            self.buy_factors.append(factor)

    def filter_long_task_factors(self):
        """
        根据每一个因子是否有fit_week筛选周任务因子
        根据每一个因子是否有fit_month筛选月任务因子
        在初始化时完成筛选工作,避免在时间序列中迭代
        不断的进行hasattr判断是否支持
        """
        self.week_buy_factors = list(filter(lambda buy_factor: hasattr(buy_factor, 'fit_week'),
                                            self.buy_factors))
        self.month_buy_factors = list(filter(lambda buy_factor: hasattr(buy_factor, 'fit_month'),
                                             self.buy_factors))

        self.week_sell_factors = list(filter(lambda sell_factor: hasattr(sell_factor, 'fit_week'),
                                             self.sell_factors))
        self.month_sell_factors = list(filter(lambda sell_factor: hasattr(sell_factor, 'fit_month'),
                                              self.sell_factors))


================================================
FILE: abupy/AlphaBu/__init__.py
================================================
from __future__ import absolute_import

from .ABuPickBase import AbuPickTimeWorkBase, AbuPickStockWorkBase

from .ABuPickStockMaster import AbuPickStockMaster
from .ABuPickStockWorker import AbuPickStockWorker

from .ABuPickTimeWorker import AbuPickTimeWorker
from .ABuPickTimeMaster import AbuPickTimeMaster

from . import ABuPickStockExecute
from . import ABuPickTimeExecute
# noinspection all
from . import ABuAlpha as alpha

__all__ = [
    'AbuPickTimeWorkBase',
    'AbuPickStockWorkBase',
    'AbuPickStockMaster',
    'AbuPickStockWorker',
    'AbuPickTimeWorker',
    'AbuPickTimeMaster',

    'ABuPickStockExecute',
    'ABuPickTimeExecute',
    'alpha'
]


================================================
FILE: abupy/BetaBu/ABuAtrPosition.py
================================================
# -*- encoding:utf-8 -*-
"""
    示例仓位管理:atr仓位管理模块
"""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function

from .ABuPositionBase import AbuPositionBase

__author__ = '阿布'
__weixin__ = 'abu_quant'

"""
    默认0.1即10% 外部可通过如:abupy.beta.atr.g_atr_pos_base = 0.01修改仓位基础配比
    需要注意外部其它自定义仓位管理类不要随意使用模块全局变量,AbuAtrPosition特殊因为注册
    在ABuEnvProcess中在多进程启动时拷贝了模块全局设置内存
"""
g_atr_pos_base = 0.1


class AbuAtrPosition(AbuPositionBase):
    """示例atr仓位管理类"""

    s_atr_base_price = 15  # best fit wide: 12-20
    s_std_atr_threshold = 0.5  # best fit wide: 0.3-0.65

    def fit_position(self, factor_object):
        """
        fit_position计算的结果是买入多少个单位(股,手,顿,合约)
        计算:(常数价格 / 买入价格)* 当天交易日atr21
        :param factor_object: ABuFactorBuyBases实例对象
        :return: 买入多少个单位(股,手,顿,合约)
        """
        std_atr = (self.atr_base_price / self.bp) * self.kl_pd_buy['atr21']

        """
            对atr 进行限制 避免由于股价波动过小,导致
            atr小,产生大量买单,实际上针对这种波动异常(过小,过大)的股票
            需要有其它的筛选过滤策略, 选股的时候取0.5,这样最大取两倍g_atr_pos_base
        """
        atr_wv = self.std_atr_threshold if std_atr < self.std_atr_threshold else std_atr
        # 计算出仓位比例
        atr_pos = self.atr_pos_base / atr_wv
        # 最大仓位限制
        atr_pos = self.pos_max if atr_pos > self.pos_max else atr_pos
        # 结果是买入多少个单位(股,手,顿,合约)
        return self.read_cash * atr_pos / self.bp * self.deposit_rate

    def _init_self(self, **kwargs):
        """atr仓位控制管理类初始化设置"""
        self.atr_base_price = kwargs.pop('atr_base_price', AbuAtrPosition.s_atr_base_price)
        self.std_atr_threshold = kwargs.pop('std_atr_threshold', AbuAtrPosition.s_std_atr_threshold)
        self.atr_pos_base = kwargs.pop('atr_pos_base', g_atr_pos_base)


================================================
FILE: abupy/BetaBu/ABuBeta.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import absolute_import

# noinspection all
from . import ABuPositionBase as position
# noinspection all
from . import ABuAtrPosition as atr
# noinspection all
from . import ABuKellyPosition as kelly


================================================
FILE: abupy/BetaBu/ABuKellyPosition.py
================================================
# -*- encoding:utf-8 -*-
"""示例仓位管理:kelly仓位管理模块"""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function

from .ABuPositionBase import AbuPositionBase


class AbuKellyPosition(AbuPositionBase):
    """示例kelly仓位管理类"""

    def fit_position(self, factor_object):
        """
        通过kelly公司计算仓位, fit_position计算的结果是买入多少个单位(股,手,顿,合约)
        :param factor_object: ABuFactorBuyBases子类实例对象
        :return:买入多少个单位(股,手,顿,合约)
        """
        # 败率
        loss_rate = 1 - self.win_rate
        # kelly计算出仓位比例
        kelly_pos = self.win_rate - loss_rate / (self.gains_mean / self.losses_mean)
        # 最大仓位限制,依然受上层最大仓位控制限制,eg:如果kelly计算出全仓,依然会减少到75%,如修改需要修改最大仓位值
        kelly_pos = self.pos_max if kelly_pos > self.pos_max else kelly_pos
        # 结果是买入多少个单位(股,手,顿,合约)
        return self.read_cash * kelly_pos / self.bp * self.deposit_rate

    def _init_self(self, **kwargs):
        """kelly仓位控制管理类初始化设置"""

        # 默认kelly仓位胜率0.50
        self.win_rate = kwargs.pop('win_rate', 0.50)
        # 默认平均获利期望0.10
        self.gains_mean = kwargs.pop('gains_mean', 0.10)
        # 默认平均亏损期望0.05
        self.losses_mean = kwargs.pop('losses_mean', 0.05)

        """以默认的设置kelly根据计算0.5 - 0.5 / (0.10 / 0.05) 仓位将是0.25即25%"""


================================================
FILE: abupy/BetaBu/ABuPositionBase.py
================================================
# -*- encoding:utf-8 -*-
"""
    风险控制仓位管理基础
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from abc import ABCMeta, abstractmethod

from ..CoreBu.ABuFixes import six
from ..MarketBu.ABuMarket import MarketMixin

"""每一笔交易最大仓位比例设置,外部可通过如:abupy.beta.position.g_pos_max = 0.5修改最大每一笔交易最大仓位比例,默认75%"""
g_pos_max = 0.75
"""
    保证金最小比例,默认1,即不使用融资,不会触发Margin Call
    在期货数据中有每种商品最少保证金比例,可使用设置
    外部可通过如:abupy.beta.position.g_deposit_rate = 0.5
"""
g_deposit_rate = 1
"""
    买入因子全局默认仓位管理类,默认None的情况下会使用AbuAtrPosition作为默认仓位管理类.

    和卖出因子,选股因子不同,一个买入因子可以对应多个卖出因子,多个选股因子,但一个买入
    因子只能对应一个仓位管理类,可以是全局仓位管理,也可以是针对买入因子的独有附属仓位管理
    类
"""
g_default_pos_class = None


class AbuPositionBase(six.with_metaclass(ABCMeta, MarketMixin)):
    """仓位管理抽象基类"""

    def __init__(self, kl_pd_buy, factor_name, symbol_name, bp, read_cash, **kwargs):
        """
        :param kl_pd_buy: 交易当日的交易数据
        :param factor_name: 因子名称
        :param symbol_name: symbol代码
        :param bp: 买入价格
        :param read_cash: 初始资金
        :param deposit_rate: 保证金比例
        """
        self.kl_pd_buy = kl_pd_buy
        self.factor_name = factor_name
        self.symbol_name = symbol_name
        self.bp = bp
        self.read_cash = read_cash

        # 如果有全局最大仓位设置基类负责弹出
        self.pos_max = kwargs.pop('pos_max', g_pos_max)
        # 如果有全局保证金最小比例设置基类负责弹出
        self.deposit_rate = kwargs.pop('deposit_rate', g_deposit_rate)

        # 子类继续完成自有的构造
        self._init_self(**kwargs)

    def __str__(self):
        """打印对象显示:class name, factor_name, symbol_name, read_cash, deposit_rate"""
        return '{}: factor_name:{}, symbol_name:{}, read_cash:{}, deposit_rate:{}'.format(self.__class__.__name__,
                                                                                          self.factor_name,
                                                                                          self.symbol_name,
                                                                                          self.read_cash,
                                                                                          self.deposit_rate)

    __repr__ = __str__

    @abstractmethod
    def _init_self(self, **kwargs):
        """子类仓位管理针对可扩展参数的初始化"""
        pass

    @abstractmethod
    def fit_position(self, factor_object):
        """
        fit_position计算的结果是买入多少个单位(股,手,顿,合约)具体计算子类实现
        :param factor_object: ABuFactorBuyBases实例对象
        :return:买入多少个单位(股,手,顿,合约)
        """
        pass


================================================
FILE: abupy/BetaBu/ABuPtPosition.py
================================================
# -*- encoding:utf-8 -*-
"""示例仓位管理:示例价格位置仓位模块"""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function

from scipy import stats

from .ABuPositionBase import AbuPositionBase


class AbuPtPosition(AbuPositionBase):
    """
        示例价格位置仓位管理类:

        根据买入价格在之前一段时间的价格位置来决策仓位大小

        假设过去一段时间的价格为[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
        如果当前买入价格为2元:则买入仓位配比很高(认为均值回复有很大向上空间)
        如果当前买入价格为9元:则买入仓位配比很低(认为均值回复向上空间比较小)
    """

    def fit_position(self, factor_object):
        """
        针对均值回复类型策略的仓位管理:
        根据当前买入价格在过去一段金融序列中的价格rank位置来决定仓位
        fit_position计算的结果是买入多少个单位(股,手,顿,合约)
        :param factor_object: ABuFactorBuyBases子类实例对象
        :return:买入多少个单位(股,手,顿,合约)
        """

        # self.kl_pd_buy为买入当天的数据,获取之前的past_day_cnt天数据
        last_kl = factor_object.past_today_kl(self.kl_pd_buy, self.past_day_cnt)
        if last_kl is None or last_kl.empty:
            precent_pos = self.pos_base
        else:
            # 使用percentileofscore计算买入价格在过去的past_day_cnt天的价格位置
            precent_pos = stats.percentileofscore(last_kl.close, self.bp)
            precent_pos = (1 + (self.mid_precent - precent_pos) / 100) * self.pos_base
        # 最大仓位限制,依然受上层最大仓位控制限制,eg:如果算出全仓,依然会减少到75%,如修改需要修改最大仓位值
        precent_pos = self.pos_max if precent_pos > self.pos_max else precent_pos
        # 结果是买入多少个单位(股,手,顿,合约)
        return self.read_cash * precent_pos / self.bp * self.deposit_rate

    def _init_self(self, **kwargs):
        """价格位置仓位控制管理类初始化设置"""
        # 默认平均仓位比例0.10,即10%
        self.pos_base = kwargs.pop('pos_base', 0.10)
        # 默认获取之前金融时间序列的长短数量
        self.past_day_cnt = kwargs.pop('past_day_cnt', 20)
        # 默认的比例中值,一般不需要设置
        self.mid_precent = kwargs.pop('mid_precent', 50.0)


================================================
FILE: abupy/BetaBu/__init__.py
================================================
from __future__ import absolute_import

from .ABuPositionBase import AbuPositionBase
from .ABuAtrPosition import AbuAtrPosition
from .ABuKellyPosition import AbuKellyPosition
from .ABuPtPosition import AbuPtPosition
# noinspection all
from . import ABuBeta as beta

__all__ = [
    'AbuPositionBase',
    'AbuAtrPosition',
    'AbuKellyPosition',
    'AbuPtPosition',
    'beta'
]


================================================
FILE: abupy/CheckBu/ABuChecker.py
================================================
# -*- encoding:utf-8 -*-
"""
    检查类,检查函数对象、函数参数、函数返回值
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from toolz import valmap
from functools import wraps

from ..CheckBu.ABuFuncUtil import *
from ..CheckBu.ABuChecks import *
from ..CheckBu.ABuProcessor import arg_process, return_process

__author__ = '夜猫'
__weixin__ = 'abu_quant'


class _NoInstances(six.with_metaclass(ABCMeta, type)):
    """阻止实例化"""

    def __call__(cls, *args, **kwargs):
        raise TypeError("Can't instantiate directly")


class FuncChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    """函数相关的检查类"""

    @staticmethod
    def check_iscallable(func):
        """
        检查传入参数对象是否是函数;不是函数raise CheckError
        :param func: 传入参数对象
        """
        if not callable(func):
            raise CheckError('%s is not callable' % get_func_name(func))


class ArgChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    """函数参数相关的检查类"""

    @staticmethod
    def check_type(*ty_args, **ty_kwargs):
        """
        【装饰器】
        检查输入参数类型;检查失败raise CheckError
        :param ty_args: 类型tuple
        :param ty_kwargs: 类型dict
        :return: 
        """
        # 检查是否有不合规的tuple参数
        for ty in ty_args:
            if not isinstance(ty, (type, tuple)):
                raise TypeError(
                    "check_type() expected a type or tuple of types"
                    ", but got {type_} instead.".format(
                        type_=ty,
                    )
                )
        # 检查是否有不合规的dict参数
        for name, ty in six.iteritems(ty_kwargs):
            if not isinstance(ty, (type, tuple)):
                raise TypeError(
                    "check_type() expected a type or tuple of types for "
                    "argument '{name}', but got {type_} instead.".format(
                        name=name, type_=ty,
                    )
                )
        # 将type_check作用在函数参数上
        return arg_process(*map(type_check, list(ty_args)), **valmap(type_check, ty_kwargs))

    @staticmethod
    def check_bound(*bd_args, **bd_kwargs):
        """
        【装饰器】
        检查输入参数是否在某一范围内;检查失败raise CheckError
        传入参数形式应为`` (min_value, max_value)``.
        ``None`` 可以作为 ``min_value`` 或 ``max_value``,相当于正负无穷
        :param bd_args: tuple范围参数
        :param bd_kwargs: dict范围参数
        :return: 
        """
        # 将bound_valid_and_check作用在函数参数上
        return arg_process(*map(bound_valid_and_check, list(bd_args)),
                           **valmap(bound_valid_and_check, bd_kwargs))

    @staticmethod
    def _check_default(check_no, *names, **_unused):
        """
        【装饰器】
        检查函数参数是否有或者没有默认值;检查失败raise CheckError
        :param staticmethod: 检查有 or 没有
        :param names: 待检查参数的名称
        :param _unused: 屏蔽dict参数
        :return: 
        """
        # 屏蔽dict参数
        if _unused:
            raise TypeError("_check_default() doesn't accept dict processors")
        check_err_msg = '' if check_no else 'no '

        def decorate(func):
            # 获取默认参数字典
            arg_defaults = get_arg_defaults(func)
            for name in names:
                if name not in arg_defaults:
                    # 传入了并不存在的参数名
                    raise TypeError(get_func_name(func) + ' has no argument named ' + name)
                if bool(check_no) != (isinstance(arg_defaults[name], ArgNoDefault)):
                    # 检查失败
                    raise CheckError(
                        'In ' + get_func_name(func) + ' argument {} has {}default'.format(name, check_err_msg))

            @wraps(func)
            def wrapper(*args, **kwargs):
                # 直接返回被装饰函数结果
                return func(*args, **kwargs)

            return wrapper

        return decorate

    @staticmethod
    def check_hasdefault(*names, **_unused):
        """
        【装饰器】
        检查函数参数是否有默认值;检查失败raise CheckError
        :param names: 待检查参数的名称
        :param _unused: 屏蔽dict参数
        :return: 
        """

        return ArgChecker._check_default(False, *names, **_unused)

    @staticmethod
    def check_nodefault(*names, **_unused):
        """
        【装饰器】
        检查函数参数是否没有默认值;检查失败raise CheckError
        :param names: 待检查参数的名称
        :param _unused: 屏蔽dict参数
        :return: 
        """

        return ArgChecker._check_default(True, *names, **_unused)

    @staticmethod
    def check_hasargs(func):
        """
        【装饰器】
        检查函数是否有*args参数;检查失败raise CheckError
        :param func: 传入函数对象
        :return: 
        """
        # 解包函数参数及默认值
        argspec = getargspec(func)
        spec_args = argspec.args if argspec.args else []
        defaults = argspec.defaults if argspec.defaults else ()
        if len(spec_args) - len(defaults) == 0:
            # 函数没有tuple参数
            raise CheckError(get_func_name(func) + ' has no args')

        @wraps(func)
        def wrapper(*args_inner, **kwargs):
            # 直接返回被装饰函数结果
            return func(*args_inner, **kwargs)

        return wrapper

    @staticmethod
    def check_haskwargs(func):
        """
        【装饰器
        检查函数是否有**kwargs参数;检查失败raise CheckError
        :param func: 传入函数对象
        :return: 
        """
        # 解包函数参数及默认值
        argspec = getargspec(func)
        defaults = argspec.defaults if argspec.defaults else ()
        if not defaults:
            # 函数没有dict参数
            raise CheckError(get_func_name(func) + ' has no kwargs')

        @wraps(func)
        def wrapper(*args, **kwargs):
            # 直接返回被装饰函数结果
            return func(*args, **kwargs)

        return wrapper

    @staticmethod
    def check_subset(*ss_args, **ss_kwargs):
        """
        【装饰器】
        检查输入参数是否是某一集合的子集;检查失败raise CheckError
        :param ss_args: 参数集合tuple
        :param ss_kwargs: 参数集合dict
        :return: 
        """
        # 检查是否有不合规的tuple参数
        for ss in ss_args:
            if not isinstance(ss, (list, set, type(None))):
                raise TypeError(
                    "check_subset() expected a list or set or None of values"
                    ", but got {subset_} or tuple instead.".format(
                        subset_=str(type(ss)),
                    )
                )
        # 检查是否有不合规的dict参数
        for name, ss in six.iteritems(ss_kwargs):
            if not isinstance(ss, (list, set, type(None))):
                raise TypeError(
                    "check_subset() expected a list or set of values for "
                    "argument '{name_}', but got {subset_} or tuple instead.".format(
                        name_=name, subset_=str(type(ss)),
                    )
                )
        # 将subset_check函数作用在函数参数上
        return arg_process(*map(subset_check, list(ss_args)), **valmap(subset_check, ss_kwargs))


class ReturnChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    """函数返回值相关的检查类"""

    @staticmethod
    def check_type(*types, **_unused):
        """
        【装饰器】
        检查返回值类型;检查失败raise CheckError
        :param types: 类型tuple
        :param _unused: 屏蔽dict参数
        :return: 
        """
        # 屏蔽dict参数
        if _unused:
            raise TypeError("check_type() doesn't accept dict processors")

        # 检查是否有不合格的tuple参数
        for type_ in types:
            if not isinstance(type_, (type, tuple, type(None))):  # tuple or 内置类型
                raise TypeError(
                    "check_return_type() expected a type or tuple of types, but got {type_msg} instead.".format(
                        type_msg=type_,
                    )
                )
        # 将type_check函数作用在函数返回值上
        return return_process(*map(type_check, list(types)))

    @staticmethod
    def check_bound(*bounds, **_unused):
        """
        【装饰器】
        检查返回参数是否在某一范围内;检查失败raise CheckError
        传入参数形式应为`` (min_value, max_value)``.
        ``None`` 可以作为 ``min_value`` 或 ``max_value``,相当于正负无穷
        :param bounds: tuple范围参数
        :param _unused: 屏蔽dict参数
        :return: 
        """
        # 屏蔽dict参数
        if _unused:
            raise TypeError("check_bound() doesn't accept dict processors")
        # 将bound_valid_and_check函数作用在函数返回值上
        return return_process(*map(bound_valid_and_check, list(bounds)))

    @staticmethod
    def check_subset(*ss_args, **_unused):
        """
        【装饰器】
        检查输入参数是否是某一集合的子集;检查失败raise CheckError
        :param ss_args: 参数集合tuple
        :param _unused: 屏蔽dict参数
        :return: 
        """
        # 屏蔽dict参数
        if _unused:
            raise TypeError("check_subset() doesn't accept dict processors")
        # 检查传入的tuple参数
        for ss in ss_args:
            if not isinstance(ss, (list, set, type(None))):
                raise TypeError(
                    "check_subset() expected a list or set or None of values"
                    ", but got {subset_} or tuple instead.".format(
                        subset_=str(type(ss)),
                    )
                )
        # 将subset_check函数作用在函数返回值上
        return return_process(*map(subset_check, list(ss_args)))


================================================
FILE: abupy/CheckBu/ABuChecks.py
================================================
# -*- encoding:utf-8 -*-
"""
    检查范围的函数
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import numpy as np
from abc import ABCMeta

from ..CoreBu.ABuFixes import six

__author__ = '夜猫'
__weixin__ = 'abu_quant'


class CheckError(six.with_metaclass(ABCMeta, TypeError)):
    """Check失败的Error类型"""
    pass


def bound_check(bound):
    """
    制作检查数值范围的check_fail函数
    """
    (min_val, max_val) = bound
    # 转换None到inf
    min_val = -np.inf if min_val is None else min_val
    max_val = np.inf if max_val is None else max_val
    # 准备错误message
    error_msg = "function expected a return value inclusively between %s and %s" % (min_val, max_val)

    def _check(value):
        """范围检查逻辑"""
        return not (min_val <= value <= max_val)

    def _bound_check(val):
        """
        检查数值范围的函数;检查失败raise CheckError
        """
        if _check(val):
            raise CheckError(error_msg)
        else:
            return val

    return _bound_check


def bound_valid_and_check(bound):
    """
    检查bound的输入参数格式;失败raise TypeError
    传入参数形式应为`` (min_value, max_value)``.
    """

    def valid_bound(t):
        # 检查bound传入参数格式
        return (
            isinstance(t, tuple)
            and len(t) == 2
            and t != (None, None)
        )

    if not valid_bound(bound):
        # 参数格式错误
        raise TypeError(
            "function expected a tuple of bounds,"
            "but got {} instead.".format(bound)
        )
    return bound_check(bound)


def subset_check(subset):
    """
    制作检查是否子集的check函数
    """

    def _check(arg_val):
        """
        检查数值是否子集的check函数;检查失败raise CheckError
        """
        if subset is not None and arg_val not in set(subset):
            raise CheckError(
                'Value {} is not the subset of {}'.format(arg_val, str(subset))
            )
        return arg_val

    return _check


def type_check(arg_ty):
    """
    制作检查数值类型的check函数
    """

    def _check(arg_val):
        """
        检查数值类型的check函数;检查失败raise CheckError
        """
        if arg_ty and not isinstance(arg_val, arg_ty):
            raise CheckError(
                'Value {} is not {}'.format(arg_val, arg_ty)
            )
        return arg_val

    return _check


================================================
FILE: abupy/CheckBu/ABuFuncUtil.py
================================================
# -*- encoding:utf-8 -*-
"""
    函数对象的工具类
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from collections import OrderedDict
from abc import ABCMeta

from ..CoreBu.ABuFixes import six

try:
    from inspect import getfullargspec as getargspec
except ImportError:

    from inspect import getargspec

__author__ = '夜猫'
__weixin__ = 'abu_quant'


class ArgNoDefault(six.with_metaclass(ABCMeta, TypeError)):
    """没有默认值的参数对象"""
    pass


def get_func_name(func):
    """
    获取函数名称
    :param func: 传入函数
    :return: 
    """
    try:
        func_name = str(func.__name__) + '()'
    except AttributeError:
        func_name = str(func)
    return func_name


def get_arg_defaults(func):
    """
    获取函数默认值字典;没有默认值时对应NoDefaultArg对象
    :param func: 传入函数
    :return: 函数参数名:默认值
    """
    # 解包函数参数及默认值
    argspec = getargspec(func)
    spec_args = argspec.args if argspec.args else []
    defaults = argspec.defaults if argspec.defaults else ()
    # 拼装默认值dict
    no_defaults = (ArgNoDefault(),) * (len(spec_args) - len(defaults))
    args_defaults = dict(zip(spec_args, no_defaults + defaults))
    return args_defaults


def check_bind(func, *args, **kwargs):
    """
    检查要bind的对象和原函数func的参数是否对齐;对齐失败,raise TypeError
    :param func:  原函数
    :param args: 要bind的tuple对象
    :param kwargs: 要bind的dict对象
    :return: 
    """
    argspec = getargspec(func)
    spec_args = argspec.args if argspec.args else []
    # 检查 kwargs 中是否有不存在的参数名
    bad_names = set(kwargs.keys()) - set(spec_args)
    if bad_names:
        raise TypeError(
            "Got unknown arguments: {}".format(str(bad_names))
        )
    # 检查args的参数是否过长
    l_arg_len = len(args)
    if len(spec_args) < l_arg_len + len(kwargs):
        raise TypeError(
            "Function with {} arguments, but got {} arguments to bind".format(len(spec_args),
                                                                              l_arg_len + len(kwargs))
        )
    # 检查 kwargs 中是否和 args的参数冲突
    arg_inds = OrderedDict(zip(spec_args, range(len(spec_args))))
    for k, v in six.iteritems(kwargs):
        if l_arg_len > arg_inds[k]:
            raise TypeError(
                "dict argument crash on tuple argument:  {}".format(str(k))
            )


def bind_partial(func, *args, **kwargs):
    """
    绑定func的参数和对应的参数对象
    :param func: 原函数
    :param args: 要bind的tuple对象
    :param kwargs: 要bind的dict对象
    :return: 绑定后的字典
    """
    # 解包函数参数
    argspec = getargspec(func)
    spec_args = argspec.args if argspec.args else []

    # 拼装函数参数和对应的参数对象
    bind_dict = OrderedDict(zip(spec_args, [None] * len(spec_args)))
    for k, v in six.iteritems(kwargs):
        bind_dict[k] = v
    for k, v in zip(six.iterkeys(bind_dict), args):
        bind_dict[k] = v

    return bind_dict


================================================
FILE: abupy/CheckBu/ABuProcessor.py
================================================
# -*- encoding:utf-8 -*-
"""
    预处理函数参数或返回值
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from functools import wraps

from ..CoreBu.ABuFixes import zip
from ..CheckBu.ABuFuncUtil import *

try:
    from ..ExtBu.six.moves import zip_longest
except ImportError:
    from six.moves import zip_longest

__author__ = '夜猫'
__weixin__ = 'abu_quant'


def arg_process(*arg_funcs, **kwarg_funcs):
    """
    【装饰器】
    将funcs函数作用在原函数的参数上;func函数只包括一个参数: return_val.
    :param arg_funcs: func函数tuple。
    :param kwarg_funcs: func函数dict
    :return: 
    """

    def _decorator(func):
        # 检查待bind参数
        check_bind(func, *arg_funcs, **kwarg_funcs)
        # 提取funcs字典
        funcs = bind_partial(func, *arg_funcs, **kwarg_funcs)

        @wraps(func)
        def wrapper(*args, **kwargs):
            # 拼装经过函数处理后的新参数
            args_new = [f(arg) if f else arg for arg, f in zip(args, six.itervalues(funcs))]
            kwargs_new = {k: funcs[k](arg) if k in funcs and funcs[k] else arg
                          for k, arg in six.iteritems(kwargs)}
            # 调用函数
            return func(*args_new, **kwargs_new)

        return wrapper

    return _decorator


def return_process(*funcs, **_unused):
    """
    【装饰器】
    将funcs函数作用在被装饰的函数的返回值上
    :param funcs: 一个或者多个处理对应参数的func函数,多个func函数时需要和返回值数量对齐;func函数只包括一个参数: return_val
    :param _unused: 用来屏蔽dict参数
    :return: 返回被funcs函数处理过的函数返回值
    """
    # 屏蔽dict参数
    if _unused:
        raise TypeError("return_process() doesn't accept dict processors")

    def _decorator(f):
        def wrapper(*args, **kw):
            # 拿到返回值
            return_vals = f(*args, **kw)
            # 用函数处理返回值
            return _apply_funcs(return_vals, funcs)

        return wrapper

    return _decorator


def _apply_funcs(return_vals, funcs):
    """
    将func函数作用在被装饰的函数的返回值上
    """
    # 检查iterable
    if not isinstance(return_vals, tuple):
        return_vals = (return_vals,)
    try:
        iter(funcs)
    except TypeError:
        funcs = (funcs,) if funcs else ()

    # 检查函数
    if not funcs:
        return return_vals

    # 函数和返回值不对齐
    if 1 < len(return_vals) < len(funcs):
        raise TypeError(
            "In _apply_funcs(), len(funcs) == {} more than len(return_vals) == {}".format(
                len(funcs), len(return_vals)
            )
        )
    # 函数多于返回值
    if 1 == len(return_vals) < len(funcs):
        raise TypeError(
            "In _apply_funcs(), only 1 return value with len(processors) == {}".format(len(funcs),
                                                                                       len(return_vals))
        )

    # 将函数作用在返回值上
    return tuple([f(v) if f else v for v, f in zip_longest(return_vals, funcs)])


================================================
FILE: abupy/CheckBu/__init__.py
================================================
from __future__ import absolute_import

from .ABuProcessor import arg_process, return_process
from .ABuChecker import FuncChecker, ArgChecker, ReturnChecker

__all__ = [
    'arg_process',
    'return_process',
    'FuncChecker',
    'ArgChecker',
    'ReturnChecker',
]


================================================
FILE: abupy/CoreBu/ABu.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import logging

from ..AlphaBu.ABuPickStockMaster import AbuPickStockMaster
from ..AlphaBu.ABuPickTimeMaster import AbuPickTimeMaster
from ..CoreBu import ABuEnv
from ..CoreBu import ABuStore
from ..CoreBu.ABuStore import EStoreAbu
from ..CoreBu.ABuEnv import EMarketDataFetchMode
from ..CoreBu.ABuStore import AbuResultTuple
from ..MarketBu.ABuMarket import all_symbol
from ..MarketBu.ABuSymbolPd import kl_df_dict_parallel
from ..TradeBu.ABuBenchmark import AbuBenchmark
from ..TradeBu.ABuCapital import AbuCapital
from ..TradeBu.ABuKLManager import AbuKLManager
from ..UtilBu import ABuDateUtil
from ..UtilBu import ABuProgress

__author__ = '阿布'
__weixin__ = 'abu_quant'


def run_loop_back(read_cash, buy_factors, sell_factors, stock_picks=None, choice_symbols=None, n_folds=2,
                  start=None,
                  end=None,
                  commission_dict=None,
                  n_process_kl=None,
                  n_process_pick=None):
    """
    封装执行择时,选股回测。

    推荐在使用abu.run_loop_back()函数进行全市场回测前使用abu.run_kl_update()函数首先将数据进行更新,
    在run_kl_update()中它会首选强制使用网络数据进行更新,在更新完毕后,更改数据获取方式为本地缓存,
    使用abu.run_kl_update()的好处是将数据更新与策略回测分离,在运行效率及问题排查上都会带来正面的提升

    :param read_cash: 初始化资金额度,eg:1000000
    :param buy_factors: 回测使用的买入因子策略序列,
                    eg:
                        buy_factors = [{'xd': 60, 'class': AbuFactorBuyBreak},
                                       {'xd': 42, 'class': AbuFactorBuyBreak}]
    :param sell_factors: 回测使用的卖出因子序列,
                    eg:
                        sell_factors = [{'stop_loss_n': 0.5, 'stop_win_n': 3.0, 'class': AbuFactorAtrNStop},
                                        {'pre_atr_n': 1.0, 'class': AbuFactorPreAtrNStop},
                                        {'close_atr_n': 1.5, 'class': AbuFactorCloseAtrNStop},]
    :param stock_picks: 回测使用的选股因子序列:
                    eg:
                        stock_pickers = [{'class': AbuPickRegressAngMinMax,
                                          'threshold_ang_min': 0.0, 'reversed': False},
                                         {'class': AbuPickStockPriceMinMax,
                                          'threshold_price_min': 50.0,
                                          'reversed': False}]
    :param choice_symbols: 备选股票池, 默认为None,即使用abupy.env.g_market_target的市场类型进行全市场回测,
                           为None的情况下为symbol序列
                    eg:
                        choice_symbols = ['usNOAH', 'usSFUN', 'usBIDU', 'usAAPL', 'usGOOG',
                                          'usTSLA', 'usWUBA', 'usVIPS']
    :param n_folds: int, 回测n_folds年的历史数据
    :param start: 回测开始的时间, str对象, eg: '2013-07-10'
    :param end: 回测结束的时间, str对象 eg: '2016-07-26'
    :param commission_dict: 透传给AbuCapital,自定义交易手续费的时候时候。
                    eg:
                        def free_commission(trade_cnt, price):
                            # 免手续费
                            return 0
                        commission_dict = {'buy_commission_func': free_commission,
                                         'sell_commission_func': free_commission}
                        AbuCapital(read_cash, benchmark, user_commission_dict=commission_dict)

    :param n_process_kl: 金融时间序列数据收集启动并行的进程数,默认None, 内部根据cpu数量分配
    :param n_process_pick: 择时与选股操作启动并行的进程数,默认None, 内部根据cpu数量分配
    :return: (AbuResultTuple对象, AbuKLManager对象)
    """
    if start is not None and end is not None and ABuDateUtil.date_str_to_int(end) - ABuDateUtil.date_str_to_int(
            start) <= 0:
        logging.info('end date <= start date!!')
        return None, None

    benchmark = AbuBenchmark(n_folds=n_folds, start=start, end=end)
    # 资金类初始化
    capital = AbuCapital(read_cash, benchmark, user_commission_dict=commission_dict)

    """
         win_to_one:
         1. 如果symbol数量少于20
         2. 并且操作系统是windows,因为windows进程开辟销毁开销都非常大,
         3. 判断cpu不是很快,只能通过cpu数量做判断,4核认为速度一般
         这种情况下不再启动多个进程,只使用一个进程运行所有择时选股操作

         TODO:不能只以symbol数量进行判断,结合策略买入卖出策略数进行综合判断
    """
    win_to_one = choice_symbols is not None and len(
        choice_symbols) < 20 and not ABuEnv.g_is_mac_os and ABuEnv.g_cpu_cnt <= 4

    if n_process_pick is None:
        # 择时,选股并行操作的进程等于cpu数量, win_to_one满足情况下1个
        n_process_pick = 1 if win_to_one else ABuEnv.g_cpu_cnt
    if n_process_kl is None:
        # mac系统下金融时间序列数据收集启动两倍进程数, windows只是进程数量,win_to_one满足情况下1个
        n_process_kl = 1 if win_to_one else ABuEnv.g_cpu_cnt * 2 if ABuEnv.g_is_mac_os else ABuEnv.g_cpu_cnt

    # 选股策略执行,多进程方式
    choice_symbols = AbuPickStockMaster.do_pick_stock_with_process(capital, benchmark,
                                                                   stock_picks, choice_symbols=choice_symbols,
                                                                   n_process_pick_stock=n_process_pick)

    if choice_symbols is None or len(choice_symbols) == 0:
        logging.info('pick stock result is zero!')
        return None, None
    # kl数据管理类初始化
    kl_pd_manager = AbuKLManager(benchmark, capital)
    # 批量获取择时kl数据
    kl_pd_manager.batch_get_pick_time_kl_pd(choice_symbols, n_process=n_process_kl)

    # 在择时之前清理一下输出, 不能wait, windows上一些浏览器会卡死
    ABuProgress.do_clear_output(wait=False)

    # 择时策略运行,多进程方式
    orders_pd, action_pd, all_fit_symbols_cnt = AbuPickTimeMaster.do_symbols_with_same_factors_process(
        choice_symbols, benchmark,
        buy_factors, sell_factors, capital, kl_pd_manager=kl_pd_manager, n_process_kl=n_process_kl,
        n_process_pick_time=n_process_pick)

    # 都完事时检测一下还有没有ui进度条
    ABuProgress.do_check_process_is_dead()

    # 返回namedtuple, ('orders_pd', 'action_pd', 'capital', 'benchmark')
    abu_result = AbuResultTuple(orders_pd, action_pd, capital, benchmark)
    # store_abu_result_tuple(abu_result, n_folds)
    return abu_result, kl_pd_manager


def run_kl_update(n_folds=2, start=None, end=None, market=None, n_jobs=16, how='thread'):
    """
    推荐在使用abu.run_loop_back()函数进行全市场回测前使用abu.run_kl_update()函数首先将数据进行更新,
    在run_kl_update()中它会首选强制使用网络数据进行更新,在更新完毕后,更改数据获取方式为本地缓存
    在run_kl_update实现根据EMarketTargetType类型即市场类型,进行全市场金融时间序列数据获取,使用多进
    程或者多线程对外执行函数,多任务批量获取时间序列数据。

    使用abu.run_kl_update()的好处是将数据更新与策略回测分离,在运行效率及问题排查上都会带来正面的提升

    eg:
        from abupy import abu,EMarketTargetType
        # 港股全市场获取
        abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_HK
        # 更新6年的数据
        abu.run_kl_update(n_folds=6)

        # A股全市场获取
        abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_CN
        # 2013-07-10直到2016-07-26的数据
        abu.run_kl_update(start='2013-07-10', end='2016-07-26')

    :param n_folds: 请求几年的历史回测数据int
    :param start: 请求的开始日期 str对象, eg: '2013-07-10'
    :param end: 请求的结束日期 str对象 eg: '2016-07-26'
    :param market: 需要查询的市场,eg:EMarketTargetType.E_MARKET_TARGET_US
    :param n_jobs: 并行的任务数,对于进程代表进程数,线程代表线程数
    :param how: process:多进程,thread:多线程,main:单进程单线程
    """

    pre_market = None
    if market is not None:
        # 临时缓存之前的市场设置
        pre_market = ABuEnv.g_market_target
        ABuEnv.g_market_target = market

    # 所有任务数据强制网络更新
    ABuEnv.g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_FORCE_NET
    # index=True, 需要大盘数据
    symbols = all_symbol(index=True)
    _ = kl_df_dict_parallel(symbols, n_folds=n_folds, start=start, end=end, n_jobs=n_jobs, how=how)
    # 完成更新后所有认为强制走本地数据
    ABuEnv.g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL

    if market is not None and pre_market is not None:
        # 还原缓存的市场设置
        ABuEnv.g_market_target = pre_market


def store_abu_result_tuple(abu_result_tuple, n_folds=None, store_type=EStoreAbu.E_STORE_NORMAL,
                           custom_name=None):
    """
    保存abu.run_loop_back的回测结果AbuResultTuple对象,根据n_folds,store_type参数
    来定义存储的文件名称,透传参数使用ABuStore.store_abu_result_tuple执行操作

    :param abu_result_tuple: AbuResultTuple对象类型
    :param n_folds: 回测执行了几年,只影响存贮文件名
    :param store_type: 回测保存类型EStoreAbu类型,只影响存贮文件名
    :param custom_name: 如果store_type=EStoreAbu.E_STORE_CUSTOM_NAME时需要的自定义文件名称
    """
    ABuStore.store_abu_result_tuple(abu_result_tuple, n_folds, store_type=store_type, custom_name=custom_name)


def load_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_NORMAL, custom_name=None):
    """
    读取使用store_abu_result_tuple保存的回测结果,根据n_folds,store_type参数
    来定义读取的文件名称,依次读取orders_pd,action_pd,capital,benchmark后构造
    AbuResultTuple对象返回,透传参数使用ABuStore.load_abu_result_tuple执行操作

    :param n_folds: 回测执行了几年,只影响读取的文件名
    :param store_type: 回测保存类型EStoreAbu类型,只影响读取的文件名
    :param custom_name: 如果store_type=EStoreAbu.E_STORE_CUSTOM_NAME时需要的自定义文件名称
    :return: AbuResultTuple对象
    """
    return ABuStore.load_abu_result_tuple(n_folds, store_type, custom_name=custom_name)


# noinspection PyUnusedLocal
def gen_buy_from_chinese(*args, **kwargs):
    """
    抱歉!由于中文生成策略的方法也需要遵循一定的语法和句式,对于完全不熟悉编程的人可能会产生错误,'
          '造成无谓的经济损失,所以中文自动生成交易策略模块暂时不开放接口以及源代码!
    """

    print('抱歉!由于中文生成策略的方法也需要遵循一定的语法和句式,对于完全不熟悉编程的人可能会产生错误,'
          '造成无谓的经济损失,所以中文自动生成交易策略模块暂时不开放接口以及源代码!')


================================================
FILE: abupy/CoreBu/ABuBase.py
================================================
# -*- encoding:utf-8 -*-
"""
    类基础通用模块
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import logging

import pandas as pd
# noinspection PyUnresolvedReferences
from ..CoreBu.ABuFixes import signature, Parameter, pickle
from ..CoreBu import ABuEnv

__author__ = '阿布'
__weixin__ = 'abu_quant'


class FreezeAttrMixin(object):
    """冻结对外设置属性混入类,设置抛异常"""

    def _freeze(self):
        """冻结属性设置接口"""
        object.__setattr__(self, "__frozen", True)

    def __setattr__(self, key, value):
        if getattr(self, "__frozen", False) and not (key in type(self).__dict__ or key == "_cache"):
            raise AttributeError("You cannot add any new attribute '{key}'".format(key=key))
        object.__setattr__(self, key, value)


class PickleStateMixin(object):
    """混入有本地序列化需求的类"""

    # pickle的最高支持版本
    _pickle_highest_protocol = pickle.HIGHEST_PROTOCOL
    # python版本,也可简单使用是否py3
    _python_version = str(sys.version_info)
    # windows or mac os
    _is_mac_os = ABuEnv.g_is_mac_os
    # 是否考虑本身的版本version, 默认不考虑,忽略abupy的版本号
    skip_abupy_version = True

    def __getstate__(self):
        from .. import __version__
        _abupy_version = __version__
        self.pick_extend_work()
        return dict(self.__dict__.items(), _abupy_version=_abupy_version,
                    _pickle_highest_protocol=self._pickle_highest_protocol,
                    _python_version=self._python_version,
                    _is_mac_os=self._is_mac_os)

    def __setstate__(self, state):
        """开始从本地序列化文件转换为python对象,即unpick"""

        # 从本地序列化文件中读取的pickle的最高支持版本, 默认0
        pickle_highest_protocol = state.pop("_pickle_highest_protocol", 0)
        # 从本地序列化文件中读取的abupy的版本号, 默认0.0.1
        old_abupy_version = state.pop("_abupy_version", '0.0.1')
        # 从本地序列化文件中读取的python版本号, 默认2.7.0
        python_version = state.pop("_python_version", '2.7.0')
        # 从本地序列化文件中读取的平台信息, 默认False,即windows
        platform_version = state.pop("_is_mac_os", False)

        if self.skip_abupy_version:
            # 忽略abupy的版本号
            _abupy_version = old_abupy_version
        else:
            from .. import __version__
            _abupy_version = __version__

        if self._pickle_highest_protocol != pickle_highest_protocol \
                or _abupy_version != old_abupy_version or self._python_version != python_version \
                or self._is_mac_os != platform_version:
            """只要有一个信息不一致,打印info,即有序列化读取失败的可能"""
            logging.info(
                "unpickle {} : "
                "old pickle_highest_protocol={},"
                "now pickle_highest_protocol={}, "
                "old abupy_version={}, "
                "now abupy_version={}, "
                "old python_version={}, "
                "now python_version={}, "
                "old platform_version={}, "
                "now platform_version={}, ".format(
                    self.__class__.__name__,
                    pickle_highest_protocol, self._pickle_highest_protocol,
                    old_abupy_version, _abupy_version,
                    python_version, self._python_version,
                    platform_version, self._is_mac_os))

        self.__dict__.update(state)
        # 混入对象可覆盖unpick_extend_work方法,完成对象特有的unpick工作
        self.unpick_extend_work(state)

    # noinspection PyMethodMayBeStatic
    def pick_extend_work(self):
        """混入对象可覆盖pick_extend_work方法,完成对象特有的__getstate__工作"""
        pass

    def unpick_extend_work(self, state):
        """混入对象可覆盖unpick_extend_work方法,完成对象特有的__setstate__工作"""
        pass


class AbuParamBase(object):
    """对象基础类,实现对象基本信息打印,调试查看接口"""

    @classmethod
    def get_params(cls):
        # init中特意找了被类装饰器替换了的deprecated_original方法,即原始init方法
        init = getattr(cls.__init__, 'deprecated_original', cls.__init__)
        if init is object.__init__:
            # 非自定义init返回空
            return list()
        # 获取init的参数签名
        init_signature = signature(init)
        # 过滤self和func(*args), 和func(**kwargs)
        parameters = [p for p in init_signature.parameters.values()
                      if p.name != 'self' and p.kind != Parameter.VAR_KEYWORD and p.kind != Parameter.VAR_POSITIONAL]
        return sorted([p.name for p in parameters])

    def _filter_attr(self, user):
        """根据user设置,返回所有类属性key或者用户定义类属性key"""
        if not user:
            return self.__dict__.keys()

        # 只筛选用户定义类属性key
        user_attr = list(filter(
            lambda attr: not attr.startswith('_'), self.__dict__.keys()))
        return user_attr

    def to_dict(self, user=True):
        """for debug show dict"""
        return {attr: self.__dict__[attr] for attr in self._filter_attr(user)}

    def to_series(self, user=True):
        """for notebook debug show series"""
        return pd.Series(self.to_dict(user))

    def __str__(self):
        """打印对象显示:class name, params"""
        class_name = self.__class__.__name__
        return '%s(%s)' % (class_name, self.get_params())

    __repr__ = __str__


================================================
FILE: abupy/CoreBu/ABuDeprecated.py
================================================
# -*- encoding:utf-8 -*-
"""
    Deprecated警告模块
"""

import warnings

from ..CoreBu.ABuFixes import six


class AbuDeprecated(object):
    """支持装饰类或者方法,在使用类或者方法时警告Deprecated信息"""

    def __init__(self, tip_info=''):
        # 用户自定义警告信息tip_info
        self.tip_info = tip_info

    def __call__(self, obj):
        if isinstance(obj, six.class_types):
            # 针对类装饰
            return self._decorate_class(obj)
        else:
            # 针对方法装饰
            return self._decorate_fun(obj)

    def _decorate_class(self, cls):
        """实现类装饰警告Deprecated信息"""

        msg = "class {} is deprecated".format(cls.__name__)
        if self.tip_info:
            msg += "; {}".format(self.tip_info)
        # 取出原始init
        init = cls.__init__

        def wrapped(*args, **kwargs):
            warnings.warn(msg, category=DeprecationWarning)
            return init(*args, **kwargs)

        cls.__init__ = wrapped

        wrapped.__name__ = '__init__'
        wrapped.__doc__ = self._update_doc(init.__doc__)
        # init成为deprecated_original,必须要使用这个属性名字,在其它地方,如AbuParamBase会寻找原始方法找它
        wrapped.deprecated_original = init

        return cls

    def _decorate_fun(self, fun):
        """实现方法装饰警告Deprecated信息"""

        msg = "func {} is deprecated".format(fun.__name__)
        if self.tip_info:
            msg += "; {}".format(self.tip_info)

        def wrapped(*args, **kwargs):
            warnings.warn(msg, category=DeprecationWarning)
            return fun(*args, **kwargs)

        # 更新func及文档信息
        wrapped.__name__ = fun.__name__
        wrapped.__dict__ = fun.__dict__
        wrapped.__doc__ = self._update_doc(fun.__doc__)

        return wrapped

    def _update_doc(self, func_doc):
        """更新文档信息,把原来的文档信息进行合并格式化, 即第一行为deprecated_doc(Deprecated: tip_info),下一行为原始func_doc"""
        deprecated_doc = "Deprecated"
        if self.tip_info:
            """如果有tip format tip"""
            deprecated_doc = "{}: {}".format(deprecated_doc, self.tip_info)
        if func_doc:
            # 把原来的文档信息进行合并格式化, 即第一行为deprecated_doc,下一行为原始func_doc
            func_doc = "{}\n{}".format(deprecated_doc, func_doc)
        return func_doc


================================================
FILE: abupy/CoreBu/ABuEnv.py
================================================
# -*- encoding:utf-8 -*-
"""
    全局环境配置模块
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import logging
import os
import re
import platform
import sys
import warnings
from enum import Enum
from os import path

import numpy as np
import pandas as pd

from ..CoreBu.ABuFixes import six

__author__ = '阿布'
__weixin__ = 'abu_quant'

"""暂时支持windows和mac os,不是windows就是mac os(不使用Darwin做判断),linux下没有完整测试"""
g_is_mac_os = platform.system().lower().find("windows") < 0 and sys.platform != "win32"
"""python版本环境,是否python3"""
g_is_py3 = six.PY3
"""ipython,是否ipython运行环境"""
g_is_ipython = True
"""主进程pid,使用并行时由于ABuEnvProcess会拷贝主进程注册了的模块信息,所以可以用g_main_pid来判断是否在主进程"""
g_main_pid = os.getpid()

try:
    # noinspection PyUnresolvedReferences
    __IPYTHON__
except NameError:
    g_is_ipython = False

# noinspection PyBroadException
try:
    # noinspection PyUnresolvedReferences
    import psutil

    """有psutil,使用psutil.cpu_count计算cpu个数"""
    g_cpu_cnt = psutil.cpu_count(logical=True) * 1
except ImportError:
    if g_is_py3:
        # noinspection PyUnresolvedReferences
        g_cpu_cnt = os.cpu_count()
    else:
        import multiprocessing as mp

        g_cpu_cnt = mp.cpu_count()
except:
    # 获取cpu个数失败,默认4个
    g_cpu_cnt = 4

"""pandas忽略赋值警告"""
pd.options.mode.chained_assignment = None

"""numpy,pandas显示控制,默认开启"""
g_display_control = True
if g_display_control:
    # pandas DataFrame表格最大显示行数
    pd.options.display.max_rows = 20
    # pandas DataFrame表格最大显示列数
    pd.options.display.max_columns = 20
    # pandas精度浮点数显示4位
    pd.options.display.precision = 4
    # numpy精度浮点数显示4位,不使用科学计数法
    np.set_printoptions(precision=4, suppress=True)

"""忽略所有警告,默认关闭"""
g_ignore_all_warnings = False
"""忽略库警告,默认打开"""
g_ignore_lib_warnings = True
if g_ignore_lib_warnings:
    # noinspection PyBroadException
    try:
        import matplotlib

        matplotlib.warnings.filterwarnings('ignore')
        matplotlib.warnings.simplefilter('ignore')
        import sklearn

        sklearn.warnings.filterwarnings('ignore')
        sklearn.warnings.simplefilter('ignore')
    except:
        pass
if g_ignore_all_warnings:
    warnings.filterwarnings('ignore')
    warnings.simplefilter('ignore')

# ******************** 数据目录 start ****************
"""
    abu 文件目录根目录
    windows应该使用磁盘空间比较充足的盘符,比如:d://, e:/, f:///

    eg:
    root_drive = 'd://'
    root_drive = 'e://'
    root_drive = 'f://'
"""


def str_is_cn(a_str):
    """
        str_is_cn原始位置: UtilBu.ABuStrUtil
        为保持env为最初初始化不引入其它模块,这里临时拷贝使用
        通过正则表达式判断字符串中是否含有中文
        返回结果只判断是否search结果为None, 不返回具体匹配结果
        eg:
            K_CN_RE.search(a_str)('abc') is None
            return False
            K_CN_RE.search(a_str)('abc哈哈') -> <_sre.SRE_Match object; span=(3, 5), match='哈哈'>
            return True
    """

    def to_unicode(text, encoding=None, errors='strict'):
        """
        to_unicode原始位置: UtilBu.ABuStrUtil,为保持env为最初初始化不引入其它模块,这里临时拷贝使用
        """
        if isinstance(text, six.text_type):
            return text
        if not isinstance(text, (bytes, six.text_type)):
            raise TypeError('to_unicode must receive a bytes, str or unicode '
                            'object, got %s' % type(text).__name__)
        if encoding is None:
            encoding = 'utf-8'
        try:
            decode_text = text.decode(encoding, errors)
        except:
            # 切换试一下,不行就需要上层处理
            decode_text = text.decode('gbk' if encoding == 'utf-8' else 'utf-8', errors)
        return decode_text

    cn_re = re.compile(u'[\u4e00-\u9fa5]+')
    try:
        is_cn_path = cn_re.search(to_unicode(a_str)) is not None
    except:
        # 非gbk,utf8的其它编码会进入这里,统一进行处理
        is_cn_path = True
    return is_cn_path


root_drive = path.expanduser('~')
# root_drive = os.path.join(root_drive, u'测试')
# noinspection PyTypeChecker

if str_is_cn(root_drive):
    """
        如果用户根目录使用了中文名称,择放弃使用公共缓存文件夹,
        windows下可以使用中文用户名,这样会导致pandas读取,写入
        csv,hdf5出现问题,所以一旦发现用户路径为中文路径,改变
        缓存路径为abupy根代码路径
    """
    abupy_source_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(str(__file__))), os.path.pardir))
    # 改变缓存路径为abupy根代码路径
    root_drive = abupy_source_dir
    print('root_drive is change to {}'.format(root_drive))

"""abu数据缓存主目录文件夹"""
g_project_root = path.join(root_drive, 'abu')
"""abu数据文件夹 ~/abu/data"""
g_project_data_dir = path.join(g_project_root, 'data')
"""abu日志文件夹 ~/abu/log"""
g_project_log_dir = path.join(g_project_root, 'log')
"""abu数据库文件夹 ~/abu/db"""
g_project_db_dir = path.join(g_project_root, 'db')
"""abu缓存文件夹 ~/abu/cache"""
g_project_cache_dir = path.join(g_project_data_dir, 'cache')
"""abu项目数据主文件目录,即项目中的RomDataBu位置"""
g_project_rom_data_dir = path.join(path.dirname(path.abspath(path.realpath(__file__))), '../RomDataBu')

"""abu日志文件 ~/abu/log/info.log"""
g_project_log_info = path.join(g_project_log_dir, 'info.log')

"""hdf5做为金融时间序列存储的路径"""
g_project_kl_df_data = path.join(g_project_data_dir, 'df_kl.h5')

_p_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.pardir))

# 不再使用hdf5做为默认,有windows用户的hdf5环境有问题
"""使用书中相同的沙盒数据环境,RomDataBu/csv内置的金融时间序列文件"""
# g_project_kl_df_data_example = os.path.join(_p_dir, 'RomDataBu/df_kl.h5')
g_project_kl_df_data_example = os.path.join(_p_dir, 'RomDataBu/csv')
# ******************** 数据目录 end ****************


#  ******************** 数据源 start ****************

# ******************** CrawlBu end ****************
"""
chrome 驱动
"""
g_crawl_chrome_driver = None


# ******************** CrawlBu start ****************


# TODO 缩短 E_MARKET_SOURCE_bd->BD
class EMarketSourceType(Enum):
    """
        数据源,当数据获取不可靠时,可尝试切换数据源,更可连接私有的数据源
    """
    """百度 a股,美股,港股"""
    E_MARKET_SOURCE_bd = 0
    """腾讯 a股,美股,港股"""
    E_MARKET_SOURCE_tx = 1
    """网易 a股,美股,港股"""
    E_MARKET_SOURCE_nt = 2
    """新浪 美股"""
    E_MARKET_SOURCE_sn_us = 3

    """新浪 国内期货"""
    E_MARKET_SOURCE_sn_futures = 100
    """新浪 国际期货"""
    E_MARKET_SOURCE_sn_futures_gb = 101

    """火币 比特币,莱特币"""
    E_MARKET_SOURCE_hb_tc = 200


"""默认设置数据源使用E_MARKET_SOURCE_bd"""
g_market_source = EMarketSourceType.E_MARKET_SOURCE_bd

"""自定义的私有数据源类,默认None"""
g_private_data_source = None


# TODO 缩短 E_MARKET_TARGET_US->US
class EMarketTargetType(Enum):
    """
        交易品种类型,即市场类型,
        eg. 美股市场, A股市场, 港股市场, 国内期货市场,
            美股期权市场, TC币市场(比特币等
    """
    """美股市场"""
    E_MARKET_TARGET_US = 'us'
    """A股市场"""
    E_MARKET_TARGET_CN = 'hs'
    """港股市场"""
    E_MARKET_TARGET_HK = 'hk'

    """国内期货市场"""
    E_MARKET_TARGET_FUTURES_CN = 'futures_cn'
    """国际期货市场"""
    E_MARKET_TARGET_FUTURES_GLOBAL = 'futures_global'
    """美股期权市场"""
    E_MARKET_TARGET_OPTIONS_US = 'options_us'

    """TC币市场(比特币等)"""
    E_MARKET_TARGET_TC = 'tc'


class EMarketSubType(Enum):
    """
        子市场(交易所)类型定义
    """

    """美股纽交所NYSE"""
    US_N = 'NYSE'
    """美股纳斯达克NASDAQ"""
    US_OQ = 'NASDAQ'
    """美股粉单市场"""
    US_PINK = 'PINK'
    """美股OTCMKTS"""
    US_OTC = 'OTCMKTS'
    """美国证券交易所"""
    US_AMEX = 'AMEX'
    """未上市"""
    US_PREIPO = 'PREIPO'

    """港股hk"""
    HK = 'hk'

    """上证交易所sh"""
    SH = 'sh'
    """深圳交易所sz"""
    SZ = 'sz'

    """大连商品交易所DCE'"""
    DCE = 'DCE'
    """郑州商品交易所ZZCE'"""
    ZZCE = 'ZZCE'
    """上海期货交易所SHFE'"""
    SHFE = 'SHFE'

    """伦敦金属交易所"""
    LME = 'LME'
    """芝加哥商品交易所"""
    CBOT = 'CBOT'
    """纽约商品交易所"""
    NYMEX = 'NYMEX'

    """币类子市场COIN'"""
    COIN = 'COIN'


"""切换目标操作市场,美股,A股,港股,期货,比特币等,默认美股市场"""
g_market_target = EMarketTargetType.E_MARKET_TARGET_US

"""市场中1年交易日,默认250日"""
g_market_trade_year = 250
if g_market_target == EMarketTargetType.E_MARKET_TARGET_US:
    # 美股252天
    g_market_trade_year = 252
if g_market_target == EMarketTargetType.E_MARKET_TARGET_TC:
    # 默认设置币类每天都可以交易
    g_market_trade_year = 365


# TODO EMarketDataSplitMode移动到市场请求相关对应的模块中
class EMarketDataSplitMode(Enum):
    """
        ABuSymbolPd中请求参数,关于是否需要与基准数据对齐切割
    """
    """直接取出所有data,不切割,即外部需要切割"""
    E_DATA_SPLIT_UNDO = 0
    """内部根据start,end取切割data"""
    E_DATA_SPLIT_SE = 1


# TODO 缩短 E_DATA_FETCH_NORMAL->NORMAL
class EMarketDataFetchMode(Enum):
    """
        金融时间数据获取模式
    """
    """普通模式,尽量从本地获取数据,本地数据不满足的情况下进行网络请求"""
    E_DATA_FETCH_NORMAL = 0
    """强制从本地获取数据,本地数据不满足的情况下,返回None"""
    E_DATA_FETCH_FORCE_LOCAL = 1
    """强制从网络获取数据,不管本地数据是否满足"""
    E_DATA_FETCH_FORCE_NET = 2


"""
    金融时间数据获取模式模块设置g_data_fetch_mode,默认为E_DATA_FETCH_NORMAL,实际上默认值建议
    为E_DATA_FETCH_FORCE_LOCAL,所有数据提前使用ABu.run_kl_update完成updtae,之后使用本地数据回测,
    原因:
    1. mac os 10.9 later 多进程 + numpy有系统bug
    2. hdf5并行容易写坏文件
    3. 执行效率更高
    4. 分开数据获取与回测流程,更容易问题分析
"""
g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_NORMAL

"""是否开启ipython example 环境,默认关闭False"""
_g_enable_example_env_ipython = False


def enable_example_env_ipython(show_log=True, check_cn=True):
    """
    只为在ipython example 环境中运行与书中一样的数据,即读取RomDataBu/csv下的数据

    初始内置在RomDataBu/csv.zip下的数据只有zip压缩包,因为git上面的文件最好不要超过50m,
    内置测试数据,包括美股,a股,期货,比特币,港股数据初始化在csv.zip中,通过解压zip
    之后将测试数据为csv(老版本都是使用hdf5,但windows用户有些hdf5环境有问题)
    show_log: 是否显示enable example env will only read RomDataBu/df_kl.h5
    check_cn: 是否检测运行环境有中文路径
    """

    if not os.path.exists(g_project_kl_df_data_example):
        # 如果还没有进行解压,开始解压csv.zip
        data_example_zip = os.path.join(_p_dir, 'RomDataBu/csv.zip')
        try:
            from zipfile import ZipFile
            zip_csv = ZipFile(data_example_zip, 'r')
            unzip_dir = os.path.join(_p_dir, 'RomDataBu/')
            for csv in zip_csv.namelist():
                zip_csv.extract(csv, unzip_dir)
            zip_csv.close()
        except Exception as e:
            # 解压测试数据zip失败,就不开启测试数据模式了
            print('example env failed! e={}'.format(e))
            return

    global _g_enable_example_env_ipython, g_data_fetch_mode
    _g_enable_example_env_ipython = True
    g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL
    if check_cn:
        try:
            from ..UtilBu.ABuStrUtil import str_is_cn, to_unicode
            if str_is_cn(str(__file__)):
                # 检测到运行环境路径中含有中文,严重错误,将出错,使用中文警告
                msg = u'严重错误!当前运行环境下有中文路径,abu将无法正常运行!请不要使用中文路径名称, 当前环境为{}'.format(
                    to_unicode(str(__file__)))
                logging.info(msg)
                return
        except:
            # 没有必要显示log给用户,如果是其它编码的字符路径会进到这里
            # logging.exception(e)
            msg = 'error!non English characters in the current running environment,abu will not work properly!'
            logging.info(msg)
    if show_log:
        logging.info('enable example env will only read RomDataBu/csv')


def disable_example_env_ipython(show_log=True):
    """
    只为在ipython example 环境中运行与书中一样的数据。,即读取RomDataBu/df_kl.h5下的数据
    show_log: 是否显示disable example env
    """
    global _g_enable_example_env_ipython, g_data_fetch_mode
    _g_enable_example_env_ipython = False
    g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_NORMAL
    if show_log:
        logging.info('disable example env')


class EDataCacheType(Enum):
    """
        金融时间序列数据缓存类型
    """

    """读取及写入最快 但非固态硬盘写入慢,存贮空间需要大"""
    E_DATA_CACHE_HDF5 = 0
    """读取及写入最慢 但非固态硬盘写速度还可以,存贮空间需要小"""
    E_DATA_CACHE_CSV = 1
    """适合分布式扩展,存贮空间需要大"""
    E_DATA_CACHE_MONGODB = 2


# """默认金融时间序列数据缓存类型为HDF5,单机固态硬盘推荐HDF5,非固态硬盘使用CSV,否则量大后hdf5写入速度无法接受"""
# g_data_cache_type = EDataCacheType.E_DATA_CACHE_HDF5
"""对外版本由于用户电脑性能,存储空间且winodws用户,python2用户多,所以更改默认存储类型为csv"""
g_data_cache_type = EDataCacheType.E_DATA_CACHE_CSV

"""csv模式下的存储路径"""
g_project_kl_df_data_csv = path.join(g_project_data_dir, 'csv')

# ******************** 数据源 end   ****************

# ***********************特征快照切割 start *****************************
"""是否开启机器学习特征收集, 开启后速度会慢,默认关闭False"""
g_enable_ml_feature = False

"""是否开启买入订单前生成k线图快照,默认关闭False"""
g_enable_take_kl_snapshot = False

"""是否开启选股切割训练集股票数据与测试集股票数据,默认关闭False"""
g_enable_train_test_split = False

"""是否开启选股使用上一次切割完成的测试集股票数据,默认关闭False"""
g_enable_last_split_test = False

"""是否开启选股使用上一次切割完成的训练集股票数据,默认关闭False"""
g_enable_last_split_train = False

"""选股切割训练集股票数据与测试集股票数据切割参数n_folds,默认10"""
g_split_tt_n_folds = 10
# ***********************特征快照切割 end *****************************


# ***********************主裁 start *****************************
# TODO 内置ump的设置move到ABuUmpManager中

"""是否开启裁判拦截机制: 主裁deg,默认关闭False"""
g_enable_ump_main_deg_block = False
"""是否开启裁判拦截机制: 主裁jump,默认关闭False"""
g_enable_ump_main_jump_block = False
"""是否开启裁判拦截机制: 主裁price,默认关闭False"""
g_enable_ump_main_price_block = False
"""是否开启裁判拦截机制: 主裁wave,默认关闭False"""
g_enable_ump_main_wave_block = False
# ***********************主裁 end *****************************

# ***********************边裁 start *****************************

"""是否开启裁判拦截机制: 边裁deg,默认关闭False"""
g_enable_ump_edge_deg_block = False

"""是否开启裁判拦截机制: 边裁price,默认关闭False"""
g_enable_ump_edge_price_block = False

"""是否开启裁判拦截机制: 边裁wave,默认关闭False"""
g_enable_ump_edge_wave_block = False
"""是否开启裁判拦截机制: 边裁full,默认关闭False"""
g_enable_ump_edge_full_block = False


# ***********************边裁 end *****************************


#  ******************** 日志 start ****************
# TODO 将log抽出来从env中
def init_logging():
    """
    logging相关初始化工作,配置log级别,默认写入路径,输出格式
    """
    if g_is_ipython and not g_is_py3:
        """ipython在python2的一些版本需要reload logging模块,否则不显示log信息"""
        # noinspection PyUnresolvedReferences, PyCompatibility
        reload(logging)
        # pass

    if not os.path.exists(g_project_log_dir):
        # 创建log文件夹
        os.makedirs(g_project_log_dir)

    # 输出格式规范
    # file_handler = logging.FileHandler(g_project_log_info, 'a', 'utf-8')
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                        datefmt='%a, %d %b %Y %H:%M:%S',
                        filename=g_project_log_info,
                        filemode='a'
                        # handlers=[file_handler]
                        )

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    # 屏幕打印只显示message
    formatter = logging.Formatter('%(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)


init_logging()

#  ******************** 日志 end ****************

g_plt_figsize = (14, 7)


def init_plot_set():
    """全局plot设置"""
    import seaborn as sns
    sns.set_context('notebook', rc={'figure.figsize': g_plt_figsize})
    sns.set_style("darkgrid")

    import matplotlib
    # conda 5.0后需要添加单独matplotlib的figure设置否则pandas的plot size不生效
    matplotlib.rcParams['figure.figsize'] = g_plt_figsize


init_plot_set()


================================================
FILE: abupy/CoreBu/ABuEnvProcess.py
================================================
# -*- encoding:utf-8 -*-
"""
    多任务子进程拷贝跟随主进程设置模块
"""

from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import functools

# noinspection PyUnresolvedReferences
from ..CoreBu.ABuFixes import filter
from ..CoreBu.ABuFixes import signature, Parameter

__author__ = '阿布'
__weixin__ = 'abu_quant'


def add_process_env_sig(func):
    """
    初始化装饰器时给被装饰函数添加env关键字参数,在wrapper中将env对象进行子进程copy
    由于要改方法签名,多个装饰器的情况要放在最下面
    :param func:
    :return:
    """

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        # env = kwargs.pop('env', None)
        if 'env' in kwargs:
            """
                实际上linux, mac os上并不需要进行进程间模块内存拷贝,
                子进程fork后携带了父进程的内存信息,win上是需要的,
                暂时不做区分,都进行进程间的内存拷贝,如特别在乎效率的
                情况下基于linux系统,mac os可以不需要拷贝,如下:
                if kwargs['env'] is not None and not ABuEnv.g_is_mac_os:
                    # 只有windows进行内存设置拷贝
                    env.copy_process_env()
            """
            # if kwargs['env'] is not None and not ABuEnv.g_is_mac_os:
            env = kwargs.pop('env', None)
            if env is not None:
                # 将主进程中的env拷贝到子进程中
                env.copy_process_env()
        return func(*args, **kwargs)

    # 获取原始函数参数签名,给并行方法添加env参数
    sig = signature(func)

    if 'env' not in list(sig.parameters.keys()):
        parameters = list(sig.parameters.values())
        # 通过强制关键字参数,给方法加上env
        parameters.append(Parameter('env', Parameter.KEYWORD_ONLY, default=None))
        # wrapper的__signature__进行替换
        wrapper.__signature__ = sig.replace(parameters=parameters)

    return wrapper


class AbuEnvProcess(object):
    """多任务主进程内存设置拷贝执行者类"""

    def __init__(self):
        """迭代注册了的需要拷贝内存设置的模块,通过筛选模块中以g_或者_g_开头的属性,将这些属性拷贝为类属性变量"""
        for module in self.register_module():
            # 迭代注册了的需要拷贝内存设置的模块, 筛选模块中以g_或者_g_开头的, 且不能callable,即不是方法
            sig_env = list(filter(
                lambda _sig: not callable(_sig) and (_sig.startswith('g_') or _sig.startswith('_g_')), dir(module)))

            module_name = module.__name__
            # map(lambda sig: setattr(self, '{}_{}'.format(module_name, sig), module.__dict__[sig]), sig_env)
            for sig in sig_env:
                # 模块中的属性拷贝为类属性变量,key=module_name_sig
                setattr(self, '{}_{}'.format(module_name, sig), module.__dict__[sig])

    # noinspection PyMethodMayBeStatic
    def register_module(self):
        """
        注册需要拷贝内存的模块,不要全局模块注册,否则很多交叉引用,也不要做为类变量存储否则多进程传递pickle时会出错
        :return:
        """
        from ..BetaBu import ABuAtrPosition, ABuPositionBase
        from ..CoreBu import ABuEnv
        from ..SimilarBu import ABuCorrcoef
        from ..SlippageBu import ABuSlippageBuyMean, ABuSlippageBuyBase, ABuSlippageSellBase
        from ..TradeBu import ABuMLFeature
        from ..UmpBu import ABuUmpManager, ABuUmpMainBase, ABuUmpEdgeBase
        from ..TLineBu import ABuTLSimilar
        from ..MarketBu import ABuMarket
        from ..AlphaBu import ABuPickTimeWorker
        from ..FactorSellBu import ABuFactorCloseAtrNStop, ABuFactorPreAtrNStop
        from ..PickStockBu import ABuPickSimilarNTop
        from ..UtilBu import ABuProgress

        # TODO 将每个模块中全局设置放在一个模块配置代码文件中,这里只将所有模块配置代码文件加载
        return [ABuAtrPosition, ABuPositionBase, ABuEnv, ABuCorrcoef, ABuProgress,
                ABuSlippageBuyMean, ABuSlippageSellBase, ABuSlippageBuyBase, ABuUmpMainBase, ABuUmpEdgeBase,
                ABuMLFeature, ABuUmpManager, ABuTLSimilar, ABuPickTimeWorker,
                ABuFactorCloseAtrNStop, ABuMarket, ABuFactorPreAtrNStop, ABuPickSimilarNTop]

    def copy_process_env(self):
        """为子进程拷贝主进程中的设置执行,在add_process_env_sig装饰器中调用,外部不应主动使用"""
        for module in self.register_module():
            # 迭代注册了的需要拷贝内存设置的模块, 筛选模块中以g_或者_g_开头的, 且不能callable,即不是方法
            sig_env = list(filter(
                lambda sig: not callable(sig) and (sig.startswith('g_') or sig.startswith('_g_')), dir(module)))
            module_name = module.__name__
            for _sig in sig_env:
                # 格式化类变量中对应模块属性的key
                name = '{}_{}'.format(module_name, _sig)
                # 根据应模块属性的key(name)getattr获取属性值
                val = getattr(self, name)
                # 为子模块内存变量进行值拷贝
                module.__dict__[_sig] = val
                # print(name, val)

    def __str__(self):
        """打印对象显示:注册需要拷贝内存的模块中在AbuEnvProcess对象属性的映射key值,以及value值"""

        str_dict = dict()
        for module in self.register_module():
            sig_env = list(filter(
                lambda sig: not callable(sig) and (sig.startswith('g_') or sig.startswith('_g_')), dir(module)))
            module_name = module.__name__
            for _sig in sig_env:
                # format对象属性的映射key值
                name = '{}_{}'.format(module_name, _sig)
                # 根据映射key值getattr出value值
                attr_str = getattr(self, name)
                str_dict[name] = attr_str
        return str(str_dict)

    __repr__ = __str__


================================================
FILE: abupy/CoreBu/ABuFixes.py
================================================
# -*- encoding:utf-8 -*-
"""
    对各个依赖库不同版本,不同系统的规范进行统一以及问题修正模块
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import functools
import numbers
import sys

import matplotlib
import numpy as np
import pandas as pd
import scipy
import sklearn as skl

__author__ = '阿布'
__weixin__ = 'abu_quant'


def _parse_version(version_string):
    """
    根据库中的__version__字段,转换为tuple,eg. '1.11.3'->(1, 11, 3)
    :param version_string: __version__字符串对象
    :return: tuple 对象
    """
    version = []
    for x in version_string.split('.'):
        try:
            version.append(int(x))
        except ValueError:
            version.append(x)
    return tuple(version)


"""numpy 版本号tuple"""
np_version = _parse_version(np.__version__)
"""sklearn 版本号tuple"""
skl_version = _parse_version(skl.__version__)
"""pandas 版本号tuple"""
pd_version = _parse_version(pd.__version__)
"""scipy 版本号tuple"""
sp_version = _parse_version(scipy.__version__)
"""matplotlib 版本号tuple"""
mpl_version = _parse_version(matplotlib.__version__)

try:
    from inspect import signature, Parameter
except ImportError:
    try:
        from funcsigs import signature, Parameter
    except ImportError:
        from ..ExtBu.funcsigs import signature, Parameter

try:
    # noinspection PyCompatibility
    from concurrent.futures import ThreadPoolExecutor
except ImportError:
    from ..ExtBu.futures.thread import ThreadPoolExecutor

try:
    from ..ExtBu import six
except ImportError:
    import six as six

# try:
#     from six.moves import zip, xrange, range, reduce, map, filter
# except ImportError:
#     # noinspection PyUnresolvedReferences
#     from ..ExtBu.six.moves import zip, xrange, range, reduce, map, filter
# noinspection PyUnresolvedReferences
try:
    from ..ExtBu.six.moves import zip, xrange, range, reduce, map, filter
except ImportError:
    # noinspection PyUnresolvedReferences
    from six.moves import zip, xrange, range, reduce, map, filter

try:
    # noinspection all
    from six.moves import cPickle as pickle
except ImportError:
    # noinspection all
    from six.moves import cPickle as pickle

if six.PY3:
    # noinspection PyProtectedMember
    Unpickler = pickle._Unpickler
    # noinspection PyProtectedMember
    Pickler = pickle._Pickler
else:
    Unpickler = pickle.Unpickler
    Pickler = pickle.Pickler

if six.PY3:
    def as_bytes(s):
        if isinstance(s, bytes):
            return s
        return s.encode('latin1')
else:
    as_bytes = str

try:
    if six.PY3:
        from functools import lru_cache
    else:
        from functools32 import lru_cache
except ImportError:
    # noinspection PyUnusedLocal
    def lru_cache(maxsize=100):
        def decorate(func):
            @functools.wraps(func)
            def wrapper(*args, **kwargs):
                return func(*args, **kwargs)

            return wrapper

        return decorate

try:
    from itertools import combinations_with_replacement
except ImportError:
    # Backport of itertools.combinations_with_replacement for Python 2.6,
    # from Python 3.4 documentation (http://tinyurl.com/comb-w-r), copyright
    # Python Software Foundation (https://docs.python.org/3/license.html)
    def combinations_with_replacement(iterable, r):
        # combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC
        pool = tuple(iterable)
        n = len(pool)
        if not n and r:
            return
        indices = [0] * r
        yield tuple(pool[i] for i in indices)
        while True:
            for i in reversed(range(r)):
                if indices[i] != n - 1:
                    break
            else:
                return
            indices[i:] = [indices[i] + 1] * (r - i)
            yield tuple(pool[i] for i in indices)

if sys.version_info < (2, 7, 0):
    # partial cannot be pickled in Python 2.6
    # http://bugs.python.org/issue1398
    # noinspection PyPep8Naming
    class partial(object):
        def __init__(self, func, *args, **keywords):
            functools.update_wrapper(self, func)
            self.func = func
            self.args = args
            self.keywords = keywords

        def __call__(self, *args, **keywords):
            args = self.args + args
            kwargs = self.keywords.copy()
            kwargs.update(keywords)
            return self.func(*args, **kwargs)
else:
    # noinspection PyUnresolvedReferences
    from functools import partial

"""
    matplotlib fixes
"""
# 先别加了,用的地方内部try吧,不然waring太多
# try:
#     # noinspection PyUnresolvedReferences, PyDeprecation
#     import matplotlib.finance as mpf
# except ImportError:
#     # 2.2 才会有
#     # noinspection PyUnresolvedReferences, PyDeprecation
#     import matplotlib.mpl_finance as mpf

"""
    urlencode
"""
if six.PY3:
    # noinspection PyUnresolvedReferences, PyCompatibility
    from urllib.parse import urlencode
else:
    # noinspection PyUnresolvedReferences
    from urllib import urlencode

"""
    sklearn fixes
"""


# noinspection PyProtectedMember,PyUnresolvedReferences
def check_random_state(seed):
    if seed is None or seed is np.random:
        return np.random.mtrand._rand
    if isinstance(seed, (numbers.Integral, np.integer)):
        return np.random.RandomState(seed)
    if isinstance(seed, np.random.RandomState):
        return seed
    raise ValueError('%r cannot be used to seed a numpy.random.RandomState'
                     ' instance' % seed)


try:
    skl_ver_big = skl_version >= (0, 18, 0)
except:
    skl_ver_big = True

if skl_ver_big:
    mean_squared_error_scorer = 'neg_mean_squared_error'
    mean_absolute_error_scorer = 'neg_mean_absolute_error'
    median_absolute_error_scorer = 'neg_median_absolute_error'
    log_loss = 'neg_log_loss'

    try:
        from sklearn.model_selection import train_test_split
        from sklearn.model_selection import learning_curve
        from sklearn.model_selection import cross_val_score
        from sklearn.model_selection import GridSearchCV
        # noinspection PyPep8Naming
        from sklearn.mixture import GaussianMixture as GMM


        class KFold(object):
            """
                sklearn将KFold移动到了model_selection,而且改变了用法,暂时不需要
                这么复杂的功能,将sklearn中关键代码简单实现,不from sklearn.model_selection import KFold
            """

            def __init__(self, n, n_folds=3, shuffle=False, random_state=None):
                if abs(n - int(n)) >= np.finfo('f').eps:
                    raise ValueError("n must be an integer")
                self.n = int(n)

                if abs(n_folds - int(n_folds)) >= np.finfo('f').eps:
                    raise ValueError("n_folds must be an integer")
                self.n_folds = n_folds = int(n_folds)

                if n_folds <= 1:
                    raise ValueError(
                        "k-fold cross validation requires at least one"
                        " train / test split by setting n_folds=2 or more,"
                        " got n_folds={0}.".format(n_folds))
                if n_folds > self.n:
                    raise ValueError(
                        ("Cannot have number of folds n_folds={0} greater"
                         " than the number of samples: {1}.").format(n_folds, n))

                if not isinstance(shuffle, bool):
                    raise TypeError("shuffle must be True or False;"
                                    " got {0}".format(shuffle))
                self.shuffle = shuffle
                self.random_state = random_state

                self.idxs = np.arange(n)
                if shuffle:
                    rng = check_random_state(self.random_state)
                    rng.shuffle(self.idxs)

            def __iter__(self):
                ind = np.arange(self.n)
                for test_index in self._iter_test_masks():
                    train_index = np.logical_not(test_index)
                    train_index = ind[train_index]
                    test_index = ind[test_index]
                    yield train_index, test_index

            def _iter_test_masks(self):
                for test_index in self._iter_test_indices():
                    test_mask = self._empty_mask()
                    test_mask[test_index] = True
                    yield test_mask

            def _empty_mask(self):
                return np.zeros(self.n, dtype=np.bool)

            def _iter_test_indices(self):
                n = self.n
                n_folds = self.n_folds
                fold_sizes = (n // n_folds) * np.ones(n_folds, dtype=np.int)
                fold_sizes[:n % n_folds] += 1
                current = 0
                for fold_size in fold_sizes:
                    start, stop = current, current + fold_size
                    yield self.idxs[start:stop]
                    current = stop

            def __repr__(self):
                return '%s.%s(n=%i, n_folds=%i, shuffle=%s, random_state=%s)' % (
                    self.__class__.__module__,
                    self.__class__.__name__,
                    self.n,
                    self.n_folds,
                    self.shuffle,
                    self.random_state,
                )

            def __len__(self):
                return self.n_folds

    except ImportError:
        from sklearn.cross_validation import train_test_split
        from sklearn.cross_validation import KFold
        from sklearn.cross_validation import cross_val_score
        from sklearn.learning_curve import learning_curve
        from sklearn import cross_validation
        from sklearn.grid_search import GridSearchCV
        from sklearn.mixture import GMM
else:
    mean_squared_error_scorer = 'mean_squared_error'
    mean_absolute_error_scorer = 'mean_absolute_error'
    median_absolute_error_scorer = 'median_absolute_error'
    log_loss = 'log_loss'

    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.cross_validation import train_test_split
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.cross_validation import KFold
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.cross_validation import cross_val_score
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.learning_curve import learning_curve
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn import cross_validation
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.grid_search import GridSearchCV
    # noinspection PyUnresolvedReferences, PyDeprecation
    from sklearn.mixture import GMM

try:
    if np_version < (1, 8, 1):
        def array_equal(a1, a2):
            # copy-paste from numpy 1.8.1
            try:
                a1, a2 = np.asarray(a1), np.asarray(a2)
            except:
                return False
            if a1.shape != a2.shape:
                return False
            return bool(np.asarray(a1 == a2).all())
    else:
        from numpy import array_equal
except:
    from numpy import array_equal

try:
    if sp_version < (0, 13, 0):
        def rankdata(a, method='average'):
            if method not in ('average', 'min', 'max', 'dense', 'ordinal'):
                raise ValueError('unknown method "{0}"'.format(method))

            arr = np.ravel(np.asarray(a))
            algo = 'mergesort' if method == 'ordinal' else 'quicksort'
            sorter = np.argsort(arr, kind=algo)

            inv = np.empty(sorter.size, dtype=np.intp)
            inv[sorter] = np.arange(sorter.size, dtype=np.intp)

            if method == 'ordinal':
                return inv + 1

            arr = arr[sorter]
            obs = np.r_[True, arr[1:] != arr[:-1]]
            dense = obs.cumsum()[inv]

            if method == 'dense':
                return dense

            # cumulative counts of each unique value
            # noinspection PyUnresolvedReferences
            count = np.r_[np.nonzero(obs)[0], len(obs)]

            if method == 'max':
                return count[dense]

            if method == 'min':
                return count[dense - 1] + 1

            # average method
            return .5 * (count[dense] + count[dense - 1] + 1)
    else:
        # noinspection PyUnresolvedReferences
        from scipy.stats import rankdata
except:
    # noinspection PyUnresolvedReferences
    from scipy.stats import rankdata


================================================
FILE: abupy/CoreBu/ABuParallel.py
================================================
# -*- encoding:utf-8 -*-
"""
    并行封装模块,主要针对不同平台统一接口规范:

    windows 上使用joblib进行长时间的多任务,如超过10小时以上时,在任何最后有系统pop任务
    的错误,所以windows上使用ProcessPoolExecutor进行多任务,套上Parallel和delayed保持接口的
    通用性及规范统一
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import functools

from ..CoreBu import ABuEnv

__author__ = '阿布'
__weixin__ = 'abu_quant'

# if ABuEnv.g_is_mac_os:
if False:
    """
        对外版本不再使用joblib避免python2,python3,mac, windows等joblib最后的pop一直出不来的bug,
        有能力可自行打开,在mac下python3环境且cpu足够快建议打开
    """
    # MAC 直接import Parallel, delayed
    # noinspection PyUnresolvedReferences
    from ..ExtBu.joblib import Parallel, delayed
else:
    # windows需要使用ProcessPoolExecutor
    try:
        # noinspection PyCompatibility
        from concurrent.futures import ProcessPoolExecutor
    except ImportError:
        from ..ExtBu.futures import ProcessPoolExecutor


    def delayed(function):
        """
        将function通过functools.wraps及delayed_function进行保留,但不执行
        :param function:
        :return:
        """
        def delayed_function(*args, **kwargs):
            """将function以及参数返回为tuple,tuple[0]为原始function"""
            return function, args, kwargs

        try:
            delayed_function = functools.wraps(function)(delayed_function)
        except AttributeError:
            raise TypeError('wraps fails on some callable objects')
        return delayed_function


    # noinspection PyUnusedLocal
    class Parallel(object):
        """封装ProcessPoolExecutor进行并行任务执行操作"""

        def __init__(self, n_jobs=1, backend='multiprocessing', verbose=0,
                     pre_dispatch='2 * n_jobs', batch_size='auto',
                     temp_folder=None, max_nbytes='1M', mmap_mode='r'):
            """
            :param n_jobs: 并行启动的进程数,任务数量
            :param backend: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param verbose: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param pre_dispatch: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param batch_size: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param temp_folder: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param max_nbytes: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            :param mmap_mode: 无意义,只是为了统一接口规范,与joblib.Parallel保持一样的参数
            """
            self.n_jobs = n_jobs

        def __call__(self, iterable):
            """为与joblib并行保持一致,内部使用ProcessPoolExecutor开始工作"""

            result = []

            def when_done(r):
                """ProcessPoolExecutor每一个进程结束后结果append到result中"""
                result.append(r.result())

            if self.n_jobs <= 0:
                # 主要为了适配 n_jobs = -1,joblib中启动cpu个数个进程并行执行
                self.n_jobs = ABuEnv.g_cpu_cnt

            if self.n_jobs == 1:
                # 如果只开一个进程,那么只在主进程(或当前运行的子进程)里运行,方便pdb debug且与joblib运行方式保持一致
                for jb in iterable:
                    result.append(jb[0](*jb[1], **jb[2]))
            else:
                with ProcessPoolExecutor(max_workers=self.n_jobs) as pool:
                    for jb in iterable:
                        # 这里iterable里每一个元素是delayed.delayed_function保留的tuple
                        future_result = pool.submit(jb[0], *jb[1], **jb[2])
                        future_result.add_done_callback(when_done)
            return result


def run_in_thread(func, *args, **kwargs):
    """
    多线程工具函数,不涉及返回值等细节处理时使用
    :param func: 被线程委托的函数
    :return: 返回Thread线程对象
    """
    from threading import Thread
    thread = Thread(target=func, args=args, kwargs=kwargs)
    thread.daemon = True
    thread.start()
    return thread


def run_in_subprocess(func, *args, **kwargs):
    """
    多进程工具函数,不涉及返回值等细节处理时使用
    :param func: 被进程委托的函数
    :return: 返回multiprocessing进程对象
    """
    from multiprocessing import Process
    process = Process(target=func, args=args, kwargs=kwargs)
    process.daemon = True
    process.start()
    return process


================================================
FILE: abupy/CoreBu/ABuPdHelper.py
================================================
# -*- encoding:utf-8 -*-
"""
    封装pandas中版本兼容问题,保持接口规范情况下,避免警告
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import functools
from collections import Iterable

import pandas as pd
from ..CoreBu.ABuFixes import partial
from ..CoreBu.ABuFixes import six

__author__ = '阿布'
__weixin__ = 'abu_quant'

try:
    # noinspection PyUnresolvedReferences
    from pandas.tseries.resample import DatetimeIndexResampler
    g_pandas_has_resampler = True
except ImportError:
    try:
        # noinspection PyUnresolvedReferences
        from pandas.core.resample import DatetimeIndexResampler
        g_pandas_has_resampler = True
    except ImportError:
        g_pandas_has_resampler = False

try:
    # noinspection PyUnresolvedReferences
    from pandas.core.window import EWM
    g_pandas_has_ewm = True
except ImportError:
    g_pandas_has_ewm = False

try:
    # noinspection PyUnresolvedReferences
    from pandas.core.window import Rolling
    g_pandas_has_rolling = True
except ImportError:
    g_pandas_has_rolling = False

try:
    # noinspection PyUnresolvedReferences
    from pandas.core.window import Expanding
    g_pandas_has_expanding = True
except ImportError:
    g_pandas_has_expanding = False


def __pd_object_covert_start(iter_obj):
    """
    _pd_object_covert中进行参数检测及转换
    :param iter_obj: 将要进行操作的可迭代序列
    :return: 操作之后的返回值是否需要转换为np.array
    """
    if isinstance(iter_obj, (pd.Series, pd.DataFrame)):
        # 如果本身就是(pd.Series, pd.DataFrame),返回对返回值不需要转换,即False
        return iter_obj, False
    # TODO Iterable和six.string_types的判断抽出来放在一个模块,做为Iterable的判断来使用
    if isinstance(iter_obj, Iterable) and not isinstance(iter_obj, six.string_types):
        # 可迭代对象使用pd.Series进行包装,且返回对返回值需要转换为np.array,即True
        return pd.Series(iter_obj), True
    raise TypeError('pd_object must support Iterable!!!')


def _pd_object_covert(func):
    """针对参数序列进行pandas处理的事前,事后装饰器"""

    @functools.wraps(func)
    def wrapper(pd_object, pd_object_cm, how, *args, **kwargs):
        """事前装饰工作__pd_object_covert_start,事后根据是否需要转换为np.array工作"""
        # 事前装饰工作__pd_object_covert_start
        pd_object, ret_covert = __pd_object_covert_start(pd_object)
        ret = func(pd_object, pd_object_cm, how, *args, **kwargs)
        # 事后根据是否需要转换为np.array工作
        if ret is not None and ret_covert:
            return ret.values
        return ret

    return wrapper


@_pd_object_covert
def _pd_rolling(pd_object, pd_object_cm, how, *args, **kwargs):
    """
    被_pd_object_covert装饰,对pandas中的rolling操作,根据pandas version版本自动选择调用方式
    :param pd_object: 可迭代的序列,pd.Series, pd.DataFrame或者只是Iterable
    :param pd_object_cm: 与pd_object相同,针对需要两个pandas对象或者序列执行的操作,如corr,cov等
    :param how: 代表方法操作名称,eg. mean, std, var
    :return:
    """
    if g_pandas_has_rolling:
        """pandas版本高,使用如pd_object.rolling直接调用"""
        rolling_obj = pd_object.rolling(*args, **kwargs)
        if hasattr(rolling_obj, how):
            if pd_object_cm is None:
                return getattr(rolling_obj, how)()
            # 需要两个pd_object进行的操作, getattr(rolling_obj, how)(pd_object_cm)
            return getattr(rolling_obj, how)(pd_object_cm)
    else:
        """pandas版本低,使用如pd.rolling_mean方法调用"""
        how_func = 'rolling_{}'.format(how)
        if hasattr(pd, how_func):
            if pd_object_cm is None:
                return getattr(pd, how_func)(pd_object, *args, **kwargs)
            # 需要两个pd_object进行的操作,getattr(pd, how_func)(pd_object, pd_object_cm, *args, **kwargs)
            return getattr(pd, how_func)(pd_object, pd_object_cm, *args, **kwargs)
    raise RuntimeError('_pd_rolling {} getattr error'.format(how))


"""没有全部导出,只导出常用的"""
pd_rolling_mean = partial(_pd_rolling, how='mean', pd_object_cm=None)
pd_rolling_median = partial(_pd_rolling, how='median', pd_object_cm=None)
pd_rolling_std = partial(_pd_rolling, how='std', pd_object_cm=None)
pd_rolling_var = partial(_pd_rolling, how='var', pd_object_cm=None)
pd_rolling_max = partial(_pd_rolling, how='max', pd_object_cm=None)
pd_rolling_min = partial(_pd_rolling, how='min', pd_object_cm=None)
pd_rolling_sum = partial(_pd_rolling, how='sum', pd_object_cm=None)
pd_rolling_kurt = partial(_pd_rolling, how='kurt', pd_object_cm=None)
pd_rolling_skew = partial(_pd_rolling, how='skew', pd_object_cm=None)
pd_rolling_corr = partial(_pd_rolling, how='corr')
pd_rolling_cov = partial(_pd_rolling, how='cov')


@_pd_object_covert
def _pd_ewm(pd_object, pd_object_cm, how, *args, **kwargs):
    """
    被_pd_object_covert装饰,对pandas中的ewm操作,根据pandas version版本自动选择调用方式
    :param pd_object: 可迭代的序列,pd.Series, pd.DataFrame或者只是Iterable
    :param pd_object_cm: 与pd_object相同,针对需要两个pandas对象或者序列执行的操作,如corr,cov等
    :param how: 代表方法操作名称,eg. mean, std, var
    :return:
    """
    if g_pandas_has_ewm:
        """pandas版本高,使用如pd_object.ewm直接调用"""
        ewm_obj = pd_object.ewm(*args, **kwargs)
        if hasattr(ewm_obj, how):
            if pd_object_cm is None:
                return getattr(ewm_obj, how)()
            # 需要两个pd_object进行的操作
            return getattr(ewm_obj, how)(pd_object_cm)
    else:
        """pandas版本低,使用如pd.ewmstd方法调用"""
        if how == 'mean':
            # pd.ewma特殊代表加权移动平均,所以使用a替换mean
            how = 'a'
        how_func = 'ewm{}'.format(how)
        if hasattr(pd, how_func):
            if pd_object_cm is None:
                return getattr(pd, how_func)(pd_object, *args, **kwargs)
            # 需要两个pd_object进行的操作
            return getattr(pd, how_func)(pd_object, pd_object_cm, *args, **kwargs)
    raise RuntimeError('_pd_ewm {} getattr error'.format(how))


"""没有全部导出,只导出常用的"""
pd_ewm_mean = partial(_pd_ewm, how='mean', pd_object_cm=None)
pd_ewm_std = partial(_pd_ewm, how='std', pd_object_cm=None)
pd_ewm_var = partial(_pd_ewm, how='var', pd_object_cm=None)
pd_ewm_corr = partial(_pd_ewm, how='corr')
pd_ewm_cov = partial(_pd_ewm, how='cov')


@_pd_object_covert
def _pd_expanding(pd_object, pd_object_cm, how, *args, **kwargs):
    """
    对pandas中的expanding操作,根据pandas version版本自动选择调用方式
    :param pd_object: 可迭代的序列,pd.Series, pd.DataFrame或者只是Iterable
    :param pd_object_cm: 与pd_object相同,针对需要两个pandas对象或者序列执行的操作,如corr,cov等
    :param how: 代表方法操作名称,eg. mean, std, var
    :return:
    """
    if g_pandas_has_expanding:
        """pandas版本高,使用如pd_object.expanding直接调用"""
        rolling_obj = pd_object.expanding(*args, **kwargs)
        if hasattr(rolling_obj, how):
            if pd_object_cm is None:
                return getattr(rolling_obj, how)()
            else:
                # 需要两个pd_object进行的操作
                return getattr(rolling_obj, how)(pd_object_cm)
    else:
        """pandas版本低,使用如pd.expanding_mean方法调用"""
        how_func = 'expanding_{}'.format(how)
        if hasattr(pd, how_func):
            if pd_object_cm is None:
                return getattr(pd, how_func)(pd_object, *args, **kwargs)
            else:
                # 需要两个pd_object进行的操作
                return getattr(pd, how_func)(pd_object, pd_object_cm, *args, **kwargs)
    raise RuntimeError('_pd_expanding {} getattr error'.format(how))


"""没有全部导出,只导出常用的"""
pd_expanding_mean = partial(_pd_expanding, how='mean', pd_object_cm=None)
pd_expanding_median = partial(_pd_expanding, how='median', pd_object_cm=None)
pd_expanding_std = partial(_pd_expanding, how='std', pd_object_cm=None)
pd_expanding_var = partial(_pd_expanding, how='var', pd_object_cm=None)
pd_expanding_max = partial(_pd_expanding, how='max', pd_object_cm=None)
pd_expanding_min = partial(_pd_expanding, how='min', pd_object_cm=None)
pd_expanding_sum = partial(_pd_expanding, how='sum', pd_object_cm=None)
pd_expanding_kurt = partial(_pd_expanding, how='kurt', pd_object_cm=None)
pd_expanding_skew = partial(_pd_expanding, how='skew', pd_object_cm=None)
pd_expanding_corr = partial(_pd_expanding, how='corr')
pd_expanding_cov = partial(_pd_expanding, how='cov')


def pd_resample(pd_object, rule, *args, **kwargs):
    """
    对pandas中的resample操作,根据pandas version版本自动选择调用方式
    :param pd_object: 可迭代的序列,pd.Series, pd.DataFrame或者只是Iterable
    :param rule: 具体的resample函数中需要的参数 eg. 21D, 即重采样周期值
    :return:
    """
    if g_pandas_has_resampler:
        """pandas版本高,使用如pd_object.resample('21D').mean()直接调用"""
        how = kwargs.pop('how', '')
        rep_obj = pd_object.resample(rule)
        if hasattr(rep_obj, how):
            return getattr(rep_obj, how)()
        print('rep_obj how is error set!!!')
        return rep_obj
    else:
        """pandas版本低,使用如pd_object.resample('21D').how方法调用, 也就不用kwargs.pop('how', '')了"""
        return pd_object.resample(rule, *args, **kwargs)


================================================
FILE: abupy/CoreBu/ABuStore.py
================================================
# -*- encoding:utf-8 -*-
"""针对交易回测结果存储,读取模块"""

import os
from collections import namedtuple
from enum import Enum
import datetime

import numpy as np
import pandas as pd

from ..CoreBu import ABuEnv
from ..UtilBu import ABuFileUtil


# noinspection PyClassHasNoInit
class AbuResultTuple(namedtuple('AbuResultTuple',
                                ('orders_pd',
                                 'action_pd',
                                 'capital',
                                 'benchmark'))):
    """
        使用abu.run_loop_back返回的nametuple对象:

        orders_pd:回测结果生成的交易订单构成的pd.DataFrame对象
        action_pd: 回测结果生成的交易行为构成的pd.DataFrame对象
        capital:   资金类AbuCapital实例化对象
        benchmark: 交易基准对象,AbuBenchmark实例对象
    """
    __slots__ = ()

    def __repr__(self):
        """打印对象显示:orders_pd.info, action_pd.info, capital, benchmark"""
        return "orders_pd:{}\naction_pd:{}\ncapital:{}\nbenchmark:{}".format(
            self.orders_pd.info(),
            self.action_pd.info(),
            self.capital, self.benchmark)


class EStoreAbu(Enum):
    """保存回测结果的enum类型"""

    """保存普通类型,存储文件后缀为空"""
    E_STORE_NORMAL = 0

    """保存训练集回测,存储文件后缀为train"""
    E_STORE_TRAIN = 1
    """保存测试集交易回测,存储文件后缀为test"""
    E_STORE_TEST = 2

    """保存测试集交易使用主裁ump进行回测,存储文件后缀为test_ump"""
    E_STORE_TEST_UMP = 3
    """保存测试集交易使用主裁+边裁ump进行回测,存储文件后缀为test_ump_with_edge"""
    E_STORE_TEST_UMP_WITH_EDGE = 4

    """保存测回测,存储文件后缀为自定义字符串"""
    E_STORE_CUSTOM_NAME = 5


def dump_custom_abu_index_csv(custom_name, custom_desc):
    """
    将回测模块的回测结果文件做index描述记录的保存,特定保存已custom_name为索引index,
    custom_desc为内容的一行一列的DataFrame数据,数据保存在cache目录中保存为csv类型文件custom_abu_index.csv
    :param custom_name: custom_name为索引index
    :param custom_desc: 构成DataFrame数据custom_desc为内容
    """
    # 无描述显示No description
    custom_desc = 'No description' if custom_desc is None else custom_desc
    # 特定的一行一列的DataFrame数据
    index_path = np.array([custom_desc]).reshape(1, 1)
    # custom_name为索引index,custom_desc为内容
    index_df = pd.DataFrame(index_path, index=[custom_name],
                            columns=['description'])

    # 数据保存在cache目录中
    index_csv_path = os.path.join(ABuEnv.g_project_data_dir, 'cache', 'custom_abu_index.csv')
    ABuFileUtil.ensure_dir(index_csv_path)

    index_csv_df = ABuFileUtil.load_df_csv(index_csv_path)
    if index_csv_df is not None:
        # 如果已存在相同索引直接返回,不再写入
        if custom_name in index_csv_df.index:
            return
        index_csv_df = index_csv_df.append(index_df)
    else:
        index_csv_df = index_df
    # 最终dump为csv文件
    ABuFileUtil.dump_df_csv(index_csv_path, index_csv_df)


def dump_custom_ump_index_csv(custom_name, ump_unique, is_main_ump, custom_desc):
    """
    将ump训练好的数据文件做index描述记录的保存,特定保存已custom_name + ump_unique为索引index,
    custom_desc, is_main_ump, ump_unique为内容的一行3列的DataFrame数据,数据保存在ump缓存目录
    中保存为csv类型文件custom_ump_index.csv
    :param custom_name: custom_name + ump_unique为索引index
    :param ump_unique: ump类的标识str类型,ump.class_unique_id()
    :param is_main_ump: 是主裁还是边裁标识str类型,eg:main or edge
    :param custom_desc: ump训练数据的描述str
    """
    # 无描述显示No description
    custom_desc = 'No description' if custom_desc is None else custom_desc
    # 特定的一行3列的DataFrame数据
    index_path = np.array([custom_desc, ump_unique, is_main_ump]).reshape(1, 3)
    # custom_desc, is_main_ump, ump_unique为内容的一行3列的DataFrame数据
    index_df = pd.DataFrame(index_path, index=['{}:{}'.format(ump_unique, custom_name)],
                            columns=['description', 'ump_unique', 'is_main_ump'])

    # 数据保存在ump缓存目录
    index_csv_path = os.path.join(ABuEnv.g_project_data_dir, 'ump', 'custom_ump_index.csv')
    ABuFileUtil.ensure_dir(index_csv_path)

    index_csv_df = ABuFileUtil.load_df_csv(index_csv_path)
    if index_csv_df is not None:
        if custom_name in index_csv_df.index:
            return
        index_csv_df = index_csv_df.append(index_df)
    else:
        index_csv_df = index_df
    # 最终dump为csv文件
    ABuFileUtil.dump_df_csv(index_csv_path, index_csv_df)


def _load_custom_index(*paths):
    """执行读取csv,通过abu数据目录 + *paths参数构成读取路径"""
    index_csv_path = os.path.join(ABuEnv.g_project_data_dir, *paths)
    index_csv_df = ABuFileUtil.load_df_csv(index_csv_path)
    return index_csv_df


def load_custom_abu_index():
    """读取回测结果索引描述csv,通过abu数据目录 + cache + custom_abu_index.csv构成读取路径"""
    return _load_custom_index('cache', 'custom_abu_index.csv')


def load_custom_ump_index():
    """读取裁判ump训练索引描述csv,通过abu数据目录 + ump + custom_ump_index.csv构成读取路径"""
    return _load_custom_index('ump', 'custom_ump_index.csv')


def _del_custom_index(custom_name, *paths):
    """执行删除索引描述csv中某一特定行,custom_name为行名称,即执行drop"""
    index_csv_path = os.path.join(ABuEnv.g_project_data_dir, *paths)
    index_csv_df = ABuFileUtil.load_df_csv(index_csv_path)

    if custom_name in index_csv_df.index:
        index_csv_df.drop(custom_name, inplace=True)
        ABuFileUtil.dump_df_csv(index_csv_path, index_csv_df)


def del_custom_abu_index(custom_name):
    """删除回测结果索引描述csv中某一特定行,custom_name为行名称,即执行drop"""
    return _del_custom_index(custom_name, 'cache', 'custom_abu_index.csv')


def del_custom_ump_index(custom_name):
    """删除裁判ump训练索引描述csv中某一特定行,custom_name为行名称,即执行drop"""
    return _del_custom_index(custom_name, 'ump', 'custom_ump_index.csv')


def _cache_abu_result_path(n_folds, store_type, custom_name):
    """由外部参数返回所有单子存贮路径"""
    fn_root = ABuEnv.g_project_cache_dir
    fn_head = '' if n_folds is None else 'n{}_'.format(n_folds)

    # 根据EStoreAbu来决定fn_head
    if store_type == EStoreAbu.E_STORE_TEST:
        fn_head += 'test'
    elif store_type == EStoreAbu.E_STORE_TEST_UMP:
        fn_head += 'test_ump'
    elif store_type == EStoreAbu.E_STORE_TEST_UMP_WITH_EDGE:
        fn_head += 'test_ump_with_edge'
    elif store_type == EStoreAbu.E_STORE_TRAIN:
        fn_head += 'train'
    elif store_type == EStoreAbu.E_STORE_CUSTOM_NAME:
        fn_head += custom_name
    elif store_type != EStoreAbu.E_STORE_NORMAL:
        raise ValueError('store_type error!!!')

    # eg: n2_test_orders_pd
    orders_key = fn_head + '_orders_pd'
    orders_path = os.path.join(fn_root, orders_key)
    # 只需要ensure_dir第一个就可以了
    ABuFileUtil.ensure_dir(orders_path)

    # eg: n2_test_action_pd
    action_key = fn_head + '_action_pd'
    action_path = os.path.join(fn_root, action_key)

    # eg: n2_test_capital
    capital_path = os.path.join(fn_root, fn_head + '_capital')

    # eg: n2_test_benchmark
    benchmark_path = os.path.join(fn_root, fn_head + '_benchmark')

    return orders_path, orders_key, action_path, action_key, capital_path, benchmark_path


def store_abu_result_tuple(abu_result_tuple, n_folds=None, store_type=EStoreAbu.E_STORE_NORMAL,
                           custom_name=None):
    """
    保存abu.run_loop_back的回测结果AbuResultTuple对象,根据n_folds,store_type参数
    来定义存储的文件名称

    :param abu_result_tuple: AbuResultTuple对象类型
    :param n_folds: 回测执行了几年,只影响存贮文件名
    :param store_type: 回测保存类型EStoreAbu类型,只影响存贮文件名
    :param custom_name: 如果store_type=EStoreAbu.E_STORE_CUSTOM_NAME时需要的自定义文件名称
    """
    orders_path, orders_key, action_path, action_key, capital_path, benchmark_path = _cache_abu_result_path(
        n_folds, store_type, custom_name)
    # abu_result_tuple.orders_pd使用dump_hdf5存储
    ABuFileUtil.dump_hdf5(orders_path, abu_result_tuple.orders_pd, orders_key)
    # abu_result_tuple.action_pd使用dump_hdf5存储
    ABuFileUtil.dump_hdf5(action_path, abu_result_tuple.action_pd, action_key)
    # abu_result_tuple.capital使用dump_pickle存储AbuCapital对象
    ABuFileUtil.dump_pickle(abu_result_tuple.capital, capital_path)
    # abu_result_tuple.benchmark使用dump_pickle存储AbuBenchmark对象
    ABuFileUtil.dump_pickle(abu_result_tuple.benchmark, benchmark_path)


def load_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_NORMAL, custom_name=None):
    """
    读取使用store_abu_result_tuple保存的回测结果,根据n_folds,store_type参数
    来定义读取的文件名称,依次读取orders_pd,action_pd,capital,benchmark后构造
    AbuResultTuple对象返回

    :param n_folds: 回测执行了几年,只影响读取的文件名
    :param store_type: 回测保存类型EStoreAbu类型,只影响读取的文件名
    :param custom_name: 如果store_type=EStoreAbu.E_STORE_CUSTOM_NAME时需要的自定义文件名称
    :return: AbuResultTuple对象
    """

    orders_path, orders_key, action_path, action_key, capital_path, benchmark_path = _cache_abu_result_path(
        n_folds, store_type, custom_name)
    # load_hdf5读取pd.DataFrame对象orders_pd
    orders_pd = ABuFileUtil.load_hdf5(orders_path, orders_key)
    # load_hdf5读取pd.DataFrame对象action_pd
    action_pd = ABuFileUtil.load_hdf5(action_path, action_key)
    # load_pickle读取AbuCapital对象capital,AbuCapital混入了类PickleStateMixin
    capital = ABuFileUtil.load_pickle(capital_path)
    # load_pickle读取AbuBenchmark对象benchmark,AbuBenchmark混入了类PickleStateMixin
    benchmark = ABuFileUtil.load_pickle(benchmark_path)
    # 构建返回AbuResultTuple对象
    return AbuResultTuple(orders_pd, action_pd, capital, benchmark)


def delete_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_NORMAL, custom_name=None, del_index=False):
    """
    删除本地store_abu_result_tuple保存的回测结果,根据n_folds,store_type参数
    来定义读取的文件名称,依次读取orders_pd,action_pd,capital,benchmark后构造
    AbuResultTuple对象返回

    :param n_folds: 回测执行了几年,只影响读取的文件名
    :param store_type: 回测保存类型EStoreAbu类型,只影响读取的文件名
    :param custom_name: 如果store_type=EStoreAbu.E_STORE_CUSTOM_NAME时需要的自定义文件名称
    :param del_index: 是否删除index csv
    """

    orders_path, _, action_path, _, capital_path, benchmark_path = _cache_abu_result_path(
        n_folds, store_type, custom_name)

    # 获取各个单子路径后依次删除
    ABuFileUtil.del_file(orders_path)
    ABuFileUtil.del_file(action_path)
    ABuFileUtil.del_file(capital_path)
    ABuFileUtil.del_file(benchmark_path)

    if del_index:
        # 删除回测所对应的描述文件索引行
        del_custom_abu_index(custom_name)


def store_abu_result_out_put(abu_result_tuple, show_log=True):
    """
    保存abu.run_loop_back的回测结果AbuResultTuple对象,根据当前时间戳保存来定义存储的文件夹名称,
    不同于保存在cache中,将保存在out_put文件夹中,且所有单子都使用csv进行保存,不使用hdf5进行保存
    保证外部的可读性
    1. 交易单: orders.csv
    2. 行动单: actions.csv
    3. 资金单: capital.csv
    4. 手续费: commission.csv
    """
    base_dir = 'out_put'
    # 时间字符串
    date_dir = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S_%f")
    fn = os.path.join(ABuEnv.g_project_data_dir, base_dir, date_dir, 'orders.csv')
    ABuFileUtil.ensure_dir(fn)

    fn = os.path.join(ABuEnv.g_project_data_dir, base_dir, date_dir, 'actions.csv')
    ABuFileUtil.dump_df_csv(fn, abu_result_tuple.action_pd)
    if show_log:
        print('save {} suc!'.format(fn))

    fn = os.path.join(ABuEnv.g_project_data_dir, base_dir, date_dir, 'capital.csv')
    ABuFileUtil.dump_df_csv(fn, abu_result_tuple.capital.capital_pd)
    if show_log:
        print('save {} suc!'.format(fn))

    fn = os.path.join(ABuEnv.g_project_data_dir, base_dir, date_dir, 'commission.csv')
    ABuFileUtil.dump_df_csv(fn, abu_result_tuple.capital.commission.commission_df)
    if show_log:
        print('save {} suc!'.format(fn))


================================================
FILE: abupy/CoreBu/__init__.py
================================================
# IN ABu LIST __all__
from __future__ import absolute_import

from .ABuFixes import *
from .ABuPdHelper import *
from . import ABuEnv as env
from . import ABu as abu
from .ABuEnv import EMarketSourceType, EMarketTargetType, EMarketSubType, \
    EMarketDataSplitMode, EMarketDataFetchMode, EDataCacheType
from .ABuBase import AbuParamBase, FreezeAttrMixin, PickleStateMixin
from .ABuParallel import Parallel, delayed
from .ABuStore import AbuResultTuple, EStoreAbu

__all__ = [
    'abu',
    'AbuResultTuple',
    'EStoreAbu',
    'env',
    'AbuParamBase',
    'FreezeAttrMixin',
    'PickleStateMixin',
    'Parallel',
    'delayed',
    'EMarketSourceType',
    'EMarketTargetType',
    'EMarketSubType',
    'EMarketDataSplitMode',
    'EMarketDataFetchMode',
    'EDataCacheType',

    'train_test_split',
    'KFold',
    'learning_curve',
    'cross_val_score',
    'GridSearchCV',

    'signature',
    'Parameter',

    'ThreadPoolExecutor',
    'six',
    'zip',
    'xrange',
    'range',
    'reduce',
    'map',
    'filter',
    'pickle',
    'Pickler',
    'Unpickler',
    'partial',

    'pd_rolling_mean',
    'pd_rolling_std',
    'pd_rolling_var',
    'pd_rolling_median',
    'pd_rolling_max',
    'pd_rolling_min',
    'pd_rolling_corr',
    'pd_rolling_cov',
    'pd_rolling_sum',
    'pd_rolling_kurt',
    'pd_rolling_skew',

    'pd_ewm_mean',
    'pd_ewm_corr',
    'pd_ewm_std',
    'pd_ewm_cov',
    'pd_ewm_var',

    'pd_expanding_mean',
    'pd_expanding_std',
    'pd_expanding_var',
    'pd_expanding_median',
    'pd_expanding_max',
    'pd_expanding_min',
    'pd_expanding_corr',
    'pd_expanding_cov',
    'pd_expanding_sum',
    'pd_expanding_kurt',
    'pd_expanding_skew',

    'pd_resample'
]


================================================
FILE: abupy/CrawlBu/ABuXqApi.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import time

from ..CoreBu import ABuFixes

__author__ = '小青蛙'
__weixin__ = 'abu_quant'

BASE_XQ_URL = 'https://xueqiu.com'

BASE_XQ_HQ_URL = BASE_XQ_URL + '/hq'

BASE_XQ_STOCK_INFO = BASE_XQ_URL + '/S/'

BASE_XQ_HQ_EXCHANGE_URL = BASE_XQ_HQ_URL + '#exchange={}'

CN_INDUSTRY_LIST = 'https://xueqiu.com/industry/quote_order.json?' \
                   'size=100&order=asc&orderBy=code&exchange=CN&'
HK_INDUSTRY_LIST = 'https://xueqiu.com/stock/cata/stocklist.json?' \
                   'size=100&order=asc&orderby=code&exchange=HK&'
US_INDUSTRY_LIST = 'https://xueqiu.com/stock/cata/stocklist.json?' \
                   'size=100&order=asc&orderby=code&exchange=US&'

CN_STOCK_LIST = 'https://xueqiu.com/stock/cata/stocklist.json?' \
                'size=100&order=asc&orderby=code&type=11%2C12&'
HK_STOCK_LIST = 'https://xueqiu.com/stock/cata/stocklist.json?' \
                'size=100&order=asc&orderby=code&type=30%2C31&'
US_STOCK_LIST = 'https://xueqiu.com/stock/cata/stocklist.json?' \
                'size=100&order=asc&orderby=code&type=0%2C1%2C2%2C3&isdelay=1&'

LOGIN_URL = 'https://xueqiu.com/user/login'

# 雪球url中type值
TYPE_INFO = {
    0: 'us_stock',  # 美股(不包含中国区)
    1: 'us_a_stock_NASDAQ',  # 在拉斯达克上市的中国股票
    2: 'us_a_stock_NYSE',  # 在纽交所上市的中国股票
    3: 'us_index',  # 美国指数
    11: 'a_stock',  # A股
    12: 'a_index',  # A股指数
    30: 'hk_stock',  # 港股
    31: 'hk_index',  # 港股指数
}


class IndustryUrl(object):
    def __init__(self, market, **kwargs):
        self.market = market
        self.kwargs = kwargs
        self._base_url = None
        self.init_base_url()

    def init_base_url(self):
        if 'CN' == self.market:
            self._base_url = CN_INDUSTRY_LIST
        elif 'HK' == self.market:
            self._base_url = HK_INDUSTRY_LIST
        elif 'US' == self.market:
            self._base_url = US_INDUSTRY_LIST
        else:
            raise RuntimeError('only support {}'.format(['US', 'CN', 'HK']))

    @property
    def url(self):
        param = dict(self.kwargs)
        param['_'] = time.time()

        return self._base_url + ABuFixes.urlencode(param)


class StockListUrl(IndustryUrl):
    def init_base_url(self):
        if 'CN' == self.market:
            self._base_url = CN_STOCK_LIST
        elif 'HK' == self.market:
            self._base_url = HK_STOCK_LIST
        elif 'US' == self.market:
            self._base_url = US_STOCK_LIST
        else:
            raise RuntimeError('only support {}'.format(['US', 'CN', 'HK']))


def test():
    print(IndustryUrl('CN', plate='保险业', page=1, level2code='J68').url)
    print(IndustryUrl('US', plate='金融', page=1).url)
    print(IndustryUrl('HK', plate='保险', page=1).url)


================================================
FILE: abupy/CrawlBu/ABuXqConsts.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

__author__ = '小青蛙'
__weixin__ = 'abu_quant'

"""
s:static
d:dynamic
co: company
pb: price book ratio
pe: price earning ratio
ps: price sales ratio
asset : net_asset_value_per_share
oo:organization_ownership
cc:circulation_capital
mv:market_value
sc:short_covering
"""
columns_map = {
    "symbol": 'symbol',
    "market": 'market',
    "exchange": 'exchange',

    "industry": 'industry',
    "name": 'co_name',
    "公司网站:": 'co_site',
    "公司电话:": 'co_tel',
    "公司地址:": 'co_addr',
    "业务:": 'co_business',
    "简介:": 'co_intro',

    "市盈率(静)/(动):": 'pe_s_d',
    "市净率(动):": 'pb_d',
    "市净率MRQ:": 'pb_MRQ',
    "市销率(动):": 'ps_d',
    "市销率:": 'ps',
    "市盈率(静):": 'pe_s',
    "换手率:": 'turnover',

    "每股净资产:": 'asset',
    "流通股本:": 'cc',
    "振幅:": 'amplitude',
    "空头补回天数:": 'sc',
    "招股说明书:": 'prospectus',
    "总股本:": 'equity',
    "总市值:": 'mv',
    "机构持股:": 'oo',
    "港股股本:": 'hk_equity'
}


================================================
FILE: abupy/CrawlBu/ABuXqCrawl.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import pandas as pd

import math
import logging

from os import path

from abupy.CrawlBu import ABuXqFile
from ..CoreBu.ABuEnvProcess import add_process_env_sig
from ..CrawlBu.ABuXqFile import map_stock_list
from .ABuXqCrawlImp import StockInfoListBrower, StockListCrawlBrower
from .ABuXqCrawlImp import NavHQCrawlBrower

from ..CoreBu.ABuEnv import g_project_rom_data_dir
from ..CoreBu.ABuParallel import Parallel, delayed
from ..UtilBu import ABuDTUtil

# noinspection PyUnresolvedReferences
from ..CoreBu.ABuFixes import map, reduce, filter

__author__ = '小青蛙'
__weixin__ = 'abu_quant'

_NAV_PATH = path.join(g_project_rom_data_dir, 'hq_nav.txt')


@add_process_env_sig
def __crawl_stock_parallel(market, url):
    with StockListCrawlBrower(url) as crawler:
        name, symbol = crawler.crawl()
        df = pd.DataFrame({'name': name, 'symbol': symbol})
        if market == 'CN':
            # 确保都是A股正确的symbol
            df = df.loc[
                list(
                    map(lambda s: (s[:2] in ['SZ', 'SH', 'sz', 'sh']) and str(s[2:]).isdigit(), df['symbol'].tolist()))]
            df['market'] = df['symbol'].map(lambda s: s[:2])
        else:
            df['market'] = market

        df.to_csv(map_stock_list(market), index=False)


@add_process_env_sig
def __crawl_stock_info_parallel(market, symbols, process):
    with StockInfoListBrower(market, symbols) as stockInfo:
        rest = stockInfo.crawl(process=process)
        print(rest)


def hq_nav():
    """
    :return: dict
    一级菜单:类别,如。美股,港股,沪深,基金,债券等
    二级菜单:如,行业分类,美股一览等
    三级菜单:可能会有(,比如行业就需细分)
    """
    with NavHQCrawlBrower() as nav:
        return nav.crawl()


@ABuDTUtil.warnings_filter
def crawl_stock_code(markets=('CN', 'HK', 'US')):
    """
    从雪球获取市场股市代码
    :param markets: 市场类型
    """
    nav = hq_nav()
    urls = dict()
    for market_nav in nav:
        for first_menu in nav[market_nav]:
            if first_menu in [u'沪深一览'] and 'CN' in markets:
                urls['CN'] = nav[market_nav][first_menu]
            if first_menu in [u'港股一览'] and 'HK' in markets:
                urls['HK'] = nav[market_nav][first_menu]
            if first_menu in [u'美股一览'] and 'US' in markets:
                urls['US'] = nav[market_nav][first_menu]

    Parallel(n_jobs=-1)(delayed(__crawl_stock_parallel)(m, urls[m]) for m in urls)


def crawl_stock_info(markets):
    """
    获取股票信息,例如,股市简介,行业,市值等信息
    :param markets:
    """
    _markets = []
    _parts = []
    for m in markets:
        symbols = ABuXqFile.read_stock_symbol_list(m)
        interval = 1000

        # 将 symbols 划分成一组1000个
        for s in range(int(math.ceil(len(symbols) / interval))):
            st = s * interval
            en = (s + 1) * interval if (s + 1) * interval <= len(symbols) else len(symbols)
            _parts.append(symbols[st:en])
            _markets.append(m)
    # 开启len(_parts)个进程同时
    print('任务数{}'.format(len(_parts)))

    parallel = Parallel(n_jobs=-1)
    parallel(delayed(__crawl_stock_info_parallel)(m, p, i)
             for i, (m, p) in enumerate(zip(_markets, _parts)))


def ensure_symbol(symbol):
    """
    保证本地的股市代码库纯在该symbol才能查看stock info
    A 股 sh、sz开头 + 6位数字
    HK 股 5位数字
    UK 股 英文代码
    :param symbol:
    :return:
    """
    symbol = str(symbol).upper()
    if (len(symbol) == 6 and str(symbol).isdigit()) or (
                        len(symbol) == 8 and symbol[:2] in ['SZ', 'SH'] and str(symbol[2:]).isdigit()):
        market = 'CN'
    elif (len(symbol) == 5 and str(symbol).isdigit()) or (
                        len(symbol) == 7 and symbol[:2] in ['HK'] and str(symbol[2:]).isdigit()):
        market = 'HK'
    else:
        market = 'US'
    stock_list = ABuXqFile.read_stock_symbol_list(market)

    if market in ['CN']:
        # symbol自带 sh或sz
        if len(symbol) == 8:
            return market, symbol
        # 此刻 symbol是6位数字
        sh_code = 'SH{}'.format(symbol)
        sz_code = 'SZ{}'.format(symbol)
        is_sh = sh_code in stock_list
        is_sz = sz_code in stock_list

        if is_sz and is_sh:
            # 即使 上证又是深圳股
            sh_name = ABuXqFile.read_stock_symbol_name(market, sh_code)
            sz_name = ABuXqFile.read_stock_symbol_name(market, sz_code)
            logging.error(
                '找到两个关于{}的股票{}({}),{}({}),请改写{}成{}或{}'.format(
                    symbol, sh_code, sh_name, sz_code, sz_name, symbol, sz_code, sh_code))
            return market, None
        elif is_sh:
            return market, sh_code
        elif is_sz:
            return sz_code
        else:
            pass
    elif market in ['US', 'HK']:
        if symbol in stock_list:
            return market, symbol

    logging.error('没有找到{}相关的股票'.format(symbol))
    return market, None


def update_all(markets=('US', 'CN', 'HK')):
    crawl_stock_code(markets)
    crawl_stock_info(markets)
    ABuXqFile.merge_stock_info_to_stock_list(markets)
    ABuXqFile.fix_xq_columns_name()


def query_symbol_info(symbol):
    m, symbol = ensure_symbol(symbol)
    return None if symbol is None else ABuXqFile.query_a_stock(m, symbol)


================================================
FILE: abupy/CrawlBu/ABuXqCrawlImp.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from abc import ABCMeta, abstractmethod

import logging
import time

from . import ABuXqFile

from ..CoreBu import env
# noinspection PyUnresolvedReferences
from ..CoreBu.ABuFixes import map, reduce, filter
from .ABuXqApi import BASE_XQ_HQ_URL
from .ABuXqApi import BASE_XQ_STOCK_INFO
from ..ExtBu import six

__author__ = '小青蛙'
__weixin__ = 'abu_quant'


def _bs4_html(content):
    """
    使用BeautifulSoup解析html
    :param content: html
    :return: BeautifulSoup
    """
    from bs4 import BeautifulSoup
    return BeautifulSoup(content, 'lxml')


def _xpath(content):
    """
    使用xpath解析html 
    :param content:
    :return:
    """
    from lxml import etree
    selector = etree.HTML(content)
    return selector


class BaseXQCrawlBrower(six.with_metaclass(ABCMeta, object)):
    """
    使用chrome浏览器的自动化测试驱动接口,获取网页数据
    """

    def __init__(self, base_url):
        self._base_url = base_url
        if env.g_crawl_chrome_driver is not None:
            self.driver_path = env.g_crawl_chrome_driver
        else:
            raise RuntimeError('driver_path error!!!, abupy.CoreBu.ABuEnv.g_crawl_chrome_driver must be right')

        # noinspection PyUnresolvedReferences
        from selenium.webdriver.support import ui
        # noinspection PyUnresolvedReferences
        from selenium import webdriver
        self.driver = webdriver.Chrome(self.driver_path)
        self.wait = ui.WebDriverWait(self.driver, 10)

    @abstractmethod
    def _crawl_imp(self, *args, **kwargs):
        pass

    def get(self, url):
        self.driver.get(url)

    @property
    def content(self):
        return self.driver.page_source

    def crawl(self, *args, **kwargs):
        """
        执行完任务是自动退出,避免占用资源,在多进程爬时会启动多个chrome实例
        :param args:
        :param kwargs:
        :return: crawl_imp
        """
        ret = None
        try:
            self.driver.get(self._base_url)
            self.driver.maximize_window()
            ret = self._crawl_imp(*args, **kwargs)
        except Exception as e:
            logging.exception(e)
        return ret

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.driver.quit()

    def _scroll_to_bottom(self, element):
        loc = element.location
        self.driver.execute_script('window.scrollBy({},{})'.format(loc['x'], loc['y']))


class BaseHQCrawlBrower(BaseXQCrawlBrower):
    def _crawl_imp(self, *args, **kwargs):
        pass

    def __init__(self, url):
        super(BaseHQCrawlBrower, self).__init__(BASE_XQ_HQ_URL)
        self._base_url = self._base_url + url


class NavHQCrawlBrower(BaseHQCrawlBrower):
    def _crawl_imp(self, *args, **kwargs):
        return _parse_nav(self.driver.page_source)

    def __init__(self):
        super(NavHQCrawlBrower, self).__init__('')


class StockListCrawlBrower(BaseHQCrawlBrower):
    def _ensure_max_page_size(self):
        """
        使每页展示的stock数最多,总页数变少,使网络请求数变少
        """
        max_page_tag = self.driver.find_element_by_xpath('//*[@id="stockList-header"]/div[2]/a[3]')
        max_page_tag.click()
        time_out = 30
        while time_out:
            time.sleep(1)
            time_out -= 1
            _, total = self._curr_total_page()
            #  直到 最大size生效
            if total == 1 or self._curr_page_counts() == int(max_page_tag.text):
                break

    def _curr_page_counts(self):
        selector = _xpath(self.content)
        items = selector.xpath('//*[@id="stockList"]/div[1]/table/tbody/tr')
        return len(items)

    def _curr_total_page(self):

        selector = _xpath(self.content)
        pages = selector.xpath('//*[@id="pageList"]/div/ul/li/a/text()')
        cur_page = selector.xpath('//*[@id="pageList"]/div/ul/li[@class="active"]/a/text()')

        # 存在pages的最后一个值,否则cur和total都是1
        if len(pages):
            return int(cur_page[0]), int(pages[-1])
        else:
            return 1, 1

    def _curr_page_items(self):
        selector = _xpath(self.content)
        # code = selector.xpath('//*[@id="stockList"]/div[1]/table/tbody/tr/td[1]/a/text()')
        # name = selector.xpath('//*[@id="stockList"]/div[1]/table/tbody/tr/td[2]/a/text()')
        # a标签下的text() 可能不存在,而xpath会把不存在的过滤掉,导致code,和name的长度不一致,产生错位,故先找到a,a。text为kong也占位,就能一一对应
        code = selector.xpath('//*[@id="stockList"]/div[1]/table/tbody/tr/td[1]/a')
        name = selector.xpath('//*[@id="stockList"]/div[1]/table/tbody/tr/td[2]/a')
        code = list(map(lambda a: a.text, code))
        name = list(map(lambda a: a.text, name))
        return name, code

    def _goto_next_page(self):
        next_page = self.driver.find_element_by_xpath('//*[@id="pageList"]/div/ul/li[@class="next"]/a')
        if next_page is not None:
            # 滚动到next_page 标签显示出来,否则click可能会报错
            self.wait.until(lambda dr: next_page.is_enabled())
            self.driver.execute_script('arguments[0].click()', next_page)
            time.sleep(1)

    def _crawl_imp(self, *args, **kwargs):
        self._ensure_max_page_size()

        cur_page, total_page = self._curr_total_page()
        names = []
        symbols = []
        # page index start 1
        for page in range(1, total_page + 1):
            self.wait.until(lambda dr: dr.find_element_by_xpath('//*[@id="stockList"]/div[1]/table').is_displayed())
            cur_page, _ = self._curr_total_page()
            temp_names, temp_symbols = self._curr_page_items()
            names += temp_names
            symbols += temp_symbols
            if page < total_page:
                self._goto_next_page()
            else:
                break

        return names, symbols

    def __init__(self, url):
        super(StockListCrawlBrower, self).__init__(url)


def _parse_nav(content):
    soup = _bs4_html(content)
    nav_tags = soup.select('.industry-nav > div')

    def parse_nav_tag(tag):
        nav = {}
        first_nav = tag.select('.first-nav > span')
        if len(first_nav) > 0:
            second_nav = tag.select('.second-nav > li')
            nav[first_nav[0].string] = {}
            for nav_2 in second_nav:
                a_tag = nav_2.select('a')
                if len(a_tag) <= 0:
                    continue
                third_nav = nav_2.select('.third-nav')
                if len(third_nav) > 0:
                    second_nav_name = str(nav_2).replace('<li><i class="list-style"></i>', '')
                    second_nav_name = second_nav_name[: second_nav_name.index('<i')]
                    nav[first_nav[0].string][second_nav_name] = list(map(lambda a: {a.get('title'): a.get('href')},
                                                                         a_tag))
                else:
                    nav[first_nav[0].string][a_tag[0].get('title')] = a_tag[0].get('href')
        return nav

    def merge(dict1, dict2):
        return dict(dict1, **dict2)

    return reduce(lambda d1, d2: merge(d1, d2), map(lambda tag: parse_nav_tag(tag), nav_tags))


class StockInfoListBrower(BaseXQCrawlBrower):
    def __init__(self, market, symbols):
        super(StockInfoListBrower, self).__init__(BASE_XQ_STOCK_INFO)

        self._market = market
        self._symbols = symbols

    def __exit__(self, exc_type, exc_val, exc_tb):
        self._market = None
        self._symbols = None
        super(StockInfoListBrower, self).__exit__(exc_type, exc_val, exc_tb)

    def _parse_stock_info(self):
        selector = _xpath(self.content)
        # 特斯拉(NASDAQ:TSLA)
        stock_name = selector.xpath('//*[@id="center"]/div[2]/div[2]/div[1]/div[1]/span[1]/strong/text()')
        company_info_p = selector.xpath('//*[@id="center"]/div[3]/div/div[2]/div/p')
        company_industry = selector.xpath('//*[@id="relatedIndustry"]/h2/a/text()')

        quate_items = selector.xpath('//*[@id="center"]/div[2]/div[2]/div[2]/table/tbody/tr/td')

        info = {}
        if len(stock_name):
            stock_name_info = stock_name[0]
            st = stock_name_info.rfind('(')
            en = stock_name_info.rfind(')')
            market_symbol = stock_name_info[st + 1:en]
            sp_result = market_symbol.split(':')
            if len(sp_result) == 2:
                company_name = stock_name_info[:st]
                exchange_name = sp_result[0]
                company_symbol = sp_result[1]
                info['name'] = company_name
                info['exchange'] = exchange_name
                info['symbol'] = company_symbol

        if len(company_info_p):
            last_key = None
            for p in company_info_p:
                for child in p.getchildren():
                    if child.tag == 'strong':
                        info[child.text] = child.tail
                        last_key = child.text
                    if child.tag == 'a':
                        info[last_key] = child.get('href')
        if len(quate_items):
            for item in quate_items:
                if len(item.getchildren()) == 1:
                    info[item.text] = item.getchildren()[0].text

        if len(company_industry):
            info['industry'] = company_industry[0]

        return info

    def _crawl_imp(self, *args, **kwargs):
        for index, symbol in enumerate(self._symbols):
            try:
                if not ABuXqFile.exist_stock_info(self._market, symbol) or ('replace' in kwargs and kwargs['replace']):
                    self.get(self._base_url + symbol)
                    stock_info = self._parse_stock_info()
                    ABuXqFile.save_cache_stock_info(stock_info, self._market, symbol)
                if (index + 1) % 200 == 0:
                    print(
                        '{}: {} {}  {}/{}'.format(kwargs['process'], self._market, symbol, index + 1,
                                                  len(self._symbols)))
            except Exception as e:
                # 记录失败的symbol
                ABuXqFile.error_stock_info(self._market, symbol, e)
                logging.exception(e)
        return 'Done'


================================================
FILE: abupy/CrawlBu/ABuXqFile.py
================================================
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from os import path
import os
from ..CoreBu.ABuEnv import g_project_data_dir
from ..CoreBu.ABuEnv import g_project_cache_dir
from ..CoreBu.ABuEnv import g_project_rom_data_dir
from ..UtilBu import ABuFileUtil
from ..UtilBu.ABuProgress import AbuProgress

from .ABuXqConsts import columns_map

import pandas as pd

__author__ = '小青蛙'
__weixin__ = 'abu_quant'

# 保存股票信息
STOCK_INFO_DIR = path.join(g_project_data_dir, 'stock_info')
# 保存爬取得股票信息
STOCK_INFO_CACHE_DIR = path.join(g_project_cache_dir, 'stock_info')
STOCK_INFO_ERROR_DIR = path.join(g_project_cache_dir, 'stock_info/error')

ABuFileUtil.ensure_dir(STOCK_INFO_DIR)
ABuFileUtil.ensure_dir(STOCK_INFO_CACHE_DIR)
ABuFileUtil.ensure_dir(STOCK_INFO_ERROR_DIR)


def map_stock_list_rom(market):
    return path.join(g_project_rom_data_dir, 'stock_code_{}.csv'.format(market))


def map_stock_list(market):
    return path.join(STOCK_INFO_DIR, 'stock_code_{}.csv'.format(market))


def map_cache_stock_info(market, symbol):
    """
    临时存取 stock info
    :param market:
    :param symbol:
    :return:
    """
    p = path.join(STOCK_INFO_CACHE_DIR, '{}_{}.txt'.format(market, symbol))
    return p


def save_cache_stock_info(stock_info, market, symbol):
    if stock_info is not None:
        df = pd.DataFrame.from_dict(stock_info, orient='index')
        df.to_csv(map_cache_stock_info(market, symbol))


def exist_stock_info(market, symbol):
    return ABuFileUtil.file_exist(map_cache_stock_info(market, symbol))


def read_stock_symbol_list(market):
    return pd.read_csv(map_stock_list(market))['symbol'].tolist()


def read_stock_symbol_name(market, symbol):
    df = pd.read_csv(map_stock_list(market))
    item = df.loc[df.symbol == symbol]
    return None if item is None else item.name.tolist()[0]


def error_stock_info(market, symbol, error_info):
    """
    抓取stock info 失败 保存到磁盘,以便,下次查看,由于多进程的原因,每个错占用一个空文件,避免多进程共享文件可能出错的问题
    :param error_info:
    :param market:
    :param symbol:
    :return:
    """
    p = path.join(STOCK_INFO_ERROR_DIR, '{}_{}'.format(market, symbol))
    ABuFileUtil.save_file(error_info, p)
    return p


def read_all_error_stock_info_symbol():
    """
    :return: 返回抓取stock info失败的symbol列表
    """
    error_symbols = os.listdir(STOCK_INFO_ERROR_DIR)
    return map(lambda error: error.split('_'), error_symbols)


def query_a_stock(market, symbol):
    stock_df = pd.read_csv(map_stock_list(market))
    return stock_df.loc[stock_df.symbol == symbol]


def _create_a_column(info, columns, size):
    """
    创建size大小的None数组
    :param info:
    :param columns:
    :param size:
    """
    for c in columns:
        if c not in info.keys():
            info[c] = [None] * size


def merge_stock_info_to_stock_list(market=('US', 'HK', 'CN')):
    for m in market:
        stock_df = pd.read_csv(map_stock_list(m), dtype=str)
        extra_info = {}
        # 08012
        progess = AbuProgress(stock_df.shape[0], 0, 'merging {}'.format(m))
        for i, symbol in enumerate(stock_df['symbol']):
            p
Download .txt
gitextract_odeghj84/

├── .gitattributes
├── .gitignore
├── LICENSE
├── abupy/
│   ├── AlphaBu/
│   │   ├── ABuAlpha.py
│   │   ├── ABuPickBase.py
│   │   ├── ABuPickStockExecute.py
│   │   ├── ABuPickStockMaster.py
│   │   ├── ABuPickStockWorker.py
│   │   ├── ABuPickTimeExecute.py
│   │   ├── ABuPickTimeMaster.py
│   │   ├── ABuPickTimeWorker.py
│   │   └── __init__.py
│   ├── BetaBu/
│   │   ├── ABuAtrPosition.py
│   │   ├── ABuBeta.py
│   │   ├── ABuKellyPosition.py
│   │   ├── ABuPositionBase.py
│   │   ├── ABuPtPosition.py
│   │   └── __init__.py
│   ├── CheckBu/
│   │   ├── ABuChecker.py
│   │   ├── ABuChecks.py
│   │   ├── ABuFuncUtil.py
│   │   ├── ABuProcessor.py
│   │   └── __init__.py
│   ├── CoreBu/
│   │   ├── ABu.py
│   │   ├── ABuBase.py
│   │   ├── ABuDeprecated.py
│   │   ├── ABuEnv.py
│   │   ├── ABuEnvProcess.py
│   │   ├── ABuFixes.py
│   │   ├── ABuParallel.py
│   │   ├── ABuPdHelper.py
│   │   ├── ABuStore.py
│   │   └── __init__.py
│   ├── CrawlBu/
│   │   ├── ABuXqApi.py
│   │   ├── ABuXqConsts.py
│   │   ├── ABuXqCrawl.py
│   │   ├── ABuXqCrawlImp.py
│   │   ├── ABuXqFile.py
│   │   └── __init__.py
│   ├── DLBu/
│   │   ├── ABuDL.py
│   │   ├── ABuDLImgStd.py
│   │   ├── ABuDLTVSplit.py
│   │   ├── __init__.py
│   │   ├── pb/
│   │   │   ├── deploy.prototxt
│   │   │   ├── solver.prototxt
│   │   │   └── train_val.prototxt
│   │   └── sh/
│   │       ├── Lmdb.sh
│   │       ├── Mean.sh
│   │       └── Train.sh
│   ├── ExtBu/
│   │   ├── __init__.py
│   │   ├── empyrical/
│   │   │   ├── __init__.py
│   │   │   ├── _version.py
│   │   │   ├── stats.py
│   │   │   └── utils.py
│   │   ├── funcsigs.py
│   │   ├── futures/
│   │   │   ├── __init__.py
│   │   │   ├── _base.py
│   │   │   ├── process.py
│   │   │   └── thread.py
│   │   ├── joblib/
│   │   │   ├── __init__.py
│   │   │   ├── _compat.py
│   │   │   ├── _memory_helpers.py
│   │   │   ├── _multiprocessing_helpers.py
│   │   │   ├── _parallel_backends.py
│   │   │   ├── disk.py
│   │   │   ├── format_stack.py
│   │   │   ├── func_inspect.py
│   │   │   ├── hashing.py
│   │   │   ├── logger.py
│   │   │   ├── memory.py
│   │   │   ├── my_exceptions.py
│   │   │   ├── numpy_pickle.py
│   │   │   ├── numpy_pickle_compat.py
│   │   │   ├── numpy_pickle_utils.py
│   │   │   ├── parallel.py
│   │   │   ├── pool.py
│   │   │   └── testing.py
│   │   ├── odict.py
│   │   └── six.py
│   ├── FactorBuyBu/
│   │   ├── ABuBuyFactorWrap.py
│   │   ├── ABuFactorBuyBase.py
│   │   ├── ABuFactorBuyBreak.py
│   │   ├── ABuFactorBuyDM.py
│   │   ├── ABuFactorBuyDemo.py
│   │   ├── ABuFactorBuyTrend.py
│   │   ├── ABuFactorBuyWD.py
│   │   └── __init__.py
│   ├── FactorSellBu/
│   │   ├── ABuFS.py
│   │   ├── ABuFactorAtrNStop.py
│   │   ├── ABuFactorCloseAtrNStop.py
│   │   ├── ABuFactorPreAtrNStop.py
│   │   ├── ABuFactorSellBase.py
│   │   ├── ABuFactorSellBreak.py
│   │   ├── ABuFactorSellDM.py
│   │   ├── ABuFactorSellNDay.py
│   │   └── __init__.py
│   ├── IndicatorBu/
│   │   ├── ABuND.py
│   │   ├── ABuNDAtr.py
│   │   ├── ABuNDBase.py
│   │   ├── ABuNDBoll.py
│   │   ├── ABuNDMa.py
│   │   ├── ABuNDMacd.py
│   │   ├── ABuNDRsi.py
│   │   └── __init__.py
│   ├── MLBu/
│   │   ├── ABuML.py
│   │   ├── ABuMLApi.py
│   │   ├── ABuMLBinsCs.py
│   │   ├── ABuMLCreater.py
│   │   ├── ABuMLExecute.py
│   │   ├── ABuMLGrid.py
│   │   ├── ABuMLPd.py
│   │   └── __init__.py
│   ├── MarketBu/
│   │   ├── ABuDataBase.py
│   │   ├── ABuDataCache.py
│   │   ├── ABuDataCheck.py
│   │   ├── ABuDataFeed.py
│   │   ├── ABuDataParser.py
│   │   ├── ABuDataSource.py
│   │   ├── ABuHkUnit.py
│   │   ├── ABuIndustries.py
│   │   ├── ABuMarket.py
│   │   ├── ABuMarketDrawing.py
│   │   ├── ABuNetWork.py
│   │   ├── ABuSymbol.py
│   │   ├── ABuSymbolFutures.py
│   │   ├── ABuSymbolPd.py
│   │   ├── ABuSymbolStock.py
│   │   └── __init__.py
│   ├── MetricsBu/
│   │   ├── ABuCrossVal.py
│   │   ├── ABuGridHelper.py
│   │   ├── ABuGridSearch.py
│   │   ├── ABuMetrics.py
│   │   ├── ABuMetricsBase.py
│   │   ├── ABuMetricsFutures.py
│   │   ├── ABuMetricsScore.py
│   │   ├── ABuMetricsTC.py
│   │   └── __init__.py
│   ├── PickStockBu/
│   │   ├── ABuPickRegressAngMinMax.py
│   │   ├── ABuPickSimilarNTop.py
│   │   ├── ABuPickStock.py
│   │   ├── ABuPickStockBase.py
│   │   ├── ABuPickStockDemo.py
│   │   ├── ABuPickStockPriceMinMax.py
│   │   └── __init__.py
│   ├── RomDataBu/
│   │   ├── futures_cn.csv
│   │   ├── futures_gb.csv
│   │   ├── hk_unit.csv
│   │   ├── hq_nav.txt
│   │   ├── ml_test.csv
│   │   ├── stock_code_CN.csv
│   │   ├── stock_code_HK.csv
│   │   ├── stock_code_US.csv
│   │   ├── stock_code_cn.txt
│   │   ├── stock_code_hk.txt
│   │   └── stock_code_us.txt
│   ├── SimilarBu/
│   │   ├── ABuCorrcoef.py
│   │   ├── ABuSimilar.py
│   │   ├── ABuSimilarCache.py
│   │   ├── ABuSimilarDrawing.py
│   │   └── __init__.py
│   ├── SlippageBu/
│   │   ├── ABuSlippage.py
│   │   ├── ABuSlippageBuyBase.py
│   │   ├── ABuSlippageBuyMean.py
│   │   ├── ABuSlippageSellBase.py
│   │   ├── ABuSlippageSellMean.py
│   │   └── __init__.py
│   ├── TLineBu/
│   │   ├── ABuTL.py
│   │   ├── ABuTLAtr.py
│   │   ├── ABuTLExecute.py
│   │   ├── ABuTLGolden.py
│   │   ├── ABuTLJump.py
│   │   ├── ABuTLSimilar.py
│   │   ├── ABuTLVwap.py
│   │   ├── ABuTLWave.py
│   │   ├── ABuTLine.py
│   │   └── __init__.py
│   ├── TradeBu/
│   │   ├── ABuBenchmark.py
│   │   ├── ABuCapital.py
│   │   ├── ABuCommission.py
│   │   ├── ABuKLManager.py
│   │   ├── ABuMLFeature.py
│   │   ├── ABuOrder.py
│   │   ├── ABuTradeDrawer.py
│   │   ├── ABuTradeExecute.py
│   │   ├── ABuTradeProxy.py
│   │   └── __init__.py
│   ├── UmpBu/
│   │   ├── ABuUmp.py
│   │   ├── ABuUmpBase.py
│   │   ├── ABuUmpEdgeBase.py
│   │   ├── ABuUmpEdgeDeg.py
│   │   ├── ABuUmpEdgeFull.py
│   │   ├── ABuUmpEdgeMul.py
│   │   ├── ABuUmpEdgePrice.py
│   │   ├── ABuUmpEdgeWave.py
│   │   ├── ABuUmpMainBase.py
│   │   ├── ABuUmpMainDeg.py
│   │   ├── ABuUmpMainFull.py
│   │   ├── ABuUmpMainJump.py
│   │   ├── ABuUmpMainMul.py
│   │   ├── ABuUmpMainPrice.py
│   │   ├── ABuUmpMainWave.py
│   │   ├── ABuUmpManager.py
│   │   └── __init__.py
│   ├── UtilBu/
│   │   ├── ABuDTUtil.py
│   │   ├── ABuDateUtil.py
│   │   ├── ABuDelegateUtil.py
│   │   ├── ABuFileUtil.py
│   │   ├── ABuKLUtil.py
│   │   ├── ABuLazyUtil.py
│   │   ├── ABuMacUtil.py
│   │   ├── ABuMd5.py
│   │   ├── ABuOsUtil.py
│   │   ├── ABuPlatform.py
│   │   ├── ABuProgress.py
│   │   ├── ABuRegUtil.py
│   │   ├── ABuScalerUtil.py
│   │   ├── ABuStatsUtil.py
│   │   ├── ABuStrUtil.py
│   │   ├── ABuWinUtil.py
│   │   └── __init__.py
│   ├── WidgetBu/
│   │   ├── ABuWGBFBase.py
│   │   ├── ABuWGBRun.py
│   │   ├── ABuWGBRunBase.py
│   │   ├── ABuWGBSymbol.py
│   │   ├── ABuWGBase.py
│   │   ├── ABuWGBuyFactor.py
│   │   ├── ABuWGCrossVal.py
│   │   ├── ABuWGDATool.py
│   │   ├── ABuWGGridSearch.py
│   │   ├── ABuWGPSBase.py
│   │   ├── ABuWGPickStock.py
│   │   ├── ABuWGPosBase.py
│   │   ├── ABuWGPosition.py
│   │   ├── ABuWGQuantTool.py
│   │   ├── ABuWGSFBase.py
│   │   ├── ABuWGSMTool.py
│   │   ├── ABuWGSellFactor.py
│   │   ├── ABuWGStockInfo.py
│   │   ├── ABuWGTLTool.py
│   │   ├── ABuWGToolBase.py
│   │   ├── ABuWGUmp.py
│   │   ├── ABuWGUpdate.py
│   │   ├── ABuWGVerifyTool.py
│   │   └── __init__.py
│   └── __init__.py
├── abupy_lecture/
│   ├── 0-abupy量化环境部署(ABU量化使用文档).ipynb
│   ├── 1-择时策略的开发(ABU量化使用文档).ipynb
│   ├── 10-比特币莱特币的回测(ABU量化使用文档).ipynb
│   ├── 11-期货市场的回测(ABU量化使用文档).ipynb
│   ├── 12-机器学习与比特币示例(ABU量化使用文档).ipynb
│   ├── 13-量化技术分析应用(ABU量化使用文档).ipynb
│   ├── 14-量化相关性分析应用(ABU量化使用文档).ipynb
│   ├── 15-量化交易和搜索引擎(ABU量化使用文档).ipynb
│   ├── 16-UMP主裁交易决策(ABU量化使用文档).ipynb
│   ├── 17-UMP边裁交易决策(ABU量化使用文档).ipynb
│   ├── 18-自定义裁判决策交易(ABU量化使用文档).ipynb
│   ├── 19-数据源(ABU量化使用文档).ipynb
│   ├── 2-择时策略的优化(ABU量化使用文档).ipynb
│   ├── 20-A股全市场回测(ABU量化使用文档).ipynb
│   ├── 21-A股UMP决策(ABU量化使用文档).ipynb
│   ├── 22-美股全市场回测(ABU量化使用文档).ipynb
│   ├── 23-美股UMP决策(ABU量化使用文档).ipynb
│   ├── 24-比特币vs黄金,莱特币vs白银(ABU量化使用文档).ipynb
│   ├── 25-期货市场内外盘低频统计套利.ipynb
│   ├── 26-星期几是这个股票的好日子.ipynb
│   ├── 27-狗股选股策略与择时策略的配合.ipynb
│   ├── 28-真 • 动态自适应双均线策略.ipynb
│   ├── 29-多因子策略并行执行配合.ipynb
│   ├── 3-滑点策略与交易手续费(ABU量化使用文档).ipynb
│   ├── 30-趋势跟踪与均值回复的长短线搭配.ipynb
│   ├── 31-资金仓位管理与买入策略的搭配.ipynb
│   ├── 32-策略有效性的验证.ipynb
│   ├── 4-多支股票择时回测与仓位管理(ABU量化使用文档).ipynb
│   ├── 5-选股策略的开发(ABU量化使用文档).ipynb
│   ├── 6-回测结果的度量(ABU量化使用文档).ipynb
│   ├── 7-寻找策略最优参数和评分(ABU量化使用文档).ipynb
│   ├── 8-A股市场的回测(ABU量化使用文档).ipynb
│   └── 9-港股市场的回测(ABU量化使用文档).ipynb
├── abupy_ui/
│   ├── readme.md
│   ├── widget_base.py
│   ├── widget_loop_back.py
│   ├── widget_quant_tool.py
│   ├── widget_stock_info.py
│   ├── widget_update_ui.py
│   ├── widget_verify_tool.py
│   ├── 历史回测界面操作.ipynb
│   ├── 参数最优交叉验证.ipynb
│   ├── 数据下载界面操作.ipynb
│   ├── 股票基本信息查询.ipynb
│   └── 量化分析工具操作.ipynb
├── gen/
│   └── stock_day_change.npy
├── ipython/
│   ├── readme.md
│   ├── 第七章-量化系统——入门.ipynb
│   ├── 第三章-量化工具——NumPy.ipynb
│   ├── 第九章-量化系统——度量与优化.ipynb
│   ├── 第二章-量化语言——Python.ipynb
│   ├── 第五章-量化工具——可视化.ipynb
│   ├── 第八章-量化系统——开发.ipynb
│   ├── 第六章-量化工具——数学.ipynb
│   ├── 第十一章-量化系统——机器学习•ABU.ipynb
│   ├── 第十章-量化系统——机器学习•猪老三.ipynb
│   ├── 第四章-量化工具——pandas.ipynb
│   ├── 附录A-量化环境部署.ipynb
│   ├── 附录B-量化相关性分析.ipynb
│   └── 附录C-量化统计分析及指标应用.ipynb
├── python/
│   ├── abu_local_env.py
│   ├── c10.py
│   ├── c11.py
│   ├── c2.py
│   ├── c3.py
│   ├── c4.py
│   ├── c5.py
│   ├── c6.py
│   ├── c7.py
│   ├── c8.py
│   ├── c9.py
│   ├── extA.py
│   ├── extB.py
│   ├── extC.py
│   ├── happy_life.py
│   ├── readme.md
│   ├── stock_days.py
│   └── stock_dream_ml.py
├── readme-en.md
├── readme.md
└── 界面操作视频教程/
    ├── 第26节星期几是这个股票的好日子界面操作视频.md
    └── 第一节界面操作视频教程.md
Download .txt
SYMBOL INDEX (2158 symbols across 185 files)

FILE: abupy/AlphaBu/ABuPickBase.py
  class AbuPickTimeWorkBase (line 19) | class AbuPickTimeWorkBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    method fit (line 23) | def fit(self, *args, **kwargs):
    method init_sell_factors (line 32) | def init_sell_factors(self, *args, **kwargs):
    method init_buy_factors (line 39) | def init_buy_factors(self, *args, **kwargs):
  class AbuPickStockWorkBase (line 46) | class AbuPickStockWorkBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    method fit (line 50) | def fit(self, *args, **kwargs):
    method init_stock_pickers (line 59) | def init_stock_pickers(self, *args, **kwargs):

FILE: abupy/AlphaBu/ABuPickStockExecute.py
  function do_pick_stock_work (line 21) | def do_pick_stock_work(choice_symbols, benchmark, capital, stock_pickers):
  function do_pick_stock_thread_work (line 38) | def do_pick_stock_thread_work(choice_symbols, benchmark, capital, stock_...

FILE: abupy/AlphaBu/ABuPickStockMaster.py
  class AbuPickStockMaster (line 25) | class AbuPickStockMaster(object):
    method do_pick_stock_with_process (line 29) | def do_pick_stock_with_process(cls, capital, benchmark, stock_pickers,...
    method do_pick_stock_with_process_mix_thread (line 103) | def do_pick_stock_with_process_mix_thread(cls, capital, benchmark, sto...

FILE: abupy/AlphaBu/ABuPickStockWorker.py
  class AbuPickStockWorker (line 23) | class AbuPickStockWorker(AbuPickStockWorkBase):
    method __init__ (line 26) | def __init__(self, capital, benchmark, kl_pd_manager, choice_symbols=N...
    method __str__ (line 42) | def __str__(self):
    method init_stock_pickers (line 48) | def init_stock_pickers(self, stock_pickers):
    method fit (line 82) | def fit(self):

FILE: abupy/AlphaBu/ABuPickTimeExecute.py
  class EFitError (line 29) | class EFitError(Enum):
  function _do_pick_time_work (line 46) | def _do_pick_time_work(capital, buy_factors, sell_factors, kl_pd, benchm...
  function do_symbols_with_same_factors (line 81) | def do_symbols_with_same_factors(target_symbols, benchmark, buy_factors,...
  function do_symbols_with_diff_factors (line 166) | def do_symbols_with_diff_factors(target_symbols, benchmark, factor_dict,...

FILE: abupy/AlphaBu/ABuPickTimeMaster.py
  class AbuPickTimeMaster (line 26) | class AbuPickTimeMaster(object):
    method do_symbols_with_same_factors_process (line 30) | def do_symbols_with_same_factors_process(cls, target_symbols, benchmar...

FILE: abupy/AlphaBu/ABuPickTimeWorker.py
  class AbuPickTimeWorker (line 34) | class AbuPickTimeWorker(AbuPickTimeWorkBase):
    method __init__ (line 37) | def __init__(self, cap, kl_pd, benchmark, buy_factors, sell_factors):
    method __str__ (line 66) | def __str__(self):
    method enable_task_pg (line 72) | def enable_task_pg(self):
    method _week_task (line 79) | def _week_task(self, today):
    method _month_task (line 99) | def _month_task(self, today):
    method _day_task (line 120) | def _day_task(self, today):
    method _task_attached_sell (line 143) | def _task_attached_sell(self, today, how):
    method _task_attached_ps (line 166) | def _task_attached_ps(self, today, is_week):
    method _task_loop (line 172) | def _task_loop(self, today):
    method fit (line 208) | def fit(self, *args, **kwargs):
    method init_sell_factors (line 247) | def init_sell_factors(self, sell_factors):
    method init_buy_factors (line 277) | def init_buy_factors(self, buy_factors):
    method filter_long_task_factors (line 308) | def filter_long_task_factors(self):

FILE: abupy/BetaBu/ABuAtrPosition.py
  class AbuAtrPosition (line 23) | class AbuAtrPosition(AbuPositionBase):
    method fit_position (line 29) | def fit_position(self, factor_object):
    method _init_self (line 51) | def _init_self(self, **kwargs):

FILE: abupy/BetaBu/ABuKellyPosition.py
  class AbuKellyPosition (line 11) | class AbuKellyPosition(AbuPositionBase):
    method fit_position (line 14) | def fit_position(self, factor_object):
    method _init_self (line 29) | def _init_self(self, **kwargs):

FILE: abupy/BetaBu/ABuPositionBase.py
  class AbuPositionBase (line 33) | class AbuPositionBase(six.with_metaclass(ABCMeta, MarketMixin)):
    method __init__ (line 36) | def __init__(self, kl_pd_buy, factor_name, symbol_name, bp, read_cash,...
    method __str__ (line 59) | def __str__(self):
    method _init_self (line 70) | def _init_self(self, **kwargs):
    method fit_position (line 75) | def fit_position(self, factor_object):

FILE: abupy/BetaBu/ABuPtPosition.py
  class AbuPtPosition (line 13) | class AbuPtPosition(AbuPositionBase):
    method fit_position (line 24) | def fit_position(self, factor_object):
    method _init_self (line 46) | def _init_self(self, **kwargs):

FILE: abupy/CheckBu/ABuChecker.py
  class _NoInstances (line 21) | class _NoInstances(six.with_metaclass(ABCMeta, type)):
    method __call__ (line 24) | def __call__(cls, *args, **kwargs):
  class FuncChecker (line 28) | class FuncChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    method check_iscallable (line 32) | def check_iscallable(func):
  class ArgChecker (line 41) | class ArgChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    method check_type (line 45) | def check_type(*ty_args, **ty_kwargs):
    method check_bound (line 75) | def check_bound(*bd_args, **bd_kwargs):
    method _check_default (line 90) | def _check_default(check_no, *names, **_unused):
    method check_hasdefault (line 126) | def check_hasdefault(*names, **_unused):
    method check_nodefault (line 138) | def check_nodefault(*names, **_unused):
    method check_hasargs (line 150) | def check_hasargs(func):
    method check_haskwargs (line 173) | def check_haskwargs(func):
    method check_subset (line 195) | def check_subset(*ss_args, **ss_kwargs):
  class ReturnChecker (line 225) | class ReturnChecker(six.with_metaclass(ABCMeta, _NoInstances)):
    method check_type (line 229) | def check_type(*types, **_unused):
    method check_bound (line 253) | def check_bound(*bounds, **_unused):
    method check_subset (line 270) | def check_subset(*ss_args, **_unused):

FILE: abupy/CheckBu/ABuChecks.py
  class CheckError (line 19) | class CheckError(six.with_metaclass(ABCMeta, TypeError)):
  function bound_check (line 24) | def bound_check(bound):
  function bound_valid_and_check (line 51) | def bound_valid_and_check(bound):
  function subset_check (line 74) | def subset_check(subset):
  function type_check (line 92) | def type_check(arg_ty):

FILE: abupy/CheckBu/ABuFuncUtil.py
  class ArgNoDefault (line 25) | class ArgNoDefault(six.with_metaclass(ABCMeta, TypeError)):
  function get_func_name (line 30) | def get_func_name(func):
  function get_arg_defaults (line 43) | def get_arg_defaults(func):
  function check_bind (line 59) | def check_bind(func, *args, **kwargs):
  function bind_partial (line 91) | def bind_partial(func, *args, **kwargs):

FILE: abupy/CheckBu/ABuProcessor.py
  function arg_process (line 24) | def arg_process(*arg_funcs, **kwarg_funcs):
  function return_process (line 53) | def return_process(*funcs, **_unused):
  function _apply_funcs (line 77) | def _apply_funcs(return_vals, funcs):

FILE: abupy/CoreBu/ABu.py
  function run_loop_back (line 27) | def run_loop_back(read_cash, buy_factors, sell_factors, stock_picks=None...
  function run_kl_update (line 137) | def run_kl_update(n_folds=2, start=None, end=None, market=None, n_jobs=1...
  function store_abu_result_tuple (line 185) | def store_abu_result_tuple(abu_result_tuple, n_folds=None, store_type=ES...
  function load_abu_result_tuple (line 199) | def load_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_NOR...
  function gen_buy_from_chinese (line 214) | def gen_buy_from_chinese(*args, **kwargs):

FILE: abupy/CoreBu/ABuBase.py
  class FreezeAttrMixin (line 22) | class FreezeAttrMixin(object):
    method _freeze (line 25) | def _freeze(self):
    method __setattr__ (line 29) | def __setattr__(self, key, value):
  class PickleStateMixin (line 35) | class PickleStateMixin(object):
    method __getstate__ (line 47) | def __getstate__(self):
    method __setstate__ (line 56) | def __setstate__(self, state):
    method pick_extend_work (line 100) | def pick_extend_work(self):
    method unpick_extend_work (line 104) | def unpick_extend_work(self, state):
  class AbuParamBase (line 109) | class AbuParamBase(object):
    method get_params (line 113) | def get_params(cls):
    method _filter_attr (line 126) | def _filter_attr(self, user):
    method to_dict (line 136) | def to_dict(self, user=True):
    method to_series (line 140) | def to_series(self, user=True):
    method __str__ (line 144) | def __str__(self):

FILE: abupy/CoreBu/ABuDeprecated.py
  class AbuDeprecated (line 11) | class AbuDeprecated(object):
    method __init__ (line 14) | def __init__(self, tip_info=''):
    method __call__ (line 18) | def __call__(self, obj):
    method _decorate_class (line 26) | def _decorate_class(self, cls):
    method _decorate_fun (line 48) | def _decorate_fun(self, fun):
    method _update_doc (line 66) | def _update_doc(self, func_doc):

FILE: abupy/CoreBu/ABuEnv.py
  function str_is_cn (line 109) | def str_is_cn(a_str):
  class EMarketSourceType (line 206) | class EMarketSourceType(Enum):
  class EMarketTargetType (line 236) | class EMarketTargetType(Enum):
  class EMarketSubType (line 260) | class EMarketSubType(Enum):
  class EMarketDataSplitMode (line 318) | class EMarketDataSplitMode(Enum):
  class EMarketDataFetchMode (line 329) | class EMarketDataFetchMode(Enum):
  function enable_example_env_ipython (line 356) | def enable_example_env_ipython(show_log=True, check_cn=True):
  function disable_example_env_ipython (line 403) | def disable_example_env_ipython(show_log=True):
  class EDataCacheType (line 415) | class EDataCacheType(Enum):
  function init_logging (line 491) | def init_logging():
  function init_plot_set (line 530) | def init_plot_set():

FILE: abupy/CoreBu/ABuEnvProcess.py
  function add_process_env_sig (line 20) | def add_process_env_sig(func):
  class AbuEnvProcess (line 61) | class AbuEnvProcess(object):
    method __init__ (line 64) | def __init__(self):
    method register_module (line 78) | def register_module(self):
    method copy_process_env (line 102) | def copy_process_env(self):
    method __str__ (line 118) | def __str__(self):

FILE: abupy/CoreBu/ABuFixes.py
  function _parse_version (line 24) | def _parse_version(version_string):
  function as_bytes (line 98) | def as_bytes(s):
  function lru_cache (line 112) | def lru_cache(maxsize=100):
  function combinations_with_replacement (line 128) | def combinations_with_replacement(iterable, r):
  class partial (line 149) | class partial(object):
    method __init__ (line 150) | def __init__(self, func, *args, **keywords):
    method __call__ (line 156) | def __call__(self, *args, **keywords):
  function check_random_state (line 193) | def check_random_state(seed):
  class KFold (line 224) | class KFold(object):
    method __init__ (line 230) | def __init__(self, n, n_folds=3, shuffle=False, random_state=None):
    method __iter__ (line 260) | def __iter__(self):
    method _iter_test_masks (line 268) | def _iter_test_masks(self):
    method _empty_mask (line 274) | def _empty_mask(self):
    method _iter_test_indices (line 277) | def _iter_test_indices(self):
    method __repr__ (line 288) | def __repr__(self):
    method __len__ (line 298) | def __len__(self):
  function array_equal (line 332) | def array_equal(a1, a2):
  function rankdata (line 348) | def rankdata(a, method='average'):

FILE: abupy/CoreBu/ABuParallel.py
  function delayed (line 39) | def delayed(function):
  class Parallel (line 57) | class Parallel(object):
    method __init__ (line 60) | def __init__(self, n_jobs=1, backend='multiprocessing', verbose=0,
    method __call__ (line 75) | def __call__(self, iterable):
  function run_in_thread (line 101) | def run_in_thread(func, *args, **kwargs):
  function run_in_subprocess (line 114) | def run_in_subprocess(func, *args, **kwargs):

FILE: abupy/CoreBu/ABuPdHelper.py
  function __pd_object_covert_start (line 54) | def __pd_object_covert_start(iter_obj):
  function _pd_object_covert (line 70) | def _pd_object_covert(func):
  function _pd_rolling (line 88) | def _pd_rolling(pd_object, pd_object_cm, how, *args, **kwargs):
  function _pd_ewm (line 130) | def _pd_ewm(pd_object, pd_object_cm, how, *args, **kwargs):
  function _pd_expanding (line 169) | def _pd_expanding(pd_object, pd_object_cm, how, *args, **kwargs):
  function pd_resample (line 212) | def pd_resample(pd_object, rule, *args, **kwargs):

FILE: abupy/CoreBu/ABuStore.py
  class AbuResultTuple (line 17) | class AbuResultTuple(namedtuple('AbuResultTuple',
    method __repr__ (line 32) | def __repr__(self):
  class EStoreAbu (line 40) | class EStoreAbu(Enum):
  function dump_custom_abu_index_csv (line 60) | def dump_custom_abu_index_csv(custom_name, custom_desc):
  function dump_custom_ump_index_csv (line 91) | def dump_custom_ump_index_csv(custom_name, ump_unique, is_main_ump, cust...
  function _load_custom_index (line 124) | def _load_custom_index(*paths):
  function load_custom_abu_index (line 131) | def load_custom_abu_index():
  function load_custom_ump_index (line 136) | def load_custom_ump_index():
  function _del_custom_index (line 141) | def _del_custom_index(custom_name, *paths):
  function del_custom_abu_index (line 151) | def del_custom_abu_index(custom_name):
  function del_custom_ump_index (line 156) | def del_custom_ump_index(custom_name):
  function _cache_abu_result_path (line 161) | def _cache_abu_result_path(n_folds, store_type, custom_name):
  function store_abu_result_tuple (line 199) | def store_abu_result_tuple(abu_result_tuple, n_folds=None, store_type=ES...
  function load_abu_result_tuple (line 222) | def load_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_NOR...
  function delete_abu_result_tuple (line 248) | def delete_abu_result_tuple(n_folds=None, store_type=EStoreAbu.E_STORE_N...
  function store_abu_result_out_put (line 274) | def store_abu_result_out_put(abu_result_tuple, show_log=True):

FILE: abupy/CrawlBu/ABuXqApi.py
  class IndustryUrl (line 50) | class IndustryUrl(object):
    method __init__ (line 51) | def __init__(self, market, **kwargs):
    method init_base_url (line 57) | def init_base_url(self):
    method url (line 68) | def url(self):
  class StockListUrl (line 75) | class StockListUrl(IndustryUrl):
    method init_base_url (line 76) | def init_base_url(self):
  function test (line 87) | def test():

FILE: abupy/CrawlBu/ABuXqCrawl.py
  function __crawl_stock_parallel (line 33) | def __crawl_stock_parallel(market, url):
  function __crawl_stock_info_parallel (line 50) | def __crawl_stock_info_parallel(market, symbols, process):
  function hq_nav (line 56) | def hq_nav():
  function crawl_stock_code (line 68) | def crawl_stock_code(markets=('CN', 'HK', 'US')):
  function crawl_stock_info (line 87) | def crawl_stock_info(markets):
  function ensure_symbol (line 112) | def ensure_symbol(symbol):
  function update_all (line 164) | def update_all(markets=('US', 'CN', 'HK')):
  function query_symbol_info (line 171) | def query_symbol_info(symbol):

FILE: abupy/CrawlBu/ABuXqCrawlImp.py
  function _bs4_html (line 24) | def _bs4_html(content):
  function _xpath (line 34) | def _xpath(content):
  class BaseXQCrawlBrower (line 45) | class BaseXQCrawlBrower(six.with_metaclass(ABCMeta, object)):
    method __init__ (line 50) | def __init__(self, base_url):
    method _crawl_imp (line 65) | def _crawl_imp(self, *args, **kwargs):
    method get (line 68) | def get(self, url):
    method content (line 72) | def content(self):
    method crawl (line 75) | def crawl(self, *args, **kwargs):
    method __enter__ (line 91) | def __enter__(self):
    method __exit__ (line 94) | def __exit__(self, exc_type, exc_val, exc_tb):
    method _scroll_to_bottom (line 97) | def _scroll_to_bottom(self, element):
  class BaseHQCrawlBrower (line 102) | class BaseHQCrawlBrower(BaseXQCrawlBrower):
    method _crawl_imp (line 103) | def _crawl_imp(self, *args, **kwargs):
    method __init__ (line 106) | def __init__(self, url):
  class NavHQCrawlBrower (line 111) | class NavHQCrawlBrower(BaseHQCrawlBrower):
    method _crawl_imp (line 112) | def _crawl_imp(self, *args, **kwargs):
    method __init__ (line 115) | def __init__(self):
  class StockListCrawlBrower (line 119) | class StockListCrawlBrower(BaseHQCrawlBrower):
    method _ensure_max_page_size (line 120) | def _ensure_max_page_size(self):
    method _curr_page_counts (line 135) | def _curr_page_counts(self):
    method _curr_total_page (line 140) | def _curr_total_page(self):
    method _curr_page_items (line 152) | def _curr_page_items(self):
    method _goto_next_page (line 163) | def _goto_next_page(self):
    method _crawl_imp (line 171) | def _crawl_imp(self, *args, **kwargs):
    method __init__ (line 191) | def __init__(self, url):
  function _parse_nav (line 195) | def _parse_nav(content):
  class StockInfoListBrower (line 225) | class StockInfoListBrower(BaseXQCrawlBrower):
    method __init__ (line 226) | def __init__(self, market, symbols):
    method __exit__ (line 232) | def __exit__(self, exc_type, exc_val, exc_tb):
    method _parse_stock_info (line 237) | def _parse_stock_info(self):
    method _crawl_imp (line 280) | def _crawl_imp(self, *args, **kwargs):

FILE: abupy/CrawlBu/ABuXqFile.py
  function map_stock_list_rom (line 32) | def map_stock_list_rom(market):
  function map_stock_list (line 36) | def map_stock_list(market):
  function map_cache_stock_info (line 40) | def map_cache_stock_info(market, symbol):
  function save_cache_stock_info (line 51) | def save_cache_stock_info(stock_info, market, symbol):
  function exist_stock_info (line 57) | def exist_stock_info(market, symbol):
  function read_stock_symbol_list (line 61) | def read_stock_symbol_list(market):
  function read_stock_symbol_name (line 65) | def read_stock_symbol_name(market, symbol):
  function error_stock_info (line 71) | def error_stock_info(market, symbol, error_info):
  function read_all_error_stock_info_symbol (line 84) | def read_all_error_stock_info_symbol():
  function query_a_stock (line 92) | def query_a_stock(market, symbol):
  function _create_a_column (line 97) | def _create_a_column(info, columns, size):
  function merge_stock_info_to_stock_list (line 109) | def merge_stock_info_to_stock_list(market=('US', 'HK', 'CN')):
  function del_columns (line 136) | def del_columns(df, columns):
  function drop_nuisance (line 142) | def drop_nuisance(df):
  function fix_xq_columns_name (line 149) | def fix_xq_columns_name():

FILE: abupy/DLBu/ABuDLImgStd.py
  function std_img_from_root_dir (line 35) | def std_img_from_root_dir(root_dir, a_ext):
  function covert_to_jpeg (line 61) | def covert_to_jpeg(org_img, dst_img=None):
  function find_img_by_ext (line 74) | def find_img_by_ext(ext, root_dir):
  function change_to_real_type (line 95) | def change_to_real_type(img_list):

FILE: abupy/DLBu/ABuDLTVSplit.py
  function train_val_split (line 21) | def train_val_split(train_path, n_folds=10):

FILE: abupy/ExtBu/empyrical/_version.py
  function get_versions (line 20) | def get_versions():

FILE: abupy/ExtBu/empyrical/stats.py
  function _adjust_returns (line 47) | def _adjust_returns(returns, adjustment_factor):
  function annualization_factor (line 66) | def annualization_factor(period, annualization):
  function cum_returns (line 105) | def cum_returns(returns, starting_value=0):
  function cum_returns_final (line 155) | def cum_returns_final(returns, starting_value=0):
  function array_wrap (line 185) | def array_wrap(arg_name, _not_specified=object()):
  function nancumsum (line 220) | def nancumsum(a, axis=None, dtype=None):
  function aggregate_returns (line 267) | def aggregate_returns(returns, convert_to):
  function max_drawdown (line 302) | def max_drawdown(returns):
  function annual_return (line 330) | def annual_return(returns, period=DAILY, annualization=None):
  function annual_volatility (line 373) | def annual_volatility(returns, period=DAILY, alpha=2.0,
  function calmar_ratio (line 413) | def calmar_ratio(returns, period=DAILY, annualization=None):
  function omega_ratio (line 462) | def omega_ratio(returns, risk_free=0.0, required_return=0.0,
  function sharpe_ratio (line 516) | def sharpe_ratio(returns, risk_free=0, period=DAILY, annualization=None):
  function sortino_ratio (line 568) | def sortino_ratio(returns, required_return=0, period=DAILY,
  function downside_risk (line 620) | def downside_risk(returns, required_return=0, period=DAILY,
  function information_ratio (line 672) | def information_ratio(returns, factor_returns):
  function _aligned_series (line 706) | def _aligned_series(*many_series):
  function alpha_beta (line 727) | def alpha_beta(returns, factor_returns, risk_free=0.0, period=DAILY,
  function alpha_beta_aligned (line 771) | def alpha_beta_aligned(returns, factor_returns, risk_free=0.0, period=DA...
  function alpha (line 817) | def alpha(returns, factor_returns, risk_free=0.0, period=DAILY,
  function alpha_aligned (line 862) | def alpha_aligned(returns, factor_returns, risk_free=0.0, period=DAILY,
  function beta (line 918) | def beta(returns, factor_returns, risk_free=0.0):
  function beta_aligned (line 946) | def beta_aligned(returns, factor_returns, risk_free=0.0):
  function stability_of_timeseries (line 989) | def stability_of_timeseries(returns):
  function tail_ratio (line 1019) | def tail_ratio(returns):
  function cagr (line 1051) | def cagr(returns, period=DAILY, annualization=None):

FILE: abupy/ExtBu/funcsigs.py
  function formatannotation (line 31) | def formatannotation(annotation, base_module=None):
  function _get_user_defined_method (line 39) | def _get_user_defined_method(cls, method_name, *nested):
  function signature (line 55) | def signature(obj):
  class _void (line 179) | class _void(object):
  class _empty (line 183) | class _empty(object):
  class _ParameterKind (line 187) | class _ParameterKind(int):
    method __new__ (line 188) | def __new__(self, *args, **kwargs):
    method __str__ (line 193) | def __str__(self):
    method __repr__ (line 196) | def __repr__(self):
  class Parameter (line 207) | class Parameter(object):
    method __init__ (line 237) | def __init__(self, name, kind, default=_empty, annotation=_empty,
    method name (line 267) | def name(self):
    method default (line 271) | def default(self):
    method annotation (line 275) | def annotation(self):
    method kind (line 279) | def kind(self):
    method replace (line 282) | def replace(self, name=_void, kind=_void, annotation=_void,
    method __str__ (line 304) | def __str__(self):
    method __repr__ (line 328) | def __repr__(self):
    method __hash__ (line 332) | def __hash__(self):
    method __eq__ (line 336) | def __eq__(self, other):
    method __ne__ (line 343) | def __ne__(self, other):
  class BoundArguments (line 347) | class BoundArguments(object):
    method __init__ (line 364) | def __init__(self, signature, arguments):
    method signature (line 369) | def signature(self):
    method args (line 373) | def args(self):
    method kwargs (line 401) | def kwargs(self):
    method __hash__ (line 431) | def __hash__(self):
    method __eq__ (line 435) | def __eq__(self, other):
    method __ne__ (line 440) | def __ne__(self, other):
  class Signature (line 444) | class Signature(object):
    method __init__ (line 474) | def __init__(self, parameters=None, return_annotation=_empty,
    method from_function (line 513) | def from_function(cls, func):
    method parameters (line 586) | def parameters(self):
    method return_annotation (line 593) | def return_annotation(self):
    method replace (line 596) | def replace(self, parameters=_void, return_annotation=_void):
    method __hash__ (line 611) | def __hash__(self):
    method __eq__ (line 615) | def __eq__(self, other):
    method __ne__ (line 645) | def __ne__(self, other):
    method _bind (line 648) | def _bind(self, args, kwargs, partial=False):
    method bind (line 776) | def bind(self, *args, **kwargs):
    method bind_partial (line 783) | def bind_partial(self, *args, **kwargs):
    method __str__ (line 790) | def __str__(self):

FILE: abupy/ExtBu/futures/_base.py
  class Error (line 45) | class Error(Exception):
  class CancelledError (line 49) | class CancelledError(Error):
  class TimeoutError (line 53) | class TimeoutError(Error):
  class _Waiter (line 57) | class _Waiter(object):
    method __init__ (line 59) | def __init__(self):
    method add_result (line 63) | def add_result(self, future):
    method add_exception (line 66) | def add_exception(self, future):
    method add_cancelled (line 69) | def add_cancelled(self, future):
  class _AsCompletedWaiter (line 72) | class _AsCompletedWaiter(_Waiter):
    method __init__ (line 75) | def __init__(self):
    method add_result (line 79) | def add_result(self, future):
    method add_exception (line 84) | def add_exception(self, future):
    method add_cancelled (line 89) | def add_cancelled(self, future):
  class _FirstCompletedWaiter (line 94) | class _FirstCompletedWaiter(_Waiter):
    method add_result (line 97) | def add_result(self, future):
    method add_exception (line 101) | def add_exception(self, future):
    method add_cancelled (line 105) | def add_cancelled(self, future):
  class _AllCompletedWaiter (line 109) | class _AllCompletedWaiter(_Waiter):
    method __init__ (line 112) | def __init__(self, num_pending_calls, stop_on_exception):
    method _decrement_pending_calls (line 118) | def _decrement_pending_calls(self):
    method add_result (line 124) | def add_result(self, future):
    method add_exception (line 128) | def add_exception(self, future):
    method add_cancelled (line 135) | def add_cancelled(self, future):
  class _AcquireFutures (line 139) | class _AcquireFutures(object):
    method __init__ (line 142) | def __init__(self, futures):
    method __enter__ (line 145) | def __enter__(self):
    method __exit__ (line 149) | def __exit__(self, *args):
  function _create_and_install_waiters (line 153) | def _create_and_install_waiters(fs, return_when):
  function as_completed (line 174) | def as_completed(fs, timeout=None):
  function wait (line 235) | def wait(fs, timeout=None, return_when=ALL_COMPLETED):
  class Future (line 284) | class Future(object):
    method __init__ (line 287) | def __init__(self):
    method _invoke_callbacks (line 297) | def _invoke_callbacks(self):
    method __repr__ (line 304) | def __repr__(self):
    method cancel (line 321) | def cancel(self):
    method cancelled (line 340) | def cancelled(self):
    method running (line 345) | def running(self):
    method done (line 350) | def done(self):
    method __get_result (line 355) | def __get_result(self):
    method add_done_callback (line 362) | def add_done_callback(self, fn):
    method result (line 379) | def result(self, timeout=None):
    method exception_info (line 410) | def exception_info(self, timeout=None):
    method exception (line 443) | def exception(self, timeout=None):
    method set_running_or_notify_cancel (line 463) | def set_running_or_notify_cancel(self):
    method set_result (line 503) | def set_result(self, result):
    method set_exception_info (line 516) | def set_exception_info(self, exception, traceback):
    method set_exception (line 531) | def set_exception(self, exception):
  class Executor (line 538) | class Executor(object):
    method submit (line 541) | def submit(self, fn, *args, **kwargs):
    method map (line 552) | def map(self, fn, *iterables, **kwargs):
    method shutdown (line 590) | def shutdown(self, wait=True):
    method __enter__ (line 603) | def __enter__(self):
    method __exit__ (line 606) | def __exit__(self, exc_type, exc_val, exc_tb):

FILE: abupy/ExtBu/futures/process.py
  function _python_exit (line 73) | def _python_exit():
  class _WorkItem (line 88) | class _WorkItem(object):
    method __init__ (line 89) | def __init__(self, future, fn, args, kwargs):
  class _ResultItem (line 95) | class _ResultItem(object):
    method __init__ (line 96) | def __init__(self, work_id, exception=None, result=None):
  class _CallItem (line 101) | class _CallItem(object):
    method __init__ (line 102) | def __init__(self, work_id, fn, args, kwargs):
  function _process_worker (line 108) | def _process_worker(call_queue, result_queue):
  function _add_call_item_to_queue (line 137) | def _add_call_item_to_queue(pending_work_items,
  function _queue_management_worker (line 174) | def _queue_management_worker(executor_reference,
  function _check_system_limits (line 242) | def _check_system_limits():
  class ProcessPoolExecutor (line 265) | class ProcessPoolExecutor(_base.Executor):
    method __init__ (line 266) | def __init__(self, max_workers=None):
    method _start_queue_management_thread (line 297) | def _start_queue_management_thread(self):
    method _adjust_process_count (line 315) | def _adjust_process_count(self):
    method submit (line 324) | def submit(self, fn, *args, **kwargs):
    method shutdown (line 343) | def shutdown(self, wait=True):

FILE: abupy/ExtBu/futures/thread.py
  function _python_exit (line 32) | def _python_exit():
  class _WorkItem (line 43) | class _WorkItem(object):
    method __init__ (line 44) | def __init__(self, future, fn, args, kwargs):
    method run (line 50) | def run(self):
  function _worker (line 62) | def _worker(executor_reference, work_queue):
  class ThreadPoolExecutor (line 84) | class ThreadPoolExecutor(_base.Executor):
    method __init__ (line 85) | def __init__(self, max_workers):
    method submit (line 98) | def submit(self, fn, *args, **kwargs):
    method _adjust_thread_count (line 111) | def _adjust_thread_count(self):
    method shutdown (line 127) | def shutdown(self, wait=True):

FILE: abupy/ExtBu/joblib/_compat.py
  function with_metaclass (line 18) | def with_metaclass(meta, *bases):

FILE: abupy/ExtBu/joblib/_memory_helpers.py
  function _get_normal_name (line 12) | def _get_normal_name(orig_enc):
  function _detect_encoding (line 23) | def _detect_encoding(readline):
  function open_py_source (line 96) | def open_py_source(filename):

FILE: abupy/ExtBu/joblib/_parallel_backends.py
  class ParallelBackendBase (line 21) | class ParallelBackendBase(with_metaclass(ABCMeta)):
    method effective_n_jobs (line 25) | def effective_n_jobs(self, n_jobs):
    method apply_async (line 43) | def apply_async(self, func, callback=None):
    method configure (line 46) | def configure(self, n_jobs=1, parallel=None, **backend_args):
    method terminate (line 55) | def terminate(self):
    method compute_batch_size (line 58) | def compute_batch_size(self):
    method batch_completed (line 62) | def batch_completed(self, batch_size, duration):
    method get_exceptions (line 65) | def get_exceptions(self):
    method abort_everything (line 69) | def abort_everything(self, ensure_ready=True):
  class SequentialBackend (line 94) | class SequentialBackend(ParallelBackendBase):
    method effective_n_jobs (line 101) | def effective_n_jobs(self, n_jobs):
    method apply_async (line 107) | def apply_async(self, func, callback=None):
  class PoolManagerMixin (line 115) | class PoolManagerMixin(object):
    method effective_n_jobs (line 118) | def effective_n_jobs(self, n_jobs):
    method terminate (line 130) | def terminate(self):
    method apply_async (line 137) | def apply_async(self, func, callback=None):
    method abort_everything (line 141) | def abort_everything(self, ensure_ready=True):
  class AutoBatchingMixin (line 149) | class AutoBatchingMixin(object):
    method compute_batch_size (line 166) | def compute_batch_size(self):
    method batch_completed (line 212) | def batch_completed(self, batch_size, duration):
  class ThreadingBackend (line 229) | class ThreadingBackend(PoolManagerMixin, ParallelBackendBase):
    method configure (line 239) | def configure(self, n_jobs=1, parallel=None, **backend_args):
  class MultiprocessingBackend (line 250) | class MultiprocessingBackend(PoolManagerMixin, AutoBatchingMixin,
    method effective_n_jobs (line 262) | def effective_n_jobs(self, n_jobs):
    method configure (line 290) | def configure(self, n_jobs=1, parallel=None, **backend_args):
    method terminate (line 315) | def terminate(self):
  class ImmediateResult (line 322) | class ImmediateResult(object):
    method __init__ (line 323) | def __init__(self, batch):
    method get (line 328) | def get(self):
  class SafeFunction (line 332) | class SafeFunction(object):
    method __init__ (line 339) | def __init__(self, func):
    method __call__ (line 342) | def __call__(self, *args, **kwargs):
  class FallbackToBackend (line 356) | class FallbackToBackend(Exception):
    method __init__ (line 359) | def __init__(self, backend):

FILE: abupy/ExtBu/joblib/disk.py
  function disk_used (line 18) | def disk_used(path):
  function memstr_to_bytes (line 34) | def memstr_to_bytes(text):
  function mkdirp (line 48) | def mkdirp(d):
  function rm_subdirs (line 64) | def rm_subdirs(path, onerror=None):

FILE: abupy/ExtBu/joblib/format_stack.py
  function safe_repr (line 42) | def safe_repr(value):
  function eq_repr (line 71) | def eq_repr(value, repr=safe_repr):
  function uniq_stable (line 76) | def uniq_stable(elems):
  function fix_frame_records_filenames (line 98) | def fix_frame_records_filenames(records):
  function _fixed_getframes (line 119) | def _fixed_getframes(etb, context=1, tb_offset=0):
  function _format_traceback_lines (line 155) | def _format_traceback_lines(lnum, index, lines, lvals=None):
  function format_records (line 184) | def format_records(records):   # , print_globals=False):
  function format_exc (line 331) | def format_exc(etype, evalue, etb, context=5, tb_offset=0):
  function format_outer_frames (line 380) | def format_outer_frames(context=5, stack_start=None, stack_end=None,

FILE: abupy/ExtBu/joblib/func_inspect.py
  function get_func_code (line 21) | def get_func_code(func):
  function _clean_win_chars (line 77) | def _clean_win_chars(string):
  function get_func_name (line 91) | def get_func_name(func, resolv_alias=True, win_characters=True):
  function getfullargspec (line 160) | def getfullargspec(func):
  function _signature_str (line 186) | def _signature_str(function_name, arg_spec):
  function _function_called_str (line 196) | def _function_called_str(function_name, args, kwargs):
  function filter_args (line 207) | def filter_args(func, ignore_lst, args=(), kwargs=dict()):
  function format_signature (line 319) | def format_signature(func, *args, **kwargs):
  function format_call (line 345) | def format_call(func, args, kwargs, object_name="Memory"):

FILE: abupy/ExtBu/joblib/hashing.py
  class _ConsistentSet (line 26) | class _ConsistentSet(object):
    method __init__ (line 30) | def __init__(self, set_sequence):
  class _MyHash (line 44) | class _MyHash(object):
    method __init__ (line 47) | def __init__(self, *args):
  class Hasher (line 51) | class Hasher(Pickler):
    method __init__ (line 56) | def __init__(self, hash_name='md5'):
    method hash (line 66) | def hash(self, obj, return_digest=True):
    method save (line 77) | def save(self, obj):
    method memoize (line 96) | def memoize(self, obj):
    method save_global (line 107) | def save_global(self, obj, name=None, pack=struct.pack):
    method _batch_setitems (line 139) | def _batch_setitems(self, items):
    method save_set (line 153) | def save_set(self, set_items):
  class NumpyHasher (line 160) | class NumpyHasher(Hasher):
    method __init__ (line 164) | def __init__(self, hash_name='md5', coerce_mmap=False):
    method save (line 184) | def save(self, obj):
  function hash (line 245) | def hash(obj, hash_name='md5', coerce_mmap=False):

FILE: abupy/ExtBu/joblib/logger.py
  function _squeeze_time (line 23) | def _squeeze_time(t):
  function format_time (line 34) | def format_time(t):
  function short_format_time (line 39) | def short_format_time(t):
  function pformat (line 47) | def pformat(obj, indent=0, depth=3):
  class Logger (line 63) | class Logger(object):
    method __init__ (line 67) | def __init__(self, depth=3):
    method warn (line 76) | def warn(self, msg):
    method debug (line 79) | def debug(self, msg):
    method format (line 83) | def format(self, obj, indent=0):
  class PrintTime (line 92) | class PrintTime(object):
    method __init__ (line 96) | def __init__(self, logfile=None, logdir=None):
    method __call__ (line 133) | def __call__(self, msg='', total=False):

FILE: abupy/ExtBu/joblib/memory.py
  function extract_first_line (line 56) | def extract_first_line(func_code):
  class JobLibCollisionWarning (line 69) | class JobLibCollisionWarning(UserWarning):
  function _get_func_fullname (line 74) | def _get_func_fullname(func):
  function _cache_key_to_dir (line 84) | def _cache_key_to_dir(cachedir, func, argument_hash):
  function _load_output (line 100) | def _load_output(output_dir, func_name, timestamp=None, metadata=None,
  class MemorizedResult (line 144) | class MemorizedResult(Logger):
    method __init__ (line 170) | def __init__(self, cachedir, func, argument_hash,
    method get (line 200) | def get(self):
    method clear (line 207) | def clear(self):
    method __repr__ (line 211) | def __repr__(self):
    method __reduce__ (line 220) | def __reduce__(self):
  class NotMemorizedResult (line 225) | class NotMemorizedResult(object):
    method __init__ (line 232) | def __init__(self, value):
    method get (line 236) | def get(self):
    method clear (line 242) | def clear(self):
    method __repr__ (line 246) | def __repr__(self):
    method __getstate__ (line 256) | def __getstate__(self):
    method __setstate__ (line 259) | def __setstate__(self, state):
  class NotMemorizedFunc (line 267) | class NotMemorizedFunc(object):
    method __init__ (line 279) | def __init__(self, func):
    method __call__ (line 282) | def __call__(self, *args, **kwargs):
    method call_and_shelve (line 285) | def call_and_shelve(self, *args, **kwargs):
    method __reduce__ (line 288) | def __reduce__(self):
    method __repr__ (line 291) | def __repr__(self):
    method clear (line 297) | def clear(self, warn=True):
  class MemorizedFunc (line 305) | class MemorizedFunc(Logger):
    method __init__ (line 343) | def __init__(self, func, cachedir, ignore=None, mmap_mode=None,
    method _cached_call (line 402) | def _cached_call(self, args, kwargs):
    method call_and_shelve (line 461) | def call_and_shelve(self, *args, **kwargs):
    method __call__ (line 482) | def __call__(self, *args, **kwargs):
    method __reduce__ (line 485) | def __reduce__(self):
    method format_signature (line 493) | def format_signature(self, *args, **kwargs):
    method format_call (line 498) | def format_call(self, *args, **kwargs):
    method _get_argument_hash (line 507) | def _get_argument_hash(self, *args, **kwargs):
    method _get_output_dir (line 512) | def _get_output_dir(self, *args, **kwargs):
    method _get_func_dir (line 523) | def _get_func_dir(self, mkdir=True):
    method _hash_func (line 532) | def _hash_func(self):
    method _write_func_code (line 537) | def _write_func_code(self, filename, func_code, first_line):
    method _check_previous_func_code (line 566) | def _check_previous_func_code(self, stacklevel=2):
    method clear (line 654) | def clear(self, warn=True):
    method call (line 667) | def call(self, *args, **kwargs):
    method _persist_output (line 687) | def _persist_output(self, output, dir):
    method _persist_input (line 699) | def _persist_input(self, output_dir, duration, args, kwargs,
    method load_output (line 753) | def load_output(self, output_dir):
    method __repr__ (line 772) | def __repr__(self):
  class Memory (line 783) | class Memory(Logger):
    method __init__ (line 796) | def __init__(self, cachedir, mmap_mode=None, compress=False, verbose=1):
    method cache (line 832) | def cache(self, func=None, ignore=None, verbose=None,
    method clear (line 879) | def clear(self, warn=True):
    method eval (line 887) | def eval(self, func, *args, **kwargs):
    method __repr__ (line 904) | def __repr__(self):
    method __reduce__ (line 910) | def __reduce__(self):

FILE: abupy/ExtBu/joblib/my_exceptions.py
  class JoblibException (line 12) | class JoblibException(Exception):
    method __init__ (line 14) | def __init__(self, *args):
    method __repr__ (line 28) | def __repr__(self):
  class TransportableException (line 40) | class TransportableException(JoblibException):
    method __init__ (line 45) | def __init__(self, message, etype):
  class WorkerInterrupt (line 53) | class WorkerInterrupt(Exception):
  function _mk_exception (line 63) | def _mk_exception(exception, name=None):
  function _mk_common_exceptions (line 91) | def _mk_common_exceptions():

FILE: abupy/ExtBu/joblib/numpy_pickle.py
  class NumpyArrayWrapper (line 34) | class NumpyArrayWrapper(object):
    method __init__ (line 64) | def __init__(self, subclass, shape, order, dtype, allow_mmap=False):
    method write_array (line 72) | def write_array(self, array, pickler):
    method read_array (line 94) | def read_array(self, unpickler):
    method read_mmap (line 148) | def read_mmap(self, unpickler):
    method read (line 165) | def read(self, unpickler):
  class NumpyPickler (line 200) | class NumpyPickler(Pickler):
    method __init__ (line 218) | def __init__(self, fp, protocol=None):
    method _create_array_wrapper (line 236) | def _create_array_wrapper(self, array):
    method save (line 247) | def save(self, obj):
  class NumpyUnpickler (line 283) | class NumpyUnpickler(Unpickler):
    method __init__ (line 302) | def __init__(self, filename, file_handle, mmap_mode=None):
    method load_build (line 319) | def load_build(self):
  function dump (line 352) | def dump(value, filename, compress=0, protocol=None, cache_size=None):
  function _unpickle (line 496) | def _unpickle(fobj, filename="", mmap_mode=None):
  function load (line 529) | def load(filename, mmap_mode=None):

FILE: abupy/ExtBu/joblib/numpy_pickle_compat.py
  function hex_str (line 13) | def hex_str(an_int):
  function asbytes (line 18) | def asbytes(s):
  function read_zfile (line 29) | def read_zfile(file_handle):
  function write_zfile (line 62) | def write_zfile(file_handle, data, compress=1):
  class NDArrayWrapper (line 79) | class NDArrayWrapper(object):
    method __init__ (line 86) | def __init__(self, filename, subclass, allow_mmap=True):
    method read (line 92) | def read(self, unpickler):
  class ZNDArrayWrapper (line 115) | class ZNDArrayWrapper(NDArrayWrapper):
    method __init__ (line 130) | def __init__(self, filename, init_args, state):
    method read (line 136) | def read(self, unpickler):
  class ZipNumpyUnpickler (line 149) | class ZipNumpyUnpickler(Unpickler):
    method __init__ (line 154) | def __init__(self, filename, file_handle, mmap_mode=None):
    method _open_pickle (line 167) | def _open_pickle(self, file_handle):
    method load_build (line 170) | def load_build(self):
  function load_compatibility (line 193) | def load_compatibility(filename):

FILE: abupy/ExtBu/joblib/numpy_pickle_utils.py
  function _detect_compressor (line 68) | def _detect_compressor(fileobj):
  function _buffered_read_file (line 100) | def _buffered_read_file(fobj):
  function _buffered_write_file (line 111) | def _buffered_write_file(fobj):
  function _read_fileobject (line 125) | def _read_fileobject(fileobj, filename, mmap_mode=None):
  function _write_fileobject (line 214) | def _write_fileobject(filename, compress=("zlib", 3)):
  class BinaryZlibFile (line 247) | class BinaryZlibFile(io.BufferedIOBase):
    method __init__ (line 272) | def __init__(self, filename, mode="rb", compresslevel=9):
    method close (line 313) | def close(self):
    method closed (line 340) | def closed(self):
    method fileno (line 344) | def fileno(self):
    method seekable (line 349) | def seekable(self):
    method readable (line 353) | def readable(self):
    method writable (line 358) | def writable(self):
    method _check_not_closed (line 365) | def _check_not_closed(self):
    method _check_can_read (line 374) | def _check_can_read(self):
    method _check_can_write (line 379) | def _check_can_write(self):
    method _check_can_seek (line 384) | def _check_can_seek(self):
    method _fill_buffer (line 394) | def _fill_buffer(self):
    method _read_all (line 418) | def _read_all(self, return_data=True):
    method _read_block (line 434) | def _read_block(self, n_bytes, return_data=True):
    method read (line 462) | def read(self, size=-1):
    method readinto (line 477) | def readinto(self, b):
    method write (line 485) | def write(self, data):
    method _rewind (line 504) | def _rewind(self):
    method seek (line 512) | def seek(self, offset, whence=0):
    method tell (line 554) | def tell(self):
  class BinaryGzipFile (line 561) | class BinaryGzipFile(BinaryZlibFile):
  function _read_bytes (line 584) | def _read_bytes(fp, size, error_template="ran out of data"):

FILE: abupy/ExtBu/joblib/parallel.py
  function get_active_backend (line 56) | def get_active_backend():
  function parallel_backend (line 68) | def parallel_backend(backend, n_jobs=-1, **backend_params):
  class BatchedCalls (line 123) | class BatchedCalls(object):
    method __init__ (line 126) | def __init__(self, iterator_slice):
    method __call__ (line 130) | def __call__(self):
    method __len__ (line 133) | def __len__(self):
  function cpu_count (line 140) | def cpu_count():
  function _verbosity_filter (line 150) | def _verbosity_filter(index, verbose):
  function delayed (line 169) | def delayed(function, check_pickle=True):
  class BatchCompletionCallBack (line 195) | class BatchCompletionCallBack(object):
    method __init__ (line 206) | def __init__(self, dispatch_timestamp, batch_size, parallel):
    method __call__ (line 211) | def __call__(self, out):
  function register_parallel_backend (line 223) | def register_parallel_backend(name, factory, make_default=False):
  function effective_n_jobs (line 245) | def effective_n_jobs(n_jobs=-1):
  class Parallel (line 272) | class Parallel(Logger):
    method __init__ (line 469) | def __init__(self, n_jobs=1, backend=None, verbose=0, timeout=None,
    method __enter__ (line 527) | def __enter__(self):
    method __exit__ (line 532) | def __exit__(self, exc_type, exc_value, traceback):
    method _initialize_backend (line 536) | def _initialize_backend(self):
    method _effective_n_jobs (line 546) | def _effective_n_jobs(self):
    method _terminate_backend (line 551) | def _terminate_backend(self):
    method _dispatch (line 555) | def _dispatch(self, batch):
    method dispatch_next (line 574) | def dispatch_next(self):
    method dispatch_one_batch (line 586) | def dispatch_one_batch(self, iterator):
    method _print (line 611) | def _print(self, msg, msg_args):
    method print_progress (line 624) | def print_progress(self):
    method retrieve (line 667) | def retrieve(self):
    method __call__ (line 721) | def __call__(self, iterable):
    method __repr__ (line 782) | def __repr__(self):

FILE: abupy/ExtBu/joblib/pool.py
  function _get_backing_memmap (line 79) | def _get_backing_memmap(a):
  function has_shareable_memory (line 96) | def has_shareable_memory(a):
  function _strided_from_memmap (line 101) | def _strided_from_memmap(filename, dtype, mode, offset, order, shape, st...
  function _reduce_memmap_backed (line 120) | def _reduce_memmap_backed(a, m):
  function reduce_memmap (line 156) | def reduce_memmap(a):
  class ArrayMemmapReducer (line 170) | class ArrayMemmapReducer(object):
    method __init__ (line 194) | def __init__(self, max_nbytes, temp_folder, mmap_mode, verbose=0,
    method __call__ (line 206) | def __call__(self, a):
  class CustomizablePickler (line 265) | class CustomizablePickler(Pickler):
    method __init__ (line 287) | def __init__(self, writer, reducers=None, protocol=HIGHEST_PROTOCOL):
    method register (line 302) | def register(self, type, reduce_func):
  class CustomizablePicklingQueue (line 315) | class CustomizablePicklingQueue(object):
    method __init__ (line 332) | def __init__(self, context, reducers=None):
    method __getstate__ (line 342) | def __getstate__(self):
    method __setstate__ (line 347) | def __setstate__(self, state):
    method empty (line 352) | def empty(self):
    method _make_methods (line 355) | def _make_methods(self):
  class PicklingPool (line 393) | class PicklingPool(Pool):
    method __init__ (line 410) | def __init__(self, processes=None, forward_reducers=None,
    method _setup_queues (line 422) | def _setup_queues(self):
  function delete_folder (line 432) | def delete_folder(folder_path):
  class MemmapingPool (line 441) | class MemmapingPool(PicklingPool):
    method __init__ (line 513) | def __init__(self, processes=None, temp_folder=None, max_nbytes=1e6,
    method terminate (line 602) | def terminate(self):

FILE: abupy/ExtBu/joblib/testing.py
  function warnings_to_stdout (line 15) | def warnings_to_stdout():
  function assert_raises_regex (line 35) | def assert_raises_regex(expected_exception, expected_regexp,
  function check_subprocess_call (line 54) | def check_subprocess_call(cmd, timeout=1, stdout_regex=None,

FILE: abupy/ExtBu/odict.py
  class OrderedDict (line 23) | class OrderedDict(dict):
    method __init__ (line 35) | def __init__(self, *args, **kwds):
    method __setitem__ (line 51) | def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
    method __delitem__ (line 61) | def __delitem__(self, key, dict_delitem=dict.__delitem__):
    method __iter__ (line 70) | def __iter__(self):
    method __reversed__ (line 78) | def __reversed__(self):
    method clear (line 86) | def clear(self):
    method popitem (line 98) | def popitem(self, last=True):
    method keys (line 123) | def keys(self):
    method values (line 127) | def values(self):
    method items (line 131) | def items(self):
    method iterkeys (line 135) | def iterkeys(self):
    method itervalues (line 139) | def itervalues(self):
    method iteritems (line 144) | def iteritems(self):
    method update (line 149) | def update(*args, **kwds):
    method pop (line 184) | def pop(self, key, default=__marker):
    method setdefault (line 197) | def setdefault(self, key, default=None):
    method __repr__ (line 204) | def __repr__(self, _repr_running={}):
    method __reduce__ (line 217) | def __reduce__(self):
    method copy (line 227) | def copy(self):
    method fromkeys (line 232) | def fromkeys(cls, iterable, value=None):
    method __eq__ (line 242) | def __eq__(self, other):
    method __ne__ (line 251) | def __ne__(self, other):
    method viewkeys (line 256) | def viewkeys(self):
    method viewvalues (line 260) | def viewvalues(self):
    method viewitems (line 264) | def viewitems(self):

FILE: abupy/ExtBu/six.py
  class X (line 55) | class X(object):
    method __len__ (line 56) | def __len__(self):
  function _add_doc (line 69) | def _add_doc(func, doc):
  function _import_module (line 74) | def _import_module(name):
  class _LazyDescr (line 80) | class _LazyDescr(object):
    method __init__ (line 82) | def __init__(self, name):
    method __get__ (line 85) | def __get__(self, obj, tp):
  class MovedModule (line 93) | class MovedModule(_LazyDescr):
    method __init__ (line 95) | def __init__(self, name, old, new=None):
    method _resolve (line 104) | def _resolve(self):
  class MovedAttribute (line 108) | class MovedAttribute(_LazyDescr):
    method __init__ (line 110) | def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
    method _resolve (line 128) | def _resolve(self):
  class _MovedItems (line 134) | class _MovedItems(types.ModuleType):
  class Module_six_moves_urllib_parse (line 202) | class Module_six_moves_urllib_parse(types.ModuleType):
  class Module_six_moves_urllib_error (line 230) | class Module_six_moves_urllib_error(types.ModuleType):
  class Module_six_moves_urllib_request (line 247) | class Module_six_moves_urllib_request(types.ModuleType):
  class Module_six_moves_urllib_response (line 293) | class Module_six_moves_urllib_response(types.ModuleType):
  class Module_six_moves_urllib_robotparser (line 311) | class Module_six_moves_urllib_robotparser(types.ModuleType):
  class Module_six_moves_urllib (line 326) | class Module_six_moves_urllib(types.ModuleType):
  function add_move (line 338) | def add_move(move):
  function remove_move (line 343) | def remove_move(name):
  function advance_iterator (line 385) | def advance_iterator(it):
  function callable (line 393) | def callable(obj):
  function get_unbound_function (line 398) | def get_unbound_function(unbound):
  function get_unbound_function (line 405) | def get_unbound_function(unbound):
  function create_bound_method (line 408) | def create_bound_method(func, obj):
  class Iterator (line 411) | class Iterator(object):
    method next (line 413) | def next(self):
  function iterkeys (line 429) | def iterkeys(d, **kw):
  function itervalues (line 433) | def itervalues(d, **kw):
  function iteritems (line 437) | def iteritems(d, **kw):
  function iterlists (line 441) | def iterlists(d, **kw):
  function b (line 447) | def b(s):
  function u (line 449) | def u(s):
  function int2byte (line 453) | def int2byte(i):
  function b (line 465) | def b(s):
  function u (line 467) | def u(s):
  function byte2int (line 471) | def byte2int(bs):
  function indexbytes (line 473) | def indexbytes(buf, i):
  function iterbytes (line 475) | def iterbytes(buf):
  function reraise (line 488) | def reraise(tp, value, tb=None):
  function exec_ (line 498) | def exec_(_code_, _globs_=None, _locs_=None):
  function print_ (line 516) | def print_(*args, **kwargs):
  function with_metaclass (line 564) | def with_metaclass(meta, *bases):
  function add_metaclass (line 568) | def add_metaclass(metaclass):

FILE: abupy/FactorBuyBu/ABuBuyFactorWrap.py
  class AbuLeastPolyWrap (line 15) | class AbuLeastPolyWrap(object):
    method __call__ (line 18) | def __call__(self, cls):

FILE: abupy/FactorBuyBu/ABuFactorBuyBase.py
  class BuyCallMixin (line 28) | class BuyCallMixin(object):
    method buy_type_str (line 35) | def buy_type_str(self):
    method expect_direction (line 40) | def expect_direction(self):
  class BuyPutMixin (line 45) | class BuyPutMixin(object):
    method buy_type_str (line 53) | def buy_type_str(self):
    method expect_direction (line 58) | def expect_direction(self):
  class AbuFactorBuyBase (line 63) | class AbuFactorBuyBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    method __init__ (line 73) | def __init__(self, capital, kl_pd, combine_kl_pd, benchmark, **kwargs):
    method _position_class_init (line 109) | def _position_class_init(self, **kwargs):
    method _slippage_class_init (line 142) | def _slippage_class_init(self, **kwargs):
    method _other_kwargs_init (line 148) | def _other_kwargs_init(self, **kwargs):
    method __str__ (line 205) | def __str__(self):
    method make_buy_order (line 213) | def make_buy_order(self, day_ind=-1):
    method make_ump_block_decision (line 243) | def make_ump_block_decision(self, ml_feature_dict):
    method make_buy_order_ml_feature (line 254) | def make_buy_order_ml_feature(self, day_ind):
    method _init_self (line 263) | def _init_self(self, **kwargs):
    method read_fit_day (line 267) | def read_fit_day(self, today):
    method buy_tomorrow (line 286) | def buy_tomorrow(self):
    method buy_today (line 294) | def buy_today(self):
    method _fit_pick_stock (line 302) | def _fit_pick_stock(self, today, pick_array):
    method fit_ps_week (line 315) | def fit_ps_week(self, today):
    method fit_ps_month (line 319) | def fit_ps_month(self, today):
    method fit_day (line 324) | def fit_day(self, today):
    method past_today_kl (line 328) | def past_today_kl(self, today, past_day_cnt):
    method past_today_one_month (line 340) | def past_today_one_month(self, today):
    method past_today_one_week (line 345) | def past_today_one_week(self, today):
    method past_today_one_year (line 350) | def past_today_one_year(self, today):
    method _deprecated_kwargs_init (line 355) | def _deprecated_kwargs_init(self, **kwargs):
    method _do_kelly_deprecated (line 361) | def _do_kelly_deprecated(self, **kwargs):
  class AbuFactorBuyTD (line 382) | class AbuFactorBuyTD(AbuFactorBuyBase):
    method read_fit_day (line 385) | def read_fit_day(self, today):
    method _init_self (line 414) | def _init_self(self, **kwargs):
    method fit_day (line 418) | def fit_day(self, today):
  class AbuFactorBuyXD (line 423) | class AbuFactorBuyXD(AbuFactorBuyBase):
    method read_fit_day (line 426) | def read_fit_day(self, today):
    method buy_tomorrow (line 451) | def buy_tomorrow(self):
    method buy_today (line 461) | def buy_today(self):
    method _init_self (line 470) | def _init_self(self, **kwargs):
    method fit_day (line 477) | def fit_day(self, today):

FILE: abupy/FactorBuyBu/ABuFactorBuyBreak.py
  class AbuFactorBuyBreak (line 17) | class AbuFactorBuyBreak(AbuFactorBuyBase, BuyCallMixin):
    method _init_self (line 20) | def _init_self(self, **kwargs):
    method fit_day (line 27) | def fit_day(self, today):
  class AbuFactorBuyXDBK (line 47) | class AbuFactorBuyXDBK(AbuFactorBuyXD, BuyCallMixin):
    method fit_day (line 49) | def fit_day(self, today):
  class AbuFactorBuyPutBreak (line 62) | class AbuFactorBuyPutBreak(AbuFactorBuyBase, BuyPutMixin):
    method _init_self (line 65) | def _init_self(self, **kwargs):
    method fit_day (line 72) | def fit_day(self, today):
  class AbuFactorBuyPutXDBK (line 91) | class AbuFactorBuyPutXDBK(AbuFactorBuyXD, BuyPutMixin):
    method fit_day (line 93) | def fit_day(self, today):

FILE: abupy/FactorBuyBu/ABuFactorBuyDM.py
  class AbuDoubleMaBuy (line 24) | class AbuDoubleMaBuy(AbuFactorBuyXD, BuyCallMixin):
    method _init_self (line 27) | def _init_self(self, **kwargs):
    method _dynamic_calc_fast (line 68) | def _dynamic_calc_fast(self, today):
    method _dynamic_calc_slow (line 110) | def _dynamic_calc_slow(self, today):
    method fit_month (line 184) | def fit_month(self, today):
    method fit_day (line 197) | def fit_day(self, today):

FILE: abupy/FactorBuyBu/ABuFactorBuyDemo.py
  class AbuSDBreak (line 23) | class AbuSDBreak(AbuFactorBuyXD, BuyCallMixin):
    method _init_self (line 26) | def _init_self(self, **kwargs):
    method fit_month (line 37) | def fit_month(self, today):
    method fit_day (line 65) | def fit_day(self, today):
  class AbuTwoDayBuy (line 76) | class AbuTwoDayBuy(AbuFactorBuyTD, BuyCallMixin):
    method _init_self (line 79) | def _init_self(self, **kwargs):
    method fit_day (line 83) | def fit_day(self, today):
  class AbuWeekMonthBuy (line 100) | class AbuWeekMonthBuy(AbuFactorBuyBase, BuyCallMixin):
    method _init_self (line 103) | def _init_self(self, **kwargs):
    method fit_day (line 107) | def fit_day(self, today):
  class AbuFactorBuyBreakUmpDemo (line 116) | class AbuFactorBuyBreakUmpDemo(AbuFactorBuyBreak):
    method make_ump_block_decision (line 119) | def make_ump_block_decision(self, ml_feature_dict):
  class AbuFactorBuyBreakReocrdHitDemo (line 141) | class AbuFactorBuyBreakReocrdHitDemo(AbuFactorBuyBreak):
    method make_ump_block_decision (line 144) | def make_ump_block_decision(self, ml_feature_dict):
  class AbuFactorBuyBreakHitPredictDemo (line 168) | class AbuFactorBuyBreakHitPredictDemo(AbuFactorBuyBreak):
    method _init_self (line 176) | def _init_self(self, **kwargs):
    method make_ump_block_decision (line 185) | def make_ump_block_decision(self, ml_feature_dict):
  class AbuBTCDayBuy (line 210) | class AbuBTCDayBuy(AbuFactorBuyBase, BuyCallMixin):
    method _init_self (line 218) | def _init_self(self, **kwargs):
    method fit_day (line 238) | def fit_day(self, today):
    method make_btc_today (line 261) | def make_btc_today(self, sib_btc):
    method similar_predict (line 312) | def similar_predict(self, today_date):

FILE: abupy/FactorBuyBu/ABuFactorBuyTrend.py
  class AbuUpDownTrend (line 19) | class AbuUpDownTrend(AbuFactorBuyXD, BuyCallMixin):
    method _init_self (line 22) | def _init_self(self, **kwargs):
    method fit_day (line 37) | def fit_day(self, today):
  class AbuUpDownGolden (line 57) | class AbuUpDownGolden(AbuUpDownTrend, BuyCallMixin):
    method fit_day (line 60) | def fit_day(self, today):
  class AbuDownUpTrend (line 83) | class AbuDownUpTrend(AbuFactorBuyXD, BuyCallMixin):
    method _init_self (line 86) | def _init_self(self, **kwargs):
    method fit_day (line 102) | def fit_day(self, today):

FILE: abupy/FactorBuyBu/ABuFactorBuyWD.py
  class AbuFactorBuyWD (line 16) | class AbuFactorBuyWD(AbuFactorBuyTD, BuyCallMixin):
    method _init_self (line 25) | def _init_self(self, **kwargs):
    method fit_month (line 42) | def fit_month(self, today):
    method fit_day (line 48) | def fit_day(self, today):
    method _make_buy_date (line 57) | def _make_buy_date(self, last_kl):

FILE: abupy/FactorSellBu/ABuFactorAtrNStop.py
  class AbuFactorAtrNStop (line 16) | class AbuFactorAtrNStop(AbuFactorSellBase):
    method _init_self (line 19) | def _init_self(self, **kwargs):
    method support_direction (line 37) | def support_direction(self):
    method fit_day (line 41) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorCloseAtrNStop.py
  class AbuFactorCloseAtrNStop (line 21) | class AbuFactorCloseAtrNStop(AbuFactorSellBase):
    method _init_self (line 24) | def _init_self(self, **kwargs):
    method support_direction (line 33) | def support_direction(self):
    method fit_day (line 37) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorPreAtrNStop.py
  class AbuFactorPreAtrNStop (line 20) | class AbuFactorPreAtrNStop(AbuFactorSellBase):
    method _init_self (line 23) | def _init_self(self, **kwargs):
    method support_direction (line 32) | def support_direction(self):
    method fit_day (line 36) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorSellBase.py
  class ESupportDirection (line 25) | class ESupportDirection(Enum):
  class AbuFactorSellBase (line 31) | class AbuFactorSellBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    method __init__ (line 38) | def __init__(self, capital, kl_pd, combine_kl_pd, benchmark, **kwargs):
    method __str__ (line 67) | def __str__(self):
    method read_fit_day (line 73) | def read_fit_day(self, today, orders):
    method sell_tomorrow (line 95) | def sell_tomorrow(self, order):
    method sell_today (line 103) | def sell_today(self, order):
    method _init_self (line 112) | def _init_self(self, **kwargs):
    method fit_day (line 117) | def fit_day(self, today, orders):
    method support_direction (line 122) | def support_direction(self):
    method make_sell_order (line 126) | def make_sell_order(self, order, day_ind):
    method make_ump_block_decision (line 150) | def make_ump_block_decision(self, ml_feature_dict):
    method make_sell_order_ml_feature (line 161) | def make_sell_order_ml_feature(self, day_ind):
  class AbuFactorSellXD (line 177) | class AbuFactorSellXD(AbuFactorSellBase):
    method _init_self (line 180) | def _init_self(self, **kwargs):
    method read_fit_day (line 187) | def read_fit_day(self, today, orders):
    method support_direction (line 206) | def support_direction(self):
    method fit_day (line 210) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorSellBreak.py
  class AbuFactorSellBreak (line 16) | class AbuFactorSellBreak(AbuFactorSellBase):
    method _init_self (line 19) | def _init_self(self, **kwargs):
    method support_direction (line 27) | def support_direction(self):
    method fit_day (line 31) | def fit_day(self, today, orders):
  class AbuFactorSellXDBK (line 43) | class AbuFactorSellXDBK(AbuFactorSellXD):
    method support_direction (line 46) | def support_direction(self):
    method fit_day (line 50) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorSellDM.py
  class AbuDoubleMaSell (line 17) | class AbuDoubleMaSell(AbuFactorSellXD):
    method _init_self (line 20) | def _init_self(self, **kwargs):
    method support_direction (line 41) | def support_direction(self):
    method fit_day (line 45) | def fit_day(self, today, orders):

FILE: abupy/FactorSellBu/ABuFactorSellNDay.py
  class AbuFactorSellNDay (line 16) | class AbuFactorSellNDay(AbuFactorSellBase):
    method _init_self (line 19) | def _init_self(self, **kwargs):
    method support_direction (line 25) | def support_direction(self):
    method fit_day (line 29) | def fit_day(self, today, orders):

FILE: abupy/IndicatorBu/ABuNDAtr.py
  function _calc_atr_from_ta (line 30) | def _calc_atr_from_ta(high, low, close, time_period=14):
  function _calc_atr_from_pd (line 51) | def _calc_atr_from_pd(high, low, close, time_period=14):
  function atr14 (line 91) | def atr14(high, low, close):
  function atr21 (line 103) | def atr21(high, low, close):
  function atr14_min (line 115) | def atr14_min(high, low, close):
  function atr14_max (line 130) | def atr14_max(high, low, close):
  function atr21_min (line 145) | def atr21_min(high, low, close):
  function atr21_max (line 160) | def atr21_max(high, low, close):
  function plot_atr_from_klpd (line 175) | def plot_atr_from_klpd(kl_pd, with_points=None, with_points_ext=None, **...
  function plot_atr_from_order (line 187) | def plot_atr_from_order(order, date_ext=120, **kwargs):
  function plot_atr (line 197) | def plot_atr(high, low, close, kl_index, with_points=None, with_points_e...

FILE: abupy/IndicatorBu/ABuNDBase.py
  class ECalcType (line 21) | class ECalcType(Enum):
  function plot_from_order (line 43) | def plot_from_order(plot_nd_func, order, date_ext, **kwargs):

FILE: abupy/IndicatorBu/ABuNDBoll.py
  function _calc_boll_from_ta (line 30) | def _calc_boll_from_ta(prices, time_period=20, nb_dev=2):
  function _calc_boll_from_pd (line 52) | def _calc_boll_from_pd(prices, time_period=20, nb_dev=2):
  function plot_boll_from_klpd (line 77) | def plot_boll_from_klpd(kl_pd, with_points=None, with_points_ext=None, *...
  function plot_boll_from_order (line 88) | def plot_boll_from_order(order, date_ext=120, **kwargs):
  function plot_boll (line 98) | def plot_boll(prices, kl_index, with_points=None, with_points_ext=None, ...

FILE: abupy/IndicatorBu/ABuNDMa.py
  class EMACalcType (line 28) | class EMACalcType(Enum):
  function _calc_ma_from_ta (line 37) | def _calc_ma_from_ta(prices, time_period=10, from_calc=EMACalcType.E_MA_...
  function _calc_ma_from_pd (line 56) | def _calc_ma_from_pd(prices, time_period=10, from_calc=EMACalcType.E_MA_...
  function calc_ma_from_prices (line 74) | def calc_ma_from_prices(prices, time_period=10, min_periods=None, from_c...
  function plot_ma_from_order (line 98) | def plot_ma_from_order(order, date_ext=120, **kwargs):
  function plot_ma_from_klpd (line 108) | def plot_ma_from_klpd(kl_pd, with_points=None, with_points_ext=None, **k...
  function plot_ma (line 123) | def plot_ma(prices, kl_index, time_period, from_calc=EMACalcType.E_MA_MA,

FILE: abupy/IndicatorBu/ABuNDMacd.py
  function _calc_macd_from_ta (line 30) | def _calc_macd_from_ta(price, fast_period=12, slow_period=26, signal_per...
  function _calc_macd_from_pd (line 50) | def _calc_macd_from_pd(price, fast_period=12, slow_period=26, signal_per...
  function plot_macd_from_klpd (line 78) | def plot_macd_from_klpd(kl_pd, with_points=None, with_points_ext=None, *...
  function plot_macd_from_order (line 89) | def plot_macd_from_order(order, date_ext=120, **kwargs):
  function plot_macd (line 99) | def plot_macd(prices, kl_index, with_points=None, with_points_ext=None,

FILE: abupy/IndicatorBu/ABuNDRsi.py
  function _calc_rsi_from_ta (line 36) | def _calc_rsi_from_ta(prices, time_period=14):
  function _calc_rsi_from_pd (line 51) | def _calc_rsi_from_pd(prices, time_period=14):
  function plot_rsi_from_order (line 86) | def plot_rsi_from_order(order, date_ext=120, **kwargs):
  function plot_rsi_from_klpd (line 96) | def plot_rsi_from_klpd(kl_pd, with_points=None, with_points_ext=None, **...
  function plot_rsi (line 109) | def plot_rsi(prices, kl_index, with_points=None, with_points_ext=None, w...

FILE: abupy/MLBu/ABuML.py
  class _EMLScoreType (line 41) | class _EMLScoreType(Enum):
  class EMLFitType (line 52) | class EMLFitType(Enum):
  function entry_wrapper (line 70) | def entry_wrapper(support=(EMLFitType.E_FIT_CLF, EMLFitType.E_FIT_REG, E...
  class AbuML (line 115) | class AbuML(object):
    method create_test_fiter (line 119) | def create_test_fiter(cls):
    method load_ttn_raw_df (line 174) | def load_ttn_raw_df(cls):
    method create_test_more_fiter (line 188) | def create_test_more_fiter(cls):
    method __init__ (line 341) | def __init__(self, x, y, df, fiter_type=EMLFitType.E_FIT_AUTO):
    method is_supervised_learning (line 362) | def is_supervised_learning(self):
    method echo_info (line 370) | def echo_info(self, fiter=None):
    method get_fiter (line 399) | def get_fiter(self):
    method cross_val_accuracy_score (line 445) | def cross_val_accuracy_score(self, cv=10, **kwargs):
    method cross_val_prob_accuracy_score (line 463) | def cross_val_prob_accuracy_score(self, pb_threshold, cv=10, show=True...
    method cross_val_silhouette_score (line 696) | def cross_val_silhouette_score(self, cv=10, **kwargs):
    method cross_val_mean_squared_score (line 720) | def cross_val_mean_squared_score(self, cv=10, **kwargs):
    method cross_val_roc_auc_score (line 739) | def cross_val_roc_auc_score(self, cv=10, **kwargs):
    method feature_selection (line 759) | def feature_selection(self, show=True, **kwargs):
    method importances_coef_pd (line 831) | def importances_coef_pd(self, **kwargs):
    method train_test_split_xy (line 896) | def train_test_split_xy(self, test_size=0.1, random_state=0, **kwargs):
    method train_test_split_df (line 967) | def train_test_split_df(self, test_size=0.1, random_state=0, **kwargs):
    method fit (line 983) | def fit(self, **kwargs):
    method fit_transform (line 1014) | def fit_transform(self, **kwargs):
    method predict (line 1048) | def predict(self, x, pre_fit=True, **kwargs):
    method predict_proba (line 1075) | def predict_proba(self, x, pre_fit=True, **kwargs):
    method predict_proba_threshold (line 1102) | def predict_proba_threshold(self, x, threshold, default_ret, pre_fit=T...
    method _predict_callback (line 1162) | def _predict_callback(self, callback, x, pre_fit=True, **kwargs):
    method search_match_neg_threshold (line 1200) | def search_match_neg_threshold(self, accuracy_match=0, effect_rate_mat...
    method search_match_pos_threshold (line 1244) | def search_match_pos_threshold(self, accuracy_match=0, effect_rate_mat...
    method plot_learning_curve (line 1288) | def plot_learning_curve(self, **kwargs):
    method plot_graphviz_tree (line 1312) | def plot_graphviz_tree(self, **kwargs):
    method plot_visualize_tree (line 1346) | def plot_visualize_tree(self, use_pca=True, **kwargs):
    method plot_decision_function (line 1370) | def plot_decision_function(self, use_pca=True, **kwargs):
    method plot_roc_estimator (line 1394) | def plot_roc_estimator(self, pos_label=None, **kwargs):
    method plot_confusion_matrices (line 1414) | def plot_confusion_matrices(self, **kwargs):
    method bagging_classifier_best (line 1434) | def bagging_classifier_best(self, **kwargs):
    method bagging_regressor_best (line 1460) | def bagging_regressor_best(self, **kwargs):
    method adaboost_regressor_best (line 1485) | def adaboost_regressor_best(self, **kwargs):
    method adaboost_classifier_best (line 1511) | def adaboost_classifier_best(self, **kwargs):
    method random_forest_classifier_best (line 1538) | def random_forest_classifier_best(self, **kwargs):
    method random_forest_regressor_best (line 1565) | def random_forest_regressor_best(self, **kwargs):
    method xgb_classifier_best (line 1593) | def xgb_classifier_best(self, **kwargs):
    method xgb_regressor_best (line 1619) | def xgb_regressor_best(self, **kwargs):
    method decision_tree_classifier_best (line 1647) | def decision_tree_classifier_best(self, **kwargs):
    method decision_tree_regressor_best (line 1673) | def decision_tree_regressor_best(self, **kwargs):
    method knn_classifier_best (line 1699) | def knn_classifier_best(self, **kwargs):
    method _confusion_matrix_with_report (line 1725) | def _confusion_matrix_with_report(self, y_true, y_predict, labels=None):
    method _decomposition_2x (line 1751) | def _decomposition_2x(self, x, use_pca):
    method _do_cross_val_score (line 1813) | def _do_cross_val_score(self, x, y, cv, scoring):

FILE: abupy/MLBu/ABuMLBinsCs.py
  function show_orders_hist (line 22) | def show_orders_hist(df, feature_columns, show=True, only_hist=True, sho...

FILE: abupy/MLBu/ABuMLCreater.py
  class AbuMLCreater (line 57) | class AbuMLCreater(object):
    method __init__ (line 60) | def __init__(self):
    method __str__ (line 78) | def __str__(self):
    method pca_decomposition (line 85) | def pca_decomposition(self, assign=True, **kwargs):
    method kmean_cluster (line 105) | def kmean_cluster(self, assign=True, **kwargs):
    method hmm_gaussian (line 124) | def hmm_gaussian(self, assign=True, **kwargs):
    method _estimators_prarms_best (line 151) | def _estimators_prarms_best(self, create_func, x, y, param_grid, assig...
    method bagging_classifier (line 184) | def bagging_classifier(self, assign=True, base_estimator=DecisionTreeC...
    method bagging_classifier_best (line 211) | def bagging_classifier_best(self, x, y, param_grid=None, assign=True, ...
    method bagging_regressor (line 241) | def bagging_regressor(self, assign=True, base_estimator=DecisionTreeRe...
    method bagging_regressor_best (line 269) | def bagging_regressor_best(self, x, y, param_grid=None, assign=True, n...
    method adaboost_regressor (line 299) | def adaboost_regressor(self, assign=True, base_estimator=DecisionTreeR...
    method adaboost_regressor_best (line 326) | def adaboost_regressor_best(self, x, y, param_grid=None, assign=True, ...
    method adaboost_classifier (line 358) | def adaboost_classifier(self, assign=True, base_estimator=DecisionTree...
    method adaboost_classifier_best (line 383) | def adaboost_classifier_best(self, x, y, param_grid=None, assign=True,...
    method xgb_regressor (line 415) | def xgb_regressor(self, assign=True, **kwargs):
    method xgb_regressor_best (line 442) | def xgb_regressor_best(self, x, y, param_grid=None, assign=True, n_job...
    method xgb_classifier (line 474) | def xgb_classifier(self, assign=True, **kwargs):
    method xgb_classifier_best (line 503) | def xgb_classifier_best(self, x, y, param_grid=None, assign=True, n_jo...
    method random_forest_regressor (line 534) | def random_forest_regressor(self, assign=True, **kwargs):
    method random_forest_regressor_best (line 556) | def random_forest_regressor_best(self, x, y, param_grid=None, assign=T...
    method random_forest_classifier (line 587) | def random_forest_classifier(self, assign=True, **kwargs):
    method random_forest_classifier_best (line 609) | def random_forest_classifier_best(self, x, y, param_grid=None, assign=...
    method svc (line 640) | def svc(self, assign=True, **kwargs):
    method decision_tree_regressor (line 662) | def decision_tree_regressor(self, assign=True, **kwargs):
    method decision_tree_regressor_best (line 685) | def decision_tree_regressor_best(self, x, y, param_grid=None, assign=T...
    method decision_tree_classifier (line 717) | def decision_tree_classifier(self, assign=True, **kwargs):
    method decision_tree_classifier_best (line 740) | def decision_tree_classifier_best(self, x, y, param_grid=None, assign=...
    method knn_classifier (line 772) | def knn_classifier(self, assign=True, **kwargs):
    method knn_classifier_best (line 795) | def knn_classifier_best(self, x, y, param_grid=None, assign=True, n_jo...
    method logistic_classifier (line 827) | def logistic_classifier(self, assign=True, **kwargs):
    method linear_regression (line 849) | def linear_regression(self, assign=True, **kwargs):
    method polynomial_regression (line 871) | def polynomial_regression(self, assign=True, degree=2, **kwargs):
    method onevsone_classifier (line 888) | def onevsone_classifier(self, assign=False, **kwargs):
    method onevsreset_classifier (line 904) | def onevsreset_classifier(self, assign=False, **kwargs):

FILE: abupy/MLBu/ABuMLExecute.py
  function run_silhouette_cv_estimator (line 43) | def run_silhouette_cv_estimator(estimator, x, n_folds=10):
  function run_prob_cv_estimator (line 77) | def run_prob_cv_estimator(estimator, x, y, n_folds=10):
  function run_cv_estimator (line 130) | def run_cv_estimator(estimator, x, y, n_folds=10):
  function plot_learning_curve (line 173) | def plot_learning_curve(estimator, x, y, cv=5, n_jobs=1,
  function graphviz_tree (line 259) | def graphviz_tree(estimator, features, x, y):
  function visualize_tree (line 305) | def visualize_tree(estimator, x, y, boundaries=True):
  function plot_decision_boundary (line 383) | def plot_decision_boundary(pred_func, x, y):
  function plot_roc_estimator (line 414) | def plot_roc_estimator(estimator, x, y, pos_label=None):
  function plot_confusion_matrices (line 521) | def plot_confusion_matrices(estimator, x, y, n_folds=10):

FILE: abupy/MLBu/ABuMLGrid.py
  function _scoring_grid (line 31) | def _scoring_grid(estimator, scoring):
  function grid_search_init_kwargs (line 63) | def grid_search_init_kwargs(estimator, x, y, param_name, param_range, cv...
  function grid_search_mul_init_kwargs (line 151) | def grid_search_mul_init_kwargs(estimator, x, y, param_grid, cv=10, n_jo...
  function grid_search_init_n_estimators (line 256) | def grid_search_init_n_estimators(estimator, x, y, n_estimators_range=No...
  function grid_search_init_max_depth (line 291) | def grid_search_init_max_depth(estimator, x, y, max_depth_range=None, cv...
  function grid_search_init_n_neighbors (line 322) | def grid_search_init_n_neighbors(estimator, x, y, n_neighbors_range=None...
  function grid_search_init_n_components (line 354) | def grid_search_init_n_components(estimator, x, y, n_components_range=No...

FILE: abupy/MLBu/ABuMLPd.py
  class AbuMLPd (line 24) | class AbuMLPd(six.with_metaclass(ABCMeta, object)):
    method __init__ (line 27) | def __init__(self, **kwarg):
    method make_xy (line 42) | def make_xy(self, **kwarg):
    method __getattr__ (line 50) | def __getattr__(self, item):
    method __call__ (line 61) | def __call__(self):
  class ClosePredict (line 70) | class ClosePredict(AbuMLPd):
    method make_xy (line 79) | def make_xy(self, **kwarg):
  function test_close_predict (line 107) | def test_close_predict():
  class BtcBigWaveClf (line 158) | class BtcBigWaveClf(AbuMLPd):
    method __init__ (line 164) | def __init__(self, **kwarg):
    method make_xy (line 172) | def make_xy(self, **kwarg):
    method btc_siblings_df (line 240) | def btc_siblings_df(self, btc_raw):

FILE: abupy/MarketBu/ABuDataBase.py
  class SupportMixin (line 19) | class SupportMixin(object):
    method _support_market (line 22) | def _support_market(self):
    method check_support (line 27) | def check_support(self, symbol=None, rs=True):
  class BaseMarket (line 59) | class BaseMarket(object):
    method __init__ (line 70) | def __init__(self, symbol):
    method req_time (line 80) | def req_time(self):
    method _fix_kline_pd_se (line 86) | def _fix_kline_pd_se(cls, kl_df, n_folds, start=None, end=None):
    method _fix_kline_pd_zero (line 114) | def _fix_kline_pd_zero(cls, kl_df):
  class StockBaseMarket (line 145) | class StockBaseMarket(six.with_metaclass(ABCMeta, BaseMarket)):
    method minute (line 149) | def minute(self, *args, **kwargs):
    method kline (line 154) | def kline(self, n_folds=2, start=None, end=None):
    method _fix_kline_pd (line 159) | def _fix_kline_pd(cls, kl_df, n_folds, start=None, end=None):
  class FuturesBaseMarket (line 164) | class FuturesBaseMarket(six.with_metaclass(ABCMeta, BaseMarket)):
    method kline (line 168) | def kline(self, n_folds=2, start=None, end=None):
    method _fix_kline_pd (line 173) | def _fix_kline_pd(cls, kl_df, n_folds, start=None, end=None):
  class TCBaseMarket (line 180) | class TCBaseMarket(six.with_metaclass(ABCMeta, BaseMarket)):
    method kline (line 184) | def kline(self, n_folds=2, start=None, end=None):
    method minute (line 189) | def minute(self, *args, **kwargs):
    method _fix_kline_pd (line 194) | def _fix_kline_pd(cls, kl_df, n_folds, start=None, end=None):

FILE: abupy/MarketBu/ABuDataCache.py
  class HDF5ExtError (line 25) | class HDF5ExtError(RuntimeError):
  function _kl_unique_key (line 33) | def _kl_unique_key(symbol, start, end):
  function rm_data_from_symbol (line 44) | def rm_data_from_symbol(symbol):
  function load_all_kline (line 64) | def load_all_kline(want_df=True, market=None, all_market=False):
  function covert_hdf_to_csv (line 111) | def covert_hdf_to_csv():
  function load_kline_df (line 133) | def load_kline_df(symbol_key):
  function _load_kline_csv (line 175) | def _load_kline_csv(date_key):
  function _load_kline_hdf5 (line 192) | def _load_kline_hdf5(date_key):
  function check_csv_local (line 201) | def check_csv_local(symbol_key):
  function _load_csv_key (line 211) | def _load_csv_key(symbol_key):
  function _load_hdf5_key (line 235) | def _load_hdf5_key(symbol_key):
  function dump_kline_df (line 246) | def dump_kline_df(dump_df, symbol_key, date_key):
  function _dump_kline_csv (line 343) | def _dump_kline_csv(symbol_key, date_key, dump_df, delete_key=None):
  function _dump_kline_hdf5 (line 363) | def _dump_kline_hdf5(symbol_key, date_key, dump_df, delete_key=None):
  function save_kline_df (line 386) | def save_kline_df(df, temp_symbol, start_int, end_int):
  function load_kline_df_net (line 401) | def load_kline_df_net(source, temp_symbol, n_folds, start, end, start_in...

FILE: abupy/MarketBu/ABuDataCheck.py
  function browser_down_csv_zip (line 28) | def browser_down_csv_zip(open_browser=False):
  function check_symbol_data_mode (line 45) | def check_symbol_data_mode(choice_symbols):
  function check_symbol_data (line 110) | def check_symbol_data(choice_symbols):
  function all_market_env_check (line 159) | def all_market_env_check():

FILE: abupy/MarketBu/ABuDataFeed.py
  function random_from_list (line 36) | def random_from_list(array):
  function query_symbol_sub_market (line 43) | def query_symbol_sub_market(symbol):
  function query_symbol_from_pinyin (line 64) | def query_symbol_from_pinyin(pinyin):
  class BDApi (line 85) | class BDApi(StockBaseMarket, SupportMixin):
    method __init__ (line 97) | def __init__(self, symbol):
    method kline (line 106) | def kline(self, n_folds=2, start=None, end=None):
    method minute (line 144) | def minute(self, n_folds=5, *args, **kwargs):
  class TXApi (line 154) | class TXApi(StockBaseMarket, SupportMixin):
    method __init__ (line 171) | def __init__(self, symbol):
    method kline (line 179) | def kline(self, n_folds=2, start=None, end=None):
    method hkmoney (line 234) | def hkmoney(self):
    method minute (line 250) | def minute(self, n_fold=5, *args, **kwargs):
  class NTApi (line 255) | class NTApi(StockBaseMarket, SupportMixin):
    method __init__ (line 260) | def __init__(self, symbol):
    method kline (line 268) | def kline(self, n_folds=2, start=None, end=None):
    method minute (line 311) | def minute(self, n_fold=5, *args, **kwargs):
  class SNUSApi (line 316) | class SNUSApi(StockBaseMarket, SupportMixin):
    method __init__ (line 321) | def __init__(self, symbol):
    method _support_market (line 329) | def _support_market(self):
    method kline (line 333) | def kline(self, n_folds=2, start=None, end=None):
    method minute (line 342) | def minute(self, n_fold=5, *args, **kwargs):
  class SNFuturesApi (line 347) | class SNFuturesApi(FuturesBaseMarket, SupportMixin):
    method __init__ (line 353) | def __init__(self, symbol):
    method _support_market (line 361) | def _support_market(self):
    method kline (line 365) | def kline(self, n_folds=2, start=None, end=None):
  class SNFuturesGBApi (line 375) | class SNFuturesGBApi(FuturesBaseMarket, SupportMixin):
    method __init__ (line 381) | def __init__(self, symbol):
    method _support_market (line 389) | def _support_market(self):
    method kline (line 393) | def kline(self, n_folds=2, start=None, end=None):
  class HBApi (line 407) | class HBApi(TCBaseMarket, SupportMixin):
    method __init__ (line 412) | def __init__(self, symbol):
    method _support_market (line 420) | def _support_market(self):
    method kline (line 424) | def kline(self, n_folds=2, start=None, end=None):
    method minute (line 440) | def minute(self, *args, **kwargs):

FILE: abupy/MarketBu/ABuDataParser.py
  function del_columns (line 23) | def del_columns(df, columns):
  class AbuDataParseWrap (line 35) | class AbuDataParseWrap(object):
    method __call__ (line 40) | def __call__(self, cls):
    method _gen_warp_df (line 70) | def _gen_warp_df(self, warp_self, symbol):
  class TXParser (line 122) | class TXParser(object):
    method __init__ (line 125) | def __init__(self, symbol, sub_market, json_dict):
  class NTParser (line 159) | class NTParser(object):
    method __init__ (line 163) | def __init__(self, symbol, json_dict):
  class SNUSParser (line 186) | class SNUSParser(object):
    method __init__ (line 190) | def __init__(self, symbol, json_dict):
  class SNFuturesParser (line 213) | class SNFuturesParser(object):
    method __init__ (line 217) | def __init__(self, symbol, json_dict):
  class SNFuturesGBParser (line 240) | class SNFuturesGBParser(object):
    method __init__ (line 243) | def __init__(self, symbol, json_dict):
  class HBTCParser (line 266) | class HBTCParser(object):
    method __init__ (line 270) | def __init__(self, symbol, json_dict):
  class BDParser (line 296) | class BDParser(object):
    method __init__ (line 302) | def __init__(self, symbol, json_dict):

FILE: abupy/MarketBu/ABuDataSource.py
  class HDF5ExtError (line 28) | class HDF5ExtError(RuntimeError):
  function _calc_start_end_date (line 43) | def _calc_start_end_date(df, force_local, n_folds, start, end):
  function kline_pd (line 100) | def kline_pd(symbol, data_mode, n_folds=2, start=None, end=None, save=Tr...

FILE: abupy/MarketBu/ABuHkUnit.py
  class AbuHkUnit (line 31) | class AbuHkUnit(FreezeAttrMixin):
    method __init__ (line 34) | def __init__(self):
    method query_unit (line 50) | def query_unit(self, symbol):
    method __str__ (line 70) | def __str__(self):
    method __len__ (line 77) | def __len__(self):
    method __contains__ (line 81) | def __contains__(self, item):
    method __getitem__ (line 93) | def __getitem__(self, key):
    method __setitem__ (line 97) | def __setitem__(self, key, value):

FILE: abupy/MarketBu/ABuIndustries.py
  function industries_df (line 26) | def industries_df(target_symbol):
  function industries_factorize (line 52) | def industries_factorize(market=None):
  function industries_market (line 117) | def industries_market(market=None):
  function match_industries_factorize (line 142) | def match_industries_factorize(match, market=None):
  function query_match_industries_df (line 208) | def query_match_industries_df(match, market=None):
  function query_factorize_industry_df (line 233) | def query_factorize_industry_df(factorize_arr, market=None):
  function query_factorize_industry_symbol (line 298) | def query_factorize_industry_symbol(factorize, market=None):
  function query_match_industries_symbol (line 355) | def query_match_industries_symbol(match, market=None):
  function get_industries_panel_from_target (line 388) | def get_industries_panel_from_target(target_symbol, show=False, n_folds=2):

FILE: abupy/MarketBu/ABuMarket.py
  class MarketMixin (line 47) | class MarketMixin(object):
    method _symbol (line 55) | def _symbol(self):
    method symbol_market (line 64) | def symbol_market(self):
    method symbol_sub_market (line 69) | def symbol_sub_market(self):
  function split_k_market (line 74) | def split_k_market(k_split, market_symbols=None, market=None):
  function choice_symbols (line 105) | def choice_symbols(count, market_symbols=None, market=None):
  function choice_symbols_with_replace (line 123) | def choice_symbols_with_replace(count, market_symbols=None, market=None):
  function _all_us_symbol (line 140) | def _all_us_symbol(index=False):
  function _all_cn_symbol (line 153) | def _all_cn_symbol(index=False):
  function _all_hk_symbol (line 165) | def _all_hk_symbol(index=False):
  function _all_futures_cn (line 177) | def _all_futures_cn():
  function _all_futures_gb (line 185) | def _all_futures_gb():
  function _all_tc_symbol (line 193) | def _all_tc_symbol():
  function all_symbol (line 201) | def all_symbol(market=None, ss=False, index=False, value=True):
  function query_symbol_market (line 243) | def query_symbol_market(target_symbol):
  function market_train_test_split (line 266) | def market_train_test_split(n_folds, market_symbols, market=None):
  function market_last_split_test (line 302) | def market_last_split_test(market=None):
  function market_last_split_train (line 321) | def market_last_split_train(market=None):
  function _do_market_train_test_split (line 340) | def _do_market_train_test_split(n_folds=10, market_symbols=None, shuffle...
  function is_in_sand_box (line 376) | def is_in_sand_box(symbol):
  function _parse_code (line 400) | def _parse_code(line, index):
  function _all_us_symbol_deprecated (line 416) | def _all_us_symbol_deprecated(index=False):
  function _all_cn_symbol_deprecated (line 427) | def _all_cn_symbol_deprecated(index=False):
  function _all_hk_symbol_deprecated (line 438) | def _all_hk_symbol_deprecated(index=False):

FILE: abupy/MarketBu/ABuMarketDrawing.py
  function plot_candle_from_order (line 44) | def plot_candle_from_order(order, date_ext=120, day_sum=False, html_bk=F...
  function plot_candle_from_symbol (line 112) | def plot_candle_from_symbol(target_symbol, n_folds=2, start=None, end=No...
  function plot_candle_form_klpd (line 152) | def plot_candle_form_klpd(kl_pd, day_sum=False, html_bk=False, view_inde...
  function plot_candle_stick (line 169) | def plot_candle_stick(date, p_open, high, low, close, volume, view_index...
  function _do_plot_candle_html (line 194) | def _do_plot_candle_html(date, p_open, high, low, close, symbol, save):
  function _do_plot_candle (line 233) | def _do_plot_candle(date, p_open, high, low, close, volume, view_index, ...
  function save_dir_name (line 353) | def save_dir_name(html=False):
  function plot_simple_multi_stock (line 363) | def plot_simple_multi_stock(multi_kl_pd):
  function plot_simple_two_stock (line 374) | def plot_simple_two_stock(two_stcok_dict):

FILE: abupy/MarketBu/ABuNetWork.py
  function get (line 31) | def get(url, params=None, headers=None, retry=3, **kwargs):
  function post (line 58) | def post(url, params=None, headers=None, retry=3, **kwargs):
  function ast_parse_js (line 79) | def ast_parse_js(js_var):
  function parse_js (line 107) | def parse_js(js_var):

FILE: abupy/MarketBu/ABuSymbol.py
  function code_to_symbol (line 20) | def code_to_symbol(code, rs=True):
  function __search (line 118) | def __search(market_df, search_match, search_code, search_result, match_...
  function _us_search (line 159) | def _us_search(search_match, search_code, search_result):
  function _cn_search (line 165) | def _cn_search(search_match, search_code, search_result):
  function _hk_search (line 171) | def _hk_search(search_match, search_code, search_result):
  function _fcn_search (line 177) | def _fcn_search(search_match, search_code, search_result):
  function _fgb_search (line 184) | def _fgb_search(search_match, search_code, search_result):
  function _tc_search (line 192) | def _tc_search(search_match, search_code, search_result):
  function search_to_symbol_dict (line 199) | def search_to_symbol_dict(search, fast_mode=False):
  class Symbol (line 260) | class Symbol(object):
    method __init__ (line 275) | def __init__(self, market, sub_market, symbol_code):
    method __str__ (line 289) | def __str__(self):
    method __len__ (line 295) | def __len__(self):
    method value (line 301) | def value(self):
    method is_a_stock (line 312) | def is_a_stock(self):
    method is_sh_stock (line 316) | def is_sh_stock(self):
    method is_sz_stock (line 320) | def is_sz_stock(self):
    method is_us_stock (line 324) | def is_us_stock(self):
    method is_us_n_stock (line 328) | def is_us_n_stock(self):
    method is_us_oq_stock (line 332) | def is_us_oq_stock(self):
    method is_hk_stock (line 336) | def is_hk_stock(self):
    method is_sh_index (line 340) | def is_sh_index(self):
    method is_sz_index (line 344) | def is_sz_index(self):
    method is_a_index (line 348) | def is_a_index(self):
    method is_us_index (line 352) | def is_us_index(self):
    method is_hk_index (line 356) | def is_hk_index(self):
    method is_index (line 360) | def is_index(self):
    method is_futures (line 364) | def is_futures(self):
    method is_tc (line 369) | def is_tc(self):
  class IndexSymbol (line 374) | class IndexSymbol(object):

FILE: abupy/MarketBu/ABuSymbolFutures.py
  class AbuFuturesCn (line 32) | class AbuFuturesCn(FreezeAttrMixin):
    method __init__ (line 35) | def __init__(self):
    method __str__ (line 60) | def __str__(self):
    method __len__ (line 67) | def __len__(self):
    method __contains__ (line 71) | def __contains__(self, item):
    method __getitem__ (line 75) | def __getitem__(self, key):
    method __setitem__ (line 86) | def __setitem__(self, key, value):
    method query_symbol (line 90) | def query_symbol(self, symbol):
    method query_min_unit (line 110) | def query_min_unit(self, symbol):
    method symbol (line 123) | def symbol(self):
    method product (line 128) | def product(self):
    method min_deposit (line 133) | def min_deposit(self):
    method min_unit (line 138) | def min_unit(self):
    method commission (line 143) | def commission(self):
    method exchange (line 148) | def exchange(self):
  class AbuFuturesGB (line 155) | class AbuFuturesGB(FreezeAttrMixin):
    method __init__ (line 158) | def __init__(self):
    method __str__ (line 175) | def __str__(self):
    method __len__ (line 182) | def __len__(self):
    method __contains__ (line 186) | def __contains__(self, item):
    method __getitem__ (line 190) | def __getitem__(self, key):
    method __setitem__ (line 202) | def __setitem__(self, key, value):
    method query_symbol (line 206) | def query_symbol(self, symbol):
    method query_min_unit (line 217) | def query_min_unit(self, symbol):
    method symbol (line 230) | def symbol(self):
    method product (line 235) | def product(self):
    method min_deposit (line 240) | def min_deposit(self):
    method min_unit (line 245) | def min_unit(self):
    method exchange (line 250) | def exchange(self):

FILE: abupy/MarketBu/ABuSymbolPd.py
  function _benchmark (line 38) | def _benchmark(df, benchmark, symbol):
  function _make_kl_df (line 108) | def _make_kl_df(symbol, data_mode, n_folds, start, end, benchmark, save):
  function _kl_df_dict_parallel (line 144) | def _kl_df_dict_parallel(choice_symbols, data_mode, n_folds, start, end,...
  function kl_df_dict_parallel (line 172) | def kl_df_dict_parallel(symbols, data_mode=ABuEnv.EMarketDataSplitMode.E...
  function make_kl_df (line 246) | def make_kl_df(symbol, data_mode=ABuEnv.EMarketDataSplitMode.E_DATA_SPLI...
  function get_price (line 312) | def get_price(symbol, start_date=None, end_date=None):
  function check_symbol_in_local_csv (line 327) | def check_symbol_in_local_csv(symbol):
  function combine_pre_kl_pd (line 348) | def combine_pre_kl_pd(kl_pd, n_folds=1):
  function calc_atr (line 370) | def calc_atr(kline_df):
  function get_n_year (line 390) | def get_n_year(kl_pd, from_year, get_year=1, how='ff'):

FILE: abupy/MarketBu/ABuSymbolStock.py
  class AbuStockBaseWrap (line 34) | class AbuStockBaseWrap(object):
    method __call__ (line 37) | def __call__(self, cls):
  class AbuSymbolStockBase (line 75) | class AbuSymbolStockBase(FreezeAttrMixin):
    method __str__ (line 78) | def __str__(self):
    method __len__ (line 85) | def __len__(self):
    method __setitem__ (line 89) | def __setitem__(self, key, value):
    method query_industry_symbols (line 93) | def query_industry_symbols(self, query_symbol, local_df=True):
    method query_industry_factorize (line 111) | def query_industry_factorize(self, factorize, local_df=True):
    method all_symbol (line 123) | def all_symbol(self, index=False):
    method query_symbol_sub_market (line 131) | def query_symbol_sub_market(self, *args, **kwargs):
    method symbol_func (line 138) | def symbol_func(self, df):
  class AbuSymbolCN (line 149) | class AbuSymbolCN(AbuSymbolStockBase):
    method __init__ (line 152) | def __init__(self):
    method __contains__ (line 156) | def __contains__(self, item):
    method __getitem__ (line 160) | def __getitem__(self, key):
    method symbol_func (line 185) | def symbol_func(self, df):
    method all_symbol (line 195) | def all_symbol(self, index=False):
    method query_symbol_sub_market (line 213) | def query_symbol_sub_market(self, code, default=EMarketSubType.SH.value):
  class AbuSymbolUS (line 234) | class AbuSymbolUS(AbuSymbolStockBase):
    method __init__ (line 243) | def __init__(self):
    method __contains__ (line 247) | def __contains__(self, item):
    method __getitem__ (line 251) | def __getitem__(self, key):
    method symbol_func (line 268) | def symbol_func(self, df):
    method all_symbol (line 277) | def all_symbol(self, index=False):
    method query_symbol_sub_market (line 296) | def query_symbol_sub_market(self, code, default=EMarketSubType.US_N.va...
  class AbuSymbolHK (line 309) | class AbuSymbolHK(AbuSymbolStockBase):
    method __init__ (line 312) | def __init__(self):
    method __contains__ (line 316) | def __contains__(self, item):
    method __getitem__ (line 320) | def __getitem__(self, key):
    method symbol_func (line 336) | def symbol_func(self, df):
    method all_symbol (line 345) | def all_symbol(self, index=False):
    method query_symbol_sub_market (line 361) | def query_symbol_sub_market(self, code, default=EMarketSubType.HK.value):
  function query_stock_info (line 369) | def query_stock_info(symbol):

FILE: abupy/MetricsBu/ABuCrossVal.py
  function cross_val_mul_process (line 35) | def cross_val_mul_process(vc, cv, corr_series, benchmark, buy_factors, s...
  class AbuCrossVal (line 85) | class AbuCrossVal(object):
    method __init__ (line 88) | def __init__(self, market=None, corr_type=ECoreCorrType.E_CORE_TYPE_PE...
    method _find_or_cache_similar (line 99) | def _find_or_cache_similar(self, n_folds, benchmark, enable_cache):
    method _do_cross_corr (line 118) | def _do_cross_corr(self, buy_factors, sell_factors, benchmark, corr_se...
    method fit (line 166) | def fit(self, buy_factors, sell_factors, cv=10, market=None, enable_ca...
    method plot_all_cross_val_orders (line 253) | def plot_all_cross_val_orders(self):
    method show_cross_val_se (line 262) | def show_cross_val_se(self, start=0, end=1):
    method show_cross_val_all (line 278) | def show_cross_val_all(self):

FILE: abupy/MetricsBu/ABuGridHelper.py
  function gen_factor_grid (line 30) | def gen_factor_grid(type_param, factors, need_empty_sell=False):
  function score_pd_plot (line 57) | def score_pd_plot(grid_score_pd, y_key, x_key=None):
  function make_grid_score_pd (line 82) | def make_grid_score_pd(grid_scores, score_index=0):

FILE: abupy/MetricsBu/ABuGridSearch.py
  class ParameterGrid (line 35) | class ParameterGrid(object):
    method __init__ (line 38) | def __init__(self, param_grid):
    method __iter__ (line 43) | def __iter__(self):
    method __len__ (line 55) | def __len__(self):
    method __getitem__ (line 61) | def __getitem__(self, ind):
  function _check_param_grid (line 86) | def _check_param_grid(param_grid):
  function grid_search_mul_process (line 107) | def grid_search_mul_process(read_cash, benchmark, factors, choice_symbol...
  class GridSearch (line 177) | class GridSearch(object):
    method combine_same_factor_class (line 181) | def combine_same_factor_class(cls, factors):
    method show_top_constraints_metrics (line 247) | def show_top_constraints_metrics(cls, constraints, scores, score_tuple...
    method show_top_score_metrics (line 263) | def show_top_score_metrics(cls, scores, score_tuple_array, top_cnt=10):
    method grid_search (line 286) | def grid_search(cls, choice_symbols, buy_factors, sell_factors, read_c...
    method __init__ (line 364) | def __init__(self, read_cash, choice_symbols, stock_pickers_product=None,
    method fit (line 385) | def fit(self, score_class=WrsmScorer, n_jobs=-1):

FILE: abupy/MetricsBu/ABuMetricsBase.py
  function valid_check (line 31) | def valid_check(func):
  class AbuMetricsBase (line 44) | class AbuMetricsBase(object):
    method show_general (line 48) | def show_general(cls, orders_pd, action_pd, capital, benchmark, return...
    method __init__ (line 73) | def __init__(self, orders_pd, action_pd, capital, benchmark, enable_st...
    method fit_metrics (line 97) | def fit_metrics(self):
    method fit_metrics_order (line 110) | def fit_metrics_order(self):
    method _metrics_base_stats (line 114) | def _metrics_base_stats(self):
    method _metrics_sell_stats (line 180) | def _metrics_sell_stats(self):
    method _metrics_action_stats (line 257) | def _metrics_action_stats(self):
    method _metrics_extend_stats (line 306) | def _metrics_extend_stats(self):
    method plot_order_returns_cmp (line 312) | def plot_order_returns_cmp(self, only_info=True):
    method plot_returns_cmp (line 331) | def plot_returns_cmp(self, only_show_returns=False, only_info=False):
    method plot_sharp_volatility_cmp (line 369) | def plot_sharp_volatility_cmp(self, only_info=False):
    method plot_effect_mean_day (line 393) | def plot_effect_mean_day(self):
    method plot_action_buy_cost (line 409) | def plot_action_buy_cost(self):
    method plot_sell_factors (line 422) | def plot_sell_factors(self):
    method plot_buy_factors (line 432) | def plot_buy_factors(self):
    method plot_keep_days (line 443) | def plot_keep_days(self):
    method plot_max_draw_down (line 454) | def plot_max_draw_down(self):
    method transform_to_full_rate_factor (line 505) | def transform_to_full_rate_factor(self, read_cash=-1, kl_pd_manager=No...
  class MetricsDemo (line 540) | class MetricsDemo(AbuMetricsBase):
    method _metrics_extend_stats (line 550) | def _metrics_extend_stats(self):
    method plot_commission (line 586) | def plot_commission(self):

FILE: abupy/MetricsBu/ABuMetricsFutures.py
  class AbuMetricsFutures (line 20) | class AbuMetricsFutures(AbuMetricsBase):
    method _metrics_base_stats (line 23) | def _metrics_base_stats(self):
    method plot_returns_cmp (line 57) | def plot_returns_cmp(self, only_show_returns=False, only_info=False):
    method plot_sharp_volatility_cmp (line 90) | def plot_sharp_volatility_cmp(self, only_info=False):

FILE: abupy/MetricsBu/ABuMetricsScore.py
  class AbuScoreTuple (line 20) | class AbuScoreTuple(namedtuple('AbuScoreTuple',
    method __repr__ (line 32) | def __repr__(self):
  class AbuBaseScorer (line 40) | class AbuBaseScorer(six.with_metaclass(ABCMeta, object)):
    method __init__ (line 44) | def __init__(self, score_tuple_array, *arg, **kwargs):
    method _init_self_begin (line 109) | def _init_self_begin(self, *arg, **kwargs):
    method _init_self_end (line 114) | def _init_self_end(self, *arg, **kwargs):
    method fit_score (line 118) | def fit_score(self):
    method __call__ (line 123) | def __call__(self):
  class WrsmScorer (line 128) | class WrsmScorer(AbuBaseScorer):
    method _init_self_begin (line 129) | def _init_self_begin(self, *arg, **kwargs):
    method _init_self_end (line 138) | def _init_self_end(self, *arg, **kwargs):
  class DemoScorer (line 156) | class DemoScorer(AbuBaseScorer):
    method _init_self_begin (line 157) | def _init_self_begin(self, *arg, **kwargs):
    method _init_self_end (line 165) | def _init_self_end(self, *arg, **kwargs):
  function make_scorer (line 175) | def make_scorer(score_tuple_array, sc_class, **kwargs):

FILE: abupy/MetricsBu/ABuMetricsTC.py
  class AbuMetricsTC (line 15) | class AbuMetricsTC(AbuMetricsFutures):

FILE: abupy/PickStockBu/ABuPickRegressAngMinMax.py
  class AbuPickRegressAngMinMax (line 18) | class AbuPickRegressAngMinMax(AbuPickStockBase):
    method _init_self (line 20) | def _init_self(self, **kwargs):
    method fit_pick (line 37) | def fit_pick(self, kl_pd, target_symbol):
    method fit_first_choice (line 47) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):

FILE: abupy/PickStockBu/ABuPickSimilarNTop.py
  class AbuPickSimilarNTop (line 22) | class AbuPickSimilarNTop(AbuPickStockBase):
    method _init_self (line 25) | def _init_self(self, **kwargs):
    method fit_pick (line 60) | def fit_pick(self, kl_pd, target_symbol):
    method fit_first_choice (line 72) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):

FILE: abupy/PickStockBu/ABuPickStockBase.py
  function reversed_result (line 21) | def reversed_result(func):
  class AbuPickStockBase (line 33) | class AbuPickStockBase(six.with_metaclass(ABCMeta, AbuParamBase)):
    method __init__ (line 34) | def __init__(self, capital, benchmark, **kwargs):
    method __str__ (line 62) | def __str__(self):
    method _init_self (line 70) | def _init_self(self, **kwargs):
    method fit_pick (line 75) | def fit_pick(self, *args, **kwargs):
    method fit_first_choice (line 80) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):

FILE: abupy/PickStockBu/ABuPickStockDemo.py
  class AbuPickStockShiftDistance (line 21) | class AbuPickStockShiftDistance(AbuPickStockBase):
    method _init_self (line 24) | def _init_self(self, **kwargs):
    method fit_pick (line 31) | def fit_pick(self, kl_pd, target_symbol):
    method fit_first_choice (line 47) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):
  class AbuPickStockNTop (line 51) | class AbuPickStockNTop(AbuPickStockBase):
    method _init_self (line 54) | def _init_self(self, **kwargs):
    method fit_pick (line 64) | def fit_pick(self, kl_pd, target_symbol):
    method fit_first_choice (line 104) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):

FILE: abupy/PickStockBu/ABuPickStockPriceMinMax.py
  class AbuPickStockPriceMinMax (line 16) | class AbuPickStockPriceMinMax(AbuPickStockBase):
    method _init_self (line 18) | def _init_self(self, **kwargs):
    method fit_pick (line 35) | def fit_pick(self, kl_pd, target_symbol):
    method fit_first_choice (line 42) | def fit_first_choice(self, pick_worker, choice_symbols, *args, **kwargs):

FILE: abupy/SimilarBu/ABuCorrcoef.py
  class ECoreCorrType (line 23) | class ECoreCorrType(Enum):
    method task_cnt (line 37) | def task_cnt(cls):
  function corr_xy (line 46) | def corr_xy(x, y, similar_type=ECoreCorrType.E_CORE_TYPE_PEARS, **kwargs):
  function corr_matrix (line 85) | def corr_matrix(df, similar_type=ECoreCorrType.E_CORE_TYPE_PEARS, **kwar...
  function rolling_corr (line 122) | def rolling_corr(df, ss=None, window=g_rolling_corr_window):
  function spearmanr (line 208) | def spearmanr(a, b=None, axis=0, p_value=False):
  function _chk_asarray (line 234) | def _chk_asarray(a, axis):

FILE: abupy/SimilarBu/ABuSimilar.py
  function from_local (line 39) | def from_local(func):
  function from_net (line 65) | def from_net(func):
  function _find_similar (line 90) | def _find_similar(symbol, cmp_cnt=None, n_folds=2, start=None, end=None,...
  function find_similar_with_se (line 125) | def find_similar_with_se(symbol, start, end, show_cnt=10, rolling=False,...
  function find_similar_with_folds (line 142) | def find_similar_with_folds(symbol, n_folds=2, show_cnt=10, rolling=Fals...
  function find_similar_with_cnt (line 158) | def find_similar_with_cnt(symbol, cmp_cnt=60, show_cnt=10, rolling=False...
  function _make_symbols_cg_df (line 175) | def _make_symbols_cg_df(symbols, benchmark):
  function _make_benchmark_cg_df (line 207) | def _make_benchmark_cg_df(symbol, benchmark):
  function _net_cg_df_create (line 231) | def _net_cg_df_create(symbol, benchmark):
  function _all_market_cg (line 275) | def _all_market_cg(symbol, cmp_cnt=None, n_folds=2, start=None, end=None):
  function _handle_market_change_df (line 310) | def _handle_market_change_df(market_change_df, cmp_cnt, benchmark_df, sh...
  function multi_corr_df (line 358) | def multi_corr_df(corr_jobs, cmp_cnt=252, n_folds=None, start=None, end=...

FILE: abupy/SimilarBu/ABuSimilarCache.py
  function similar_key (line 15) | def similar_key(symbol, cmp_cnt=None, n_folds=None, start=None, end=None...
  function dump_2_hdh5 (line 19) | def dump_2_hdh5(key, obj):
  function load_2_hdh5 (line 23) | def load_2_hdh5(key):
  function show_keys (line 27) | def show_keys():
  function clear_cache (line 32) | def clear_cache(key=None):

FILE: abupy/SimilarBu/ABuSimilarDrawing.py
  function draw_show_close (line 28) | def draw_show_close(sorted_ret, target_count, show_cnt):
  function draw_show_close_array (line 64) | def draw_show_close_array(sorted_ret, cs_array):

FILE: abupy/SlippageBu/ABuSlippageBuyBase.py
  class AbuSlippageBuyBase (line 23) | class AbuSlippageBuyBase(six.with_metaclass(ABCMeta, object)):
    method __init__ (line 26) | def __init__(self, kl_pd_buy, factor_name):
    method fit (line 35) | def fit(self):
    method fit_price (line 44) | def fit_price(self):
  function slippage_limit_up (line 62) | def slippage_limit_up(func):

FILE: abupy/SlippageBu/ABuSlippageBuyMean.py
  class AbuSlippageBuyMean (line 23) | class AbuSlippageBuyMean(AbuSlippageBuyBase):
    method fit_price (line 27) | def fit_price(self):

FILE: abupy/SlippageBu/ABuSlippageSellBase.py
  class AbuSlippageSellBase (line 23) | class AbuSlippageSellBase(six.with_metaclass(ABCMeta, object)):
    method __init__ (line 26) | def __init__(self, kl_pd_sell, factor_name):
    method fit (line 35) | def fit(self):
    method fit_price (line 44) | def fit_price(self):
  function slippage_limit_down (line 62) | def slippage_limit_down(func):

FILE: abupy/SlippageBu/ABuSlippageSellMean.py
  class AbuSlippageSellMean (line 20) | class AbuSlippageSellMean(AbuSlippageSellBase):
    method fit_price (line 24) | def fit_price(self):

FILE: abupy/TLineBu/ABuTLAtr.py
  function show_atr_std (line 21) | def show_atr_std(kl_pd):
  function calc_atr_std (line 38) | def calc_atr_std(kl_pd, xd=21, ewm=True, show=True):

FILE: abupy/TLineBu/ABuTLExecute.py
  function shift_distance (line 38) | def shift_distance(arr, how, slice_start=0, slice_end=-1, color='r', sho...
  function calc_kl_speed (line 140) | def calc_kl_speed(kl, resample=5):
  function calc_pair_speed (line 217) | def calc_pair_speed(symbol, benchmark_symbol, resample=5, speed_key='clo...
  function shift_distance_how (line 263) | def shift_distance_how(how):
  function regress_trend_channel (line 293) | def regress_trend_channel(arr):
  function bfgs_min_pos (line 322) | def bfgs_min_pos(find_min_pos, y_len, linear_interp):
  function support_resistance_pos (line 341) | def support_resistance_pos(x, support_resistance_y, best_poly=0, label=N...
  function select_k_support_resistance (line 390) | def select_k_support_resistance(support_resistance, thresh=0.06, label='...
  function support_resistance_predict (line 461) | def support_resistance_predict(x, y, est, support_resistance, is_support...
  function plot_support_resistance_trend (line 534) | def plot_support_resistance_trend(x, y, trend_pos, label, only_last=Fals...
  function skeleton_how (line 587) | def skeleton_how(how):
  function below_above_gen (line 619) | def below_above_gen(x, y):
  function find_percent_point (line 628) | def find_percent_point(percents, y):
  function find_golden_point_ex (line 650) | def find_golden_point_ex(x, y, show=False):
  function find_golden_point (line 671) | def find_golden_point(x, y, show=False):

FILE: abupy/TLineBu/ABuTLGolden.py
  function calc_golden (line 21) | def calc_golden(kl_pd, show=True):

FILE: abupy/TLineBu/ABuTLJump.py
  function calc_jump (line 30) | def calc_jump(kl_pd, jump_diff_factor=1, show=True):
  class AbuJumpTuple (line 192) | class AbuJumpTuple(namedtuple('AbuJumpTuple',
    method __repr__ (line 199) | def __repr__(self):
  function calc_jump_line (line 206) | def calc_jump_line(kl_pd, power_threshold=2.0, jump_diff_factor=1, show=...
  function _show_jump_line (line 237) | def _show_jump_line(kl_pd, jump_lines):
  function calc_jump_line_weight (line 259) | def calc_jump_line_weight(kl_pd, sw=(0.5, 0.5), power_threshold=2.0, jum...

FILE: abupy/TLineBu/ABuTLSimilar.py
  function rank_corr_sum (line 39) | def rank_corr_sum(corr_df_dict, symbol):
  function calc_similar (line 134) | def calc_similar(symbol, cmp_symbol, sum_rank=None, corr_jobs=(ECoreCorr...
  function calc_similar_top (line 280) | def calc_similar_top(symbol, sum_rank=None, corr_jobs=(ECoreCorrType.E_C...
  function coint_similar (line 401) | def coint_similar(symbol, sum_rank=None, corr_jobs=(ECoreCorrType.E_CORE...

FILE: abupy/TLineBu/ABuTLVwap.py
  class EDayBarCalcType (line 20) | class EDayBarCalcType(Enum):
  function calc_vwap (line 33) | def calc_vwap(kl_pd, how=EDayBarCalcType.OHLC_MEAN, show=True):

FILE: abupy/TLineBu/ABuTLWave.py
  function show_wave_return (line 20) | def show_wave_return(kl_pd):
  function calc_wave_std (line 37) | def calc_wave_std(kl_pd, xd=21, ewm=True, show=True):
  function calc_wave_abs (line 66) | def calc_wave_abs(kl_pd, xd=21, show=True):
  function calc_wave_weight_abs (line 120) | def calc_wave_weight_abs(kl_pd, xd=21, span=3, show=True):
  function _show_wave (line 154) | def _show_wave(wave, above, wave_mean, below, xd_mean_close):

FILE: abupy/TLineBu/ABuTLine.py
  class ESkeletonHow (line 43) | class ESkeletonHow(Enum):
  class EShiftDistanceHow (line 66) | class EShiftDistanceHow(Enum):
  class AbuTLine (line 90) | class AbuTLine(FreezeAttrMixin):
    method __init__ (line 93) | def __init__(self, line, line_name, **kwargs):
    method show_kl_pd (line 123) | def show_kl_pd(cls, kl_pd, key='close', show=True, **kwargs):
    method score (line 160) | def score(self):
    method y_zoom (line 178) | def y_zoom(self):
    method step_x_to_step (line 188) | def step_x_to_step(self, step_x):
    method show (line 207) | def show(self):
    method is_up_trend (line 221) | def is_up_trend(self, up_deg_threshold=5, show=True):
    method is_down_trend (line 238) | def is_down_trend(self, down_deg_threshold=-5, show=True):
    method show_best_poly (line 256) | def show_best_poly(self, zoom=False, show=show):
    method show_least_valid_poly (line 268) | def show_least_valid_poly(self, zoom=False, show=True):
    method show_shift_distance (line 280) | def show_shift_distance(self, how=EShiftDistanceHow.shift_distance_clo...
    method show_regress_trend_channel (line 311) | def show_regress_trend_channel(self, step_x=1.0):
    method show_skeleton_channel (line 331) | def show_skeleton_channel(self, with_mean=True, step_x=1.0):
    method show_skeleton (line 349) | def show_skeleton(self, how=ESkeletonHow.skeleton_min, step_x=1.0, ps=...
    method show_skeleton_bfgs (line 397) | def show_skeleton_bfgs(self, step_x=1.0):
    method show_support_resistance_pos (line 428) | def show_support_resistance_pos(self, best_poly=0, show=True):
    method show_support_resistance_select_k (line 461) | def show_support_resistance_select_k(self, best_poly=0, show=True):
    method show_support_resistance_trend (line 488) | def show_support_resistance_trend(self, best_poly=0, only_last=False, ...
    method show_support_trend (line 535) | def show_support_trend(self, best_poly=0, only_last=False, plot_org=Fa...
    method show_resistance_trend (line 568) | def show_resistance_trend(self, best_poly=0, only_last=False, plot_org...
    method show_percents (line 601) | def show_percents(self, percents=(0.1, 0.9)):
    method show_golden (line 633) | def show_golden(self, both_golden=True):
    method __str__ (line 647) | def __str__(self):

FILE: abupy/TradeBu/ABuBenchmark.py
  class AbuBenchmark (line 22) | class AbuBenchmark(PickleStateMixin):
    method __init__ (line 25) | def __init__(self, benchmark=None, start=None, end=None, n_folds=2, rs...
    method unpick_extend_work (line 73) | def unpick_extend_work(self, state):
    method __str__ (line 80) | def __str__(self):

FILE: abupy/TradeBu/ABuCapital.py
  class AbuCapital (line 25) | class AbuCapital(PickleStateMixin):
    method __init__ (line 28) | def __init__(self, init_cash, benchmark, user_commission_dict=None):
    method __str__ (line 58) | def __str__(self):
    method __len__ (line 65) | def __len__(self):
    method init_k_line (line 69) | def init_k_line(self, a_symbol):
    method apply_init_kl (line 98) | def apply_init_kl(self, action_pd, show_progress):
    method apply_k_line (line 114) | def apply_k_line(self, a_k_day, kl_pd, buy_type_head):
    method apply_kl (line 142) | def apply_kl(self, action_pd, kl_pd_manager, show_progress):
    method apply_action (line 193) | def apply_action(self, a_action, progress):
    method buy_stock (line 230) | def buy_stock(self, a_order):
    method sell_stock (line 299) | def sell_stock(self, a_order):

FILE: abupy/TradeBu/ABuCommission.py
  function calc_commission_us (line 28) | def calc_commission_us(trade_cnt, price):
  function calc_commission_cn (line 43) | def calc_commission_cn(trade_cnt, price):
  function calc_commission_hk (line 61) | def calc_commission_hk(trade_cnt, price):
  function calc_commission_tc (line 77) | def calc_commission_tc(trade_cnt, price):
  function calc_commission_futures_cn (line 92) | def calc_commission_futures_cn(trade_cnt, price, symbol_name):
  function calc_options_us (line 113) | def calc_options_us(trade_cnt, price):
  function calc_commission_futures_global (line 126) | def calc_commission_futures_global(trade_cnt, price):
  class AbuCommission (line 139) | class AbuCommission(object):
    method __init__ (line 142) | def __init__(self, commission_dict):
    method __str__ (line 154) | def __str__(self):
    method _commission_enter (line 163) | def _commission_enter(self, a_order):
    method buy_commission_func (line 200) | def buy_commission_func(self, a_order):
    method sell_commission_func (line 226) | def sell_commission_func(self, a_order):

FILE: abupy/TradeBu/ABuKLManager.py
  function gen_dict_pick_time_kl_pd (line 32) | def gen_dict_pick_time_kl_pd(target_symbols, capital, benchmark, show_pr...
  class AbuKLManager (line 67) | class AbuKLManager(object):
    method __init__ (line 70) | def __init__(self, benchmark, capital):
    method __str__ (line 84) | def __str__(self):
    method __len__ (line 91) | def __len__(self):
    method __contains__ (line 95) | def __contains__(self, item):
    method __missing__ (line 99) | def __missing__(self, key):
    method __getitem__ (line 104) | def __getitem__(self, key):
    method __setitem__ (line 114) | def __setitem__(self, key, value):
    method _fetch_pick_stock_kl_pd (line 118) | def _fetch_pick_stock_kl_pd(self, xd, target_symbol):
    method _fetch_pick_time_kl_pd (line 155) | def _fetch_pick_time_kl_pd(self, target_symbol):
    method get_pick_time_kl_pd (line 160) | def get_pick_time_kl_pd(self, target_symbol):
    method filter_pick_time_choice_symbols (line 173) | def filter_pick_time_choice_symbols(self, choice_symbols):
    method batch_get_pick_time_kl_pd (line 182) | def batch_get_pick_time_kl_pd(self, choice_symbols, n_process=ABuEnv.g...
    method get_pick_stock_kl_pd (line 226) | def get_pick_stock_kl_pd(self, target_symbol, xd=ABuEnv.g_market_trade...

FILE: abupy/TradeBu/ABuMLFeature.py
  class BuyFeatureMixin (line 43) | class BuyFeatureMixin(object):
  class SellFeatureMixin (line 52) | class SellFeatureMixin(object):
  class AbuFeatureBase (line 61) | class AbuFeatureBase(object):
    method support_buy_feature (line 64) | def support_buy_feature(self):
    method support_sell_feature (line 68) | def support_sell_feature(self):
    method check_support (line 72) | def check_support(self, buy_feature):
    method feature_prefix (line 82) | def feature_prefix(self, buy_feature, check=True):
    method __str__ (line 93) | def __str__(self):
    method get_feature_ump_keys (line 103) | def get_feature_ump_keys(self, ump_cls):
    method get_feature_keys (line 112) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 120) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeatureDeg (line 132) | class AbuFeatureDeg(AbuFeatureBase, BuyFeatureMixin, SellFeatureMixin):
    method __init__ (line 135) | def __init__(self):
    method get_feature_keys (line 144) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 152) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeaturePrice (line 184) | class AbuFeaturePrice(AbuFeatureBase, BuyFeatureMixin, SellFeatureMixin):
    method __init__ (line 187) | def __init__(self):
    method get_feature_keys (line 196) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 205) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeatureWave (line 254) | class AbuFeatureWave(AbuFeatureBase, BuyFeatureMixin, SellFeatureMixin):
    method __init__ (line 257) | def __init__(self):
    method get_feature_keys (line 265) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 274) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeatureAtr (line 308) | class AbuFeatureAtr(AbuFeatureBase, BuyFeatureMixin):
    method __init__ (line 311) | def __init__(self):
    method get_feature_keys (line 319) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 327) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeatureJump (line 360) | class AbuFeatureJump(AbuFeatureBase, BuyFeatureMixin, SellFeatureMixin):
    method __init__ (line 363) | def __init__(self):
    method get_feature_keys (line 373) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 381) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  class AbuFeatureSnapshot (line 456) | class AbuFeatureSnapshot(AbuFeatureBase, BuyFeatureMixin, SellFeatureMix...
    method __init__ (line 462) | def __init__(self):
    method get_feature_keys (line 470) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 478) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
  function append_user_feature (line 519) | def append_user_feature(feature, check=True):
  function clear_user_feature (line 542) | def clear_user_feature():
  class AbuMlFeature (line 548) | class AbuMlFeature(object):
    method __init__ (line 551) | def __init__(self):
    method make_feature_dict (line 565) | def make_feature_dict(self, kl_pd, combine_kl_pd, day_ind, buy_feature):
    method _get_unzip_feature_keys (line 586) | def _get_unzip_feature_keys(self, buy_feature):
    method unzip_ml_feature (line 602) | def unzip_ml_feature(self, orders_pd):
  class AbuFeatureDegExtend (line 636) | class AbuFeatureDegExtend(AbuFeatureBase, BuyFeatureMixin, SellFeatureMi...
    method __init__ (line 639) | def __init__(self):
    method get_feature_keys (line 644) | def get_feature_keys(self, buy_feature):
    method calc_feature (line 652) | def calc_feature(self, kl_pd, combine_kl_pd, day_ind, buy_feature):

FILE: abupy/TradeBu/ABuOrder.py
  class OrderMarket (line 25) | class OrderMarket(MarketMixin):
    method __init__ (line 28) | def __init__(self, order):
  class AbuOrder (line 40) | class AbuOrder(object):
    method __init__ (line 49) | def __init__(self):
    method fit_buy_order (line 53) | def fit_buy_order(self, day_ind, factor_object):
    method fit_sell_order (line 182) | def fit_sell_order(self, day_ind, factor_object):
    method __str__ (line 221) | def __str__(self):

FILE: abupy/TradeBu/ABuTradeDrawer.py
  function plot_his_trade (line 32) | def plot_his_trade(orders, kl_pd):
  function plot_capital_info (line 141) | def plot_capital_info(capital_pd, init_cash=-1):
  function plot_bk_xd (line 190) | def plot_bk_xd(bk_summary, kl_pd_xd_mean, title=None):
  function plot_kp_xd (line 204) | def plot_kp_xd(kp_summary, kl_pd_xd_mean, title=None):

FILE: abupy/TradeBu/ABuTradeExecute.py
  function calc_simple_profit (line 24) | def calc_simple_profit(orders, kl_pd):
  function make_orders_pd (line 43) | def make_orders_pd(orders, kl_pd):
  function transform_action (line 100) | def transform_action(orders_pd):
  function apply_action_to_capital (line 141) | def apply_action_to_capital(capital, action_pd, kl_pd_manager, show_prog...

FILE: abupy/TradeBu/ABuTradeProxy.py
  class EOrderSameRule (line 24) | class EOrderSameRule(Enum):
  class AbuOrderPdProxy (line 38) | class AbuOrderPdProxy(object):
    method __init__ (line 55) | def __init__(self, orders_pd, same_rule=EOrderSameRule.ORDER_SAME_BSPD):
    method proxy_work (line 70) | def proxy_work(self, orders_pd):
    method __and__ (line 97) | def __and__(self, other):
    method __or__ (line 103) | def __or__(self, other):
    method __sub__ (line 109) | def __sub__(self, other):
    method __eq__ (line 114) | def __eq__(self, other):
    method __gt__ (line 118) | def __gt__(self, other):
  function union_in_2orders (line 125) | def union_in_2orders(orders_pd, other_orders_pd):
  function _same_pd (line 140) | def _same_pd(order, other_orders_pd, same_rule):
  function intersection_in_2orders (line 178) | def intersection_in_2orders(orders_pd, other_orders_pd, same_rule=EOrder...
  function difference_in_2orders (line 200) | def difference_in_2orders(orders_pd, other_orders_pd, same_rule=EOrderSa...
  function find_unique_group_symbol (line 224) | def find_unique_group_symbol(order_pd):
  function find_unique_symbol (line 240) | def find_unique_symbol(order_pd, same_rule=EOrderSameRule.ORDER_SAME_BSPD):
  function trade_summary (line 261) | def trade_summary(orders, kl_pd, draw=False, show_info=True):

FILE: abupy/UmpBu/ABuUmpBase.py
  class BuyUmpMixin (line 24) | class BuyUmpMixin(object):
  class SellUmpMixin (line 32) | class SellUmpMixin(object):
  class UmpDict (line 40) | class UmpDict(dict):
  class CachedUmpManager (line 46) | class CachedUmpManager:
    method __init__ (line 52) | def __init__(self):
    method get_ump (line 56) | def get_ump(self, ump):
    method clear (line 92) | def clear(self):
  function ump_main_make_xy (line 97) | def ump_main_make_xy(func):
  function ump_edge_make_xy (line 152) | def ump_edge_make_xy(func):
  class AbuUmpBase (line 198) | class AbuUmpBase(six.with_metaclass(ABCMeta, object)):
    method get_fiter_class (line 203) | def get_fiter_class(self):
    method get_predict_col (line 208) | def get_predict_col(self):
    method is_buy_ump (line 213) | def is_buy_ump(cls):
    method class_unique_id (line 222) | def class_unique_id(cls):
    method __str__ (line 230) | def __str__(self):

FILE: abupy/UmpBu/ABuUmpEdgeBase.py
  class EEdgeType (line 55) | class EEdgeType(Enum):
  class AbuUmpEdgeBase (line 70) | class AbuUmpEdgeBase(AbuUmpBase):
    method ump_edge_clf_dump (line 74) | def ump_edge_clf_dump(cls, orders_pd_train, show_info=False, market_na...
    method get_fiter_class (line 91) | def get_fiter_class(self):
    method get_predict_col (line 96) | def get_predict_col(self):
    method class_unique_id (line 102) | def class_unique_id(cls):
    method __init__ (line 110) | def __init__(self, orders_pd=None, predict=False, market_name=None, **...
    method fit (line 154) | def fit(self):
    method dump_file_fn (line 275) | def dump_file_fn(self):
    method dump_clf (line 285) | def dump_clf(self):
    method predict (line 317) | def predict(self, **kwargs):

FILE: abupy/UmpBu/ABuUmpEdgeDeg.py
  class UmpDegFiter (line 17) | class UmpDegFiter(AbuMLPd):
    method make_xy (line 27) | def make_xy(self, **kwarg):
  class AbuUmpEdgeDeg (line 97) | class AbuUmpEdgeDeg(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 100) | def get_predict_col(self):
    method get_fiter_class (line 107) | def get_fiter_class(self):
    method class_unique_id (line 115) | def class_unique_id(cls):
  class UmpExtendEdgeFiter (line 124) | class UmpExtendEdgeFiter(AbuMLPd):
    method make_xy (line 127) | def make_xy(self, **kwarg):
  class AbuUmpEegeDegExtend (line 135) | class AbuUmpEegeDegExtend(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 138) | def get_predict_col(self):
    method get_fiter_class (line 143) | def get_fiter_class(self):
    method class_unique_id (line 147) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpEdgeFull.py
  class UmpFullFiter (line 17) | class UmpFullFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpEdgeFull (line 120) | class AbuUmpEdgeFull(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 123) | def get_predict_col(self):
    method get_fiter_class (line 143) | def get_fiter_class(self):
    method class_unique_id (line 151) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpEdgeMul.py
  class UmpMulFiter (line 17) | class UmpMulFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpEdgeMul (line 101) | class AbuUmpEdgeMul(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 104) | def get_predict_col(self):
    method get_fiter_class (line 115) | def get_fiter_class(self):
    method class_unique_id (line 123) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpEdgePrice.py
  class UmpPriceFiter (line 17) | class UmpPriceFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpEdgePrice (line 99) | class AbuUmpEdgePrice(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 102) | def get_predict_col(self):
    method get_fiter_class (line 109) | def get_fiter_class(self):
    method class_unique_id (line 117) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpEdgeWave.py
  class UmpWaveFiter (line 17) | class UmpWaveFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpEdgeWave (line 98) | class AbuUmpEdgeWave(AbuUmpEdgeBase, BuyUmpMixin):
    method get_predict_col (line 101) | def get_predict_col(self):
    method get_fiter_class (line 108) | def get_fiter_class(self):
    method class_unique_id (line 116) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainBase.py
  function _do_gmm_cluster (line 53) | def _do_gmm_cluster(sub_ncs, x, df, threshold):
  class AbuUmpMainBase (line 161) | class AbuUmpMainBase(AbuUmpBase):
    method ump_main_clf_dump (line 165) | def ump_main_clf_dump(cls, orders_pd_train, p_ncs=None, brust_min=True...
    method get_fiter_class (line 220) | def get_fiter_class(self):
    method get_predict_col (line 225) | def get_predict_col(self):
    method class_unique_id (line 231) | def class_unique_id(cls):
    method __init__ (line 239) | def __init__(self, orders_pd=None, predict=False, market_name=None, **...
    method _sub_ncs_split (line 288) | def _sub_ncs_split(self, ncs, n_jobs):
    method fit (line 300) | def fit(self, p_ncs=None, threshold=0.65, brust_min=True, show=True):
    method _fit_cprs (line 451) | def _fit_cprs(self, show):
    method _fit_brust_min (line 638) | def _fit_brust_min(self, brust_min):
    method brust_min (line 667) | def brust_min(self):
    method min_func (line 734) | def min_func(self, l_pmr):
    method min_func_improved (line 808) | def min_func_improved(self, l_pmr):
    method _calc_llps_improved (line 825) | def _calc_llps_improved(self, llps):
    method dump_file_fn (line 891) | def dump_file_fn(self):
    method dump_clf (line 901) | def dump_clf(self, llps=None):
    method predict (line 982) | def predict(self, x, need_hit_cnt=1):
    method predict_kwargs (line 1033) | def predict_kwargs(self, w_col=None, need_hit_cnt=1, **kwargs):
    method show_parse_rt (line 1061) | def show_parse_rt(self, rt):
    method choose_cprs_component (line 1088) | def choose_cprs_component(self, llps=None):
    method best_hit_cnt_info (line 1158) | def best_hit_cnt_info(self, llps=None):
    method hit_cnt (line 1265) | def hit_cnt(self, x):
    method predict_hit_kwargs (line 1293) | def predict_hit_kwargs(self, w_col=None, **kwargs):

FILE: abupy/UmpBu/ABuUmpMainDeg.py
  class UmpDegFiter (line 17) | class UmpDegFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainDeg (line 95) | class AbuUmpMainDeg(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 98) | def get_predict_col(self):
    method get_fiter_class (line 105) | def get_fiter_class(self):
    method class_unique_id (line 113) | def class_unique_id(cls):
  class UmpExtendFeatureFiter (line 122) | class UmpExtendFeatureFiter(AbuMLPd):
    method make_xy (line 125) | def make_xy(self, **kwarg):
  class AbuUmpMainDegExtend (line 133) | class AbuUmpMainDegExtend(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 136) | def get_predict_col(self):
    method get_fiter_class (line 141) | def get_fiter_class(self):
    method class_unique_id (line 145) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainFull.py
  class UmpFullFiter (line 17) | class UmpFullFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainFull (line 143) | class AbuUmpMainFull(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 146) | def get_predict_col(self):
    method get_fiter_class (line 166) | def get_fiter_class(self):
    method class_unique_id (line 174) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainJump.py
  class UmpJumpFiter (line 17) | class UmpJumpFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainJump (line 94) | class AbuUmpMainJump(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 97) | def get_predict_col(self):
    method get_fiter_class (line 104) | def get_fiter_class(self):
    method class_unique_id (line 112) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainMul.py
  class UmpMulFiter (line 17) | class UmpMulFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainMul (line 97) | class AbuUmpMainMul(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 102) | def get_predict_col(self):
    method get_fiter_class (line 113) | def get_fiter_class(self):
    method class_unique_id (line 121) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainPrice.py
  class UmpPriceFiter (line 17) | class UmpPriceFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainPrice (line 95) | class AbuUmpMainPrice(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 98) | def get_predict_col(self):
    method get_fiter_class (line 105) | def get_fiter_class(self):
    method class_unique_id (line 113) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpMainWave.py
  class UmpWaveFiter (line 17) | class UmpWaveFiter(AbuMLPd):
    method make_xy (line 28) | def make_xy(self, **kwarg):
  class AbuUmpMainWave (line 73) | class AbuUmpMainWave(AbuUmpMainBase, BuyUmpMixin):
    method get_predict_col (line 76) | def get_predict_col(self):
    method get_fiter_class (line 84) | def get_fiter_class(self):
    method class_unique_id (line 92) | def class_unique_id(cls):

FILE: abupy/UmpBu/ABuUmpManager.py
  function append_user_ump (line 35) | def append_user_ump(ump, check=True):
  function clear_user_ump (line 53) | def clear_user_ump():
  class AbuUmpManager (line 62) | class AbuUmpManager(object):
    method __init__ (line 65) | def __init__(self, factor):
    method __str__ (line 85) | def __str__(self):
    method _fix_ump_env (line 93) | def _fix_ump_env(cls):
    method ump_main_deg (line 110) | def ump_main_deg(self):
    method ump_main_jump (line 118) | def ump_main_jump(self):
    method ump_main_price (line 126) | def ump_main_price(self):
    method ump_main_wave (line 134) | def ump_main_wave(self):
    method ump_edge_deg (line 142) | def ump_edge_deg(self):
    method ump_edge_price (line 150) | def ump_edge_price(self):
    method ump_edge_wave (line 158) | def ump_edge_wave(self):
    method ump_edge_full (line 166) | def ump_edge_full(self):
    method _default_main_hit_cnt (line 174) | def _default_main_hit_cnt(self):
    method ump_main_deg_hit_cnt (line 180) | def ump_main_deg_hit_cnt(self):
    method ump_main_jump_hit_cnt (line 192) | def ump_main_jump_hit_cnt(self):
    method ump_main_price_hit_cnt (line 204) | def ump_main_price_hit_cnt(self):
    method ump_main_wave_hit_cnt (line 216) | def ump_main_wave_hit_cnt(self):
    method ump_main_user_hit_cnt (line 228) | def ump_main_user_hit_cnt(self):
    method ump_block (line 252) | def ump_block(self, ml_feature_dict):
    method extend_ump_block (line 277) | def extend_ump_block(self, ml_feature_dict):
    method builtin_ump_block (line 337) | def builtin_ump_block(self, ml_feature_dict):

FILE: abupy/UtilBu/ABuDTUtil.py
  function warnings_filter (line 26) | def warnings_filter(func):
  function singleton (line 44) | def singleton(cls):
  function arr_to_pandas (line 63) | def arr_to_pandas(arr):
  function params_to_pandas (line 88) | def params_to_pandas(func):
  function arr_to_numpy (line 106) | def arr_to_numpy(arr):
  function params_to_numpy (line 127) | def params_to_numpy(func):
  function catch_error (line 144) | def catch_error(return_val=None, log=True):
  function consume_time (line 174) | def consume_time(func):
  function empty_wrapper (line 191) | def empty_wrapper(func):
  function empty_wrapper_with_params (line 205) | def empty_wrapper_with_params(*p_args, **p_kwargs):
  function except_debug (line 221) | def except_debug(func):
  function plt_show (line 241) | def plt_show():

FILE: abupy/UtilBu/ABuDateUtil.py
  function str_to_datetime (line 34) | def str_to_datetime(date_str, fmt=K_DEFAULT_DT_FMT, fix=True):
  function str_to_datetime_fast (line 49) | def str_to_datetime_fast(date_str, split='-', fix=True):
  function datetime_to_str (line 65) | def datetime_to_str(dt_obj):
  function timestamp_to_str (line 74) | def timestamp_to_str(ts):
  function date_str_to_int (line 89) | def date_str_to_int(date_str, split='-', fix=True):
  function fix_date (line 105) | def fix_date(date_str):
  function fmt_date (line 140) | def fmt_date(convert_date):
  function diff (line 171) | def diff(start_date, end_date, check_order=True):
  function current_date_int (line 214) | def current_date_int():
  function current_str_date (line 230) | def current_str_date():
  function week_of_date (line 238) | def week_of_date(date_str, fmt=K_DEFAULT_DT_FMT, fix=True):
  function begin_date (line 253) | def begin_date(pre_days, date_str=None, split='-', fix=True):
  function time_seconds (line 285) | def time_seconds():
  function time_zone (line 293) | def time_zone():

FILE: abupy/UtilBu/ABuDelegateUtil.py
  function first_delegate_has_method (line 20) | def first_delegate_has_method(delegate, check_params=True):
  function replace_word_delegate_has_method (line 71) | def replace_word_delegate_has_method(delegate, key_word, replace_word, c...
  class _IffHasAttrDescriptor (line 128) | class _IffHasAttrDescriptor(object):
    method __init__ (line 133) | def __init__(self, fn, delegate_names, attribute_name):
    method __get__ (line 141) | def __get__(self, obj, p_type=None):
  function if_delegate_has_method (line 164) | def if_delegate_has_method(delegate):

FILE: abupy/UtilBu/ABuFileUtil.py
  function ensure_dir (line 32) | def ensure_dir(a_path):
  function ensure_file (line 46) | def ensure_file(a_path):
  function file_exist (line 57) | def file_exist(a_path):
  function copy_file (line 65) | def copy_file(source, target_dir):
  function del_file (line 84) | def del_file(a_path):
  function load_pickle (line 98) | def load_pickle(file_name):
  function dump_pickle (line 122) | def dump_pickle(input_obj, file_name, how='normal'):
  function __start_batch_h5s (line 154) | def __start_batch_h5s(file_name, mode):
  function __end_batch_h5s (line 164) | def __end_batch_h5s():
  function batch_h5s (line 175) | def batch_h5s(h5_fn, mode='a'):
  function batch_ctx_h5s (line 212) | def batch_ctx_h5s(h5_fn, mode='a'):
  function dump_del_hdf5 (line 243) | def dump_del_hdf5(file_name, dump_dict, del_array=None):
  function dump_hdf5 (line 279) | def dump_hdf5(file_name, input_obj, input_key):
  function del_hdf5 (line 297) | def del_hdf5(file_name, key):
  function load_hdf5 (line 317) | def load_hdf5(file_name, key):
  function dump_df_csv (line 349) | def dump_df_csv(file_name, df):
  function load_df_csv (line 361) | def load_df_csv(file_name):
  function save_file (line 372) | def save_file(ct, file_name):

FILE: abupy/UtilBu/ABuKLUtil.py
  function _df_dispatch (line 34) | def _df_dispatch(df, dispatch_func):
  function _df_dispatch_concat (line 54) | def _df_dispatch_concat(df, dispatch_func):
  function resample_close_mean (line 76) | def resample_close_mean(df, bins=None):
  function bcut_change_vc (line 161) | def bcut_change_vc(df, bins=None):
  function qcut_change_vc (line 196) | def qcut_change_vc(df, q=10):
  function date_week_mean (line 235) | def date_week_mean(df):
  function date_week_win (line 265) | def date_week_win(df):
  function wave_change_rate (line 300) | def wave_change_rate(df):
  function p_change_stats (line 322) | def p_change_stats(df):
  function date_week_wave (line 348) | def date_week_wave(df):

FILE: abupy/UtilBu/ABuLazyUtil.py
  class LazyFunc (line 14) | class LazyFunc(object):
    method __init__ (line 17) | def __init__(self, func):
    method __get__ (line 32) | def __get__(self, instance, owner):
    method __set__ (line 43) | def __set__(self, instance, value):
    method __delete__ (line 47) | def __delete__(self, instance):
  class LazyClsFunc (line 52) | class LazyClsFunc(LazyFunc):
    method __get__ (line 59) | def __get__(self, instance, owner):
  function add_doc (line 64) | def add_doc(func, doc):
  function import_module (line 69) | def import_module(name):

FILE: abupy/UtilBu/ABuMacUtil.py
  function socket_bind_recv (line 14) | def socket_bind_recv(socket_fn, cmd_handler):
  function socket_send_msg (line 34) | def socket_send_msg(socket_fn, msg):
  function show_msg (line 46) | def show_msg(title, msg):
  function fold_free_size_mb (line 57) | def fold_free_size_mb(folder):

FILE: abupy/UtilBu/ABuMd5.py
  function _md5_obj (line 21) | def _md5_obj():
  function md5_from_binary (line 27) | def md5_from_binary(binary):
  function md5_from_file (line 34) | def md5_from_file(fn, block_m=1):
  function crc32_from_file (line 66) | def crc32_from_file(fn, block_m=1):

FILE: abupy/UtilBu/ABuOsUtil.py
  function show_msg (line 17) | def show_msg(title, msg, log=False):
  function socket_bind_recv (line 36) | def socket_bind_recv(socket_fn, cmd_handler):
  function socket_send_msg (line 51) | def socket_send_msg(socket_fn, msg):
  function fold_free_size_mb (line 66) | def fold_free_size_mb(folder):

FILE: abupy/UtilBu/ABuPlatform.py
  function is_32bit (line 17) | def is_32bit():
  function is_mac (line 22) | def is_mac():
  function is_windows (line 27) | def is_windows():
  function is_linux (line 32) | def is_linux():
  function platform_name (line 37) | def platform_name():
  function get_sys_info (line 42) | def get_sys_info():
  function show_versions (line 79) | def show_versions():

FILE: abupy/UtilBu/ABuProgress.py
  function do_clear_output (line 29) | def do_clear_output(wait=False):
  class UIProgress (line 44) | class UIProgress(object):
    method __init__ (line 47) | def __init__(self, a_pid):
    method update (line 55) | def update(self, p_progress, p_progress_text):
    method close (line 60) | def close(self):
  function _socket_cmd_handle (line 75) | def _socket_cmd_handle(socket_cmd):
  function ui_progress_socket_work (line 107) | def ui_progress_socket_work():
  function check_process_is_dead (line 129) | def check_process_is_dead():
  function do_check_process_is_dead (line 137) | def do_check_process_is_dead():
  function cache_socket_ready (line 157) | def cache_socket_ready():
  class AbuMulPidProgress (line 176) | class AbuMulPidProgress(object):
    method __init__ (line 179) | def __init__(self, total, label, show_progress=True):
    method init_ui_progress (line 200) | def init_ui_progress(self):
    method update_ui_progress (line 221) | def update_ui_progress(self, ps, ps_text):
    method close_ui_progress (line 242) | def close_ui_progress(self):
    method __enter__ (line 259) | def __enter__(self):
    method show (line 285) | def show(self, epoch=None, clear=True):
    method __exit__ (line 308) | def __exit__(self, exc_type, exc_val, exc_tb):
  class AbuBlockProgress (line 326) | class AbuBlockProgress(object):
    method __init__ (line 329) | def __init__(self, label, interval=1, max_step=20):
    method __enter__ (line 340) | def __enter__(self):
    method __exit__ (line 359) | def __exit__(self, exc_type, exc_val, exc_tb):
  class AbuProgress (line 367) | class AbuProgress(object):
    method __init__ (line 372) | def __init__(self, total, a_progress, label=None):
    method __enter__ (line 388) | def __enter__(self):
    method __exit__ (line 392) | def __exit__(self, exc_type, exc_val, exc_tb):
    method progress (line 398) | def progress(self):
    method progress (line 403) | def progress(self, a_progress):
    method show (line 412) | def show(self, a_progress=None, ext='', p_format="{}:{}:{}%"):

FILE: abupy/UtilBu/ABuRegUtil.py
  function regress_xy (line 28) | def regress_xy(x, y, mode=True, zoom=False, show=False):
  function regress_y (line 74) | def regress_y(y, mode=True, zoom=False, show=False):
  function calc_regress_deg (line 90) | def calc_regress_deg(y, show=True):
  function regress_xy_polynomial (line 107) | def regress_xy_polynomial(x, y, poly=1, zoom=False, show=False):
  function regress_y_polynomial (line 136) | def regress_y_polynomial(y, poly=1, zoom=False, show=False):
  function metrics_mae (line 149) | def metrics_mae(y, y_fit, show=True):
  function metrics_mse (line 164) | def metrics_mse(y, y_fit, show=True):
  function metrics_rmse (line 179) | def metrics_rmse(y, y_fit, show=True):
  function metrics_euclidean (line 194) | def metrics_euclidean(y, y_fit, show=True):
  function metrics_manhattan (line 208) | def metrics_manhattan(y, y_fit, show=True):
  function metrics_cosine (line 222) | def metrics_cosine(y, y_fit, show=True):
  function valid_poly (line 236) | def valid_poly(y, poly=1, zoom=False, show=True, metrics_func=metrics_rm...
  function least_valid_poly (line 287) | def least_valid_poly(y, zoom=False, show=True, metrics_func=metrics_rmse):
  function search_best_poly (line 309) | def search_best_poly(y, poly_min=1, poly_max=100, zoom=False, show=True,...

FILE: abupy/UtilBu/ABuScalerUtil.py
  function scaler_log10 (line 17) | def scaler_log10(group):
  function scaler_mm (line 79) | def scaler_mm(group):
  function scaler_std (line 142) | def scaler_std(group):
  function scaler_one (line 208) | def scaler_one(group):
  function scaler_matrix (line 262) | def scaler_matrix(group, type_look='look_max', mean_how=False):
  function scaler_xy (line 383) | def scaler_xy(x, y, type_look='look_max', mean_how=True):

FILE: abupy/UtilBu/ABuStatsUtil.py
  function _distance_matrix (line 39) | def _distance_matrix(distance_func, df, scale_end=True, to_similar=False):
  function _distance_xy (line 77) | def _distance_xy(distance_func, x, y):
  function euclidean_distance_xy (line 99) | def euclidean_distance_xy(x, y, to_similar=False):
  function euclidean_distance_matrix (line 123) | def euclidean_distance_matrix(df, scale_end=True, to_similar=False):
  function manhattan_distances_xy (line 175) | def manhattan_distances_xy(x, y, to_similar=False):
  function manhattan_distance_matrix (line 192) | def manhattan_distance_matrix(df, scale_end=True, to_similar=False):
  function cosine_distances_xy (line 246) | def cosine_distances_xy(x, y, to_similar=False):
  function cosine_distance_matrix (line 263) | def cosine_distance_matrix(df, scale_end=True, to_similar=False):
  function arr_to_pandas (line 321) | def arr_to_pandas(func):
  function arr_to_numpy (line 353) | def arr_to_numpy(func):
  function demean (line 381) | def demean(arr, rolling_window=0, show=False):
  function print_stats_sm (line 460) | def print_stats_sm(arr):
  function normality_stats (line 536) | def normality_stats(arr):
  function print_stats (line 594) | def print_stats(arr):
  function stats_dict (line 636) | def stats_dict(arr):
  class AbuMomentsTuple (line 661) | class AbuMomentsTuple(namedtuple('AbuMomentsTuple',
    method __repr__ (line 671) | def __repr__(self):
  function stats_namedtuple (line 679) | def stats_namedtuple(arr):
  function sigmoid (line 702) | def sigmoid(arr):

FILE: abupy/UtilBu/ABuStrUtil.py
  function _create_random_tmp (line 21) | def _create_random_tmp(salt_count, seed):
  function create_random_with_num (line 35) | def create_random_with_num(salt_count):
  function create_random_with_alpha (line 45) | def create_random_with_alpha(salt_count):
  function create_random_with_num_low (line 56) | def create_random_with_num_low(salt_count):
  function to_unicode (line 67) | def to_unicode(text, encoding=None, errors='strict'):
  function to_bytes (line 87) | def to_bytes(text, encoding=None, errors='strict'):
  function to_native_str (line 106) | def to_native_str(text, encoding=None, errors='strict'):
  function str_is_num10 (line 119) | def str_is_num10(a_str):
  function str_is_num16 (line 129) | def str_is_num16(a_str):
  function str_is_cn (line 139) | def str_is_cn(a_str):
  function digit_str (line 154) | def digit_str(item):
  function var_name (line 175) | def var_name(var, glb):

FILE: abupy/UtilBu/ABuWinUtil.py
  function show_msg (line 33) | def show_msg(title, msg):
  function socket_bind_recv (line 42) | def socket_bind_recv(socket_fn, cmd_handler):
  function socket_send_msg (line 64) | def socket_send_msg(socket_fn, msg):
  function fold_free_size_mb (line 79) | def fold_free_size_mb(folder):
  function drive_free_space (line 88) | def drive_free_space(drive):
  function max_drive (line 98) | def max_drive():
  class PyNOTIFYICONDATA (line 112) | class PyNOTIFYICONDATA:
    method pack (line 147) | def pack(self):
    method __setattr__ (line 163) | def __setattr__(self, name, value):
  class MainWindow (line 171) | class MainWindow:
    method __init__ (line 172) | def __init__(self, title, msg):
    method show_balloon (line 202) | def show_balloon(self, title, msg):
    method on_destroy (line 217) | def on_destroy(self, hwnd, msg, wparam, lparam):

FILE: abupy/WidgetBu/ABuWGBFBase.py
  class BFSubscriberMixin (line 19) | class BFSubscriberMixin(object):
    method subscriber_ui (line 25) | def subscriber_ui(self, labels):
    method notify_subscriber (line 46) | def notify_subscriber(self):
    method add_to_buy_factor (line 50) | def add_to_buy_factor(self, select, factor_unique_callable, factor_key...
  class BuyFactorWGManager (line 95) | class BuyFactorWGManager(WidgetFactorManagerBase):
    method _init_widget (line 98) | def _init_widget(self):
  class WidgetFactorBuyBase (line 125) | class WidgetFactorBuyBase(WidgetFactorBase):
    method __init__ (line 128) | def __init__(self, wg_manager):
    method _init_widget (line 147) | def _init_widget(self):
    method make_buy_factor_unique (line 152) | def make_buy_factor_unique(self):
    method add_buy_factor (line 162) | def add_buy_factor(self, bt):
    method add_buy_factor_grid (line 168) | def add_buy_factor_grid(self, bt):

FILE: abupy/WidgetBu/ABuWGBRun.py
  class WidgetRunLoopBack (line 39) | class WidgetRunLoopBack(WidgetBase):
    method __init__ (line 43) | def __init__(self):
    method _metrics_out_put (line 75) | def _metrics_out_put(self, metrics, abu_result_tuple):
    method run_loop_back (line 111) | def run_loop_back(self, bt):

FILE: abupy/WidgetBu/ABuWGBRunBase.py
  class WidgetEnvSetMixin (line 20) | class WidgetEnvSetMixin(object):
    method init_env_set_ui (line 32) | def init_env_set_ui(self):
    method on_data_mode_change (line 110) | def on_data_mode_change(self, change):
    method on_data_store_change (line 132) | def on_data_store_change(self, change):
    method on_fetch_mode_change (line 138) | def on_fetch_mode_change(self, change):
    method on_date_source_change (line 144) | def on_date_source_change(self, change):
  class WidgetTimeModeMixin (line 151) | class WidgetTimeModeMixin(object):
    method init_time_mode_ui (line 161) | def init_time_mode_ui(self):
    method on_time_mode_change (line 201) | def on_time_mode_change(self, change):
    method time_mode_str (line 212) | def time_mode_str(self):
  class WidgetMetricsSet (line 217) | class WidgetMetricsSet(object):
    method init_metrics_ui (line 237) | def init_metrics_ui(self):
  class WidgetRunTT (line 311) | class WidgetRunTT(WidgetBase, WidgetEnvSetMixin, WidgetTimeModeMixin, Wi...
    method __init__ (line 314) | def __init__(self):
    method time_mode_str (line 331) | def time_mode_str(self):

FILE: abupy/WidgetBu/ABuWGBSymbol.py
  class WidgetSymbolChoice (line 22) | class WidgetSymbolChoice(WidgetBase):
    method __init__ (line 26) | def __init__(self):
    method on_market_change (line 94) | def on_market_change(self, change):
    method on_already_select (line 98) | def on_already_select(self, select):
    method choice_symbols_select (line 105) | def choice_symbols_select(self, select):

FILE: abupy/WidgetBu/ABuWGBase.py
  function accordion_shut (line 28) | def accordion_shut(accordion):
  class WidgetBase (line 40) | class WidgetBase(object):
    method __call__ (line 43) | def __call__(self):
    method display (line 46) | def display(self):
  class WidgetFactorBase (line 51) | class WidgetFactorBase(six.with_metaclass(ABCMeta, WidgetBase)):
    method __init__ (line 54) | def __init__(self, wg_manager):
    method _init_widget (line 62) | def _init_widget(self):
    method delegate_class (line 67) | def delegate_class(self):
  class WidgetFactorManagerBase (line 72) | class WidgetFactorManagerBase(six.with_metaclass(ABCMeta, WidgetBase)):
    method __init__ (line 75) | def __init__(self, show_add_buy=True, add_button_style='default'):
    method _sub_children (line 104) | def _sub_children(self, children, n_split):
    method register_subscriber (line 116) | def register_subscriber(self, observe):
    method unregister_subscriber (line 120) | def unregister_subscriber(self, observe):
    method notify_subscriber (line 124) | def notify_subscriber(self):
    method _init_widget (line 131) | def _init_widget(self):
    method refresh_factor (line 135) | def refresh_factor(self):
    method remove_factor (line 140) | def remove_factor(self, select):
    method add_factor (line 148) | def add_factor(self, factor_dict, factor_desc_key, only_one=False):
  class WidgetSearchBox (line 171) | class WidgetSearchBox(WidgetBase):
    method __init__ (line 175) | def __init__(self, search_result_callable):
    method _do_search (line 204) | def _do_search(self, bt):
    method _search_input_change (line 211) | def _search_input_change(self, change):
  function permission_denied (line 223) | def permission_denied(*arg, **kwargs):

FILE: abupy/WidgetBu/ABuWGBuyFactor.py
  class BuyDMWidget (line 21) | class BuyDMWidget(WidgetFactorBuyBase):
    method _init_widget (line 24) | def _init_widget(self):
    method make_buy_factor_unique (line 92) | def make_buy_factor_unique(self):
    method delegate_class (line 102) | def delegate_class(self):
  class BuySDWidget (line 107) | class BuySDWidget(WidgetFactorBuyBase):
    method _init_widget (line 110) | def _init_widget(self):
    method make_buy_factor_unique (line 153) | def make_buy_factor_unique(self):
    method delegate_class (line 159) | def delegate_class(self):
  class BuyWDWidget (line 164) | class BuyWDWidget(WidgetFactorBuyBase):
    method _init_widget (line 167) | def _init_widget(self):
    method make_buy_factor_unique (line 228) | def make_buy_factor_unique(self):
    method delegate_class (line 236) | def delegate_class(self):
  class BuyXDWidget (line 241) | class BuyXDWidget(WidgetFactorBuyBase):
    method _init_widget (line 244) | def _init_widget(self):
    method make_buy_factor_unique (line 270) | def make_buy_factor_unique(self):
    method delegate_class (line 276) | def delegate_class(self):
  class BuyWMWidget (line 281) | class BuyWMWidget(WidgetFactorBuyBase):
    method _init_widget (line 284) | def _init_widget(self):
    method make_buy_factor_unique (line 308) | def make_buy_factor_unique(self):
    method delegate_class (line 314) | def delegate_class(self):
  class BuyDUWidget (line 319) | class BuyDUWidget(WidgetFactorBuyBase):
    method _init_widget (line 322) | def _init_widget(self):
    method make_buy_factor_unique (line 383) | def make_buy_factor_unique(self):
    method delegate_class (line 391) | def delegate_class(self):

FILE: abupy/WidgetBu/ABuWGCrossVal.py
  class WidgetCrossVal (line 24) | class WidgetCrossVal(WidgetBase):
    method __init__ (line 28) | def __init__(self):
    method run_cross_val (line 80) | def run_cross_val(self, bt):

FILE: abupy/WidgetBu/ABuWGDATool.py
  class WidgetDATool (line 19) | class WidgetDATool(WidgetToolBase):
    method __init__ (line 22) | def __init__(self, tool_set):
    method qcut_change_vc (line 65) | def qcut_change_vc(self, kl_dict, bt):
    method bcut_change_vc (line 70) | def bcut_change_vc(self, kl_dict, bt):
    method date_week_win (line 75) | def date_week_win(self, kl_dict, bt):
    method wave_change_rate (line 80) | def wave_change_rate(self, kl_dict, bt):
    method date_week_wave (line 85) | def date_week_wave(self, kl_dict, bt):
    method p_change_stats (line 90) | def p_change_stats(self, kl_dict, bt):

FILE: abupy/WidgetBu/ABuWGGridSearch.py
  class WidgetGridSearch (line 25) | class WidgetGridSearch(WidgetBase):
    method __init__ (line 29) | def __init__(self):
    method on_data_mode_change (line 59) | def on_data_mode_change(self, change):
    method run_grid_search (line 68) | def run_grid_search(self, bt):

FILE: abupy/WidgetBu/ABuWGPSBase.py
  class PickStockWGManager (line 19) | class PickStockWGManager(WidgetFactorManagerBase):
    method _init_widget (line 22) | def _init_widget(self):
    method seed_choice_symbol_update (line 46) | def seed_choice_symbol_update(self, seed_choice_symbol):
    method register (line 71) | def register(self, buy_factor_manger):
  class WidgetPickStockBase (line 78) | class WidgetPickStockBase(WidgetFactorBase, BFSubscriberMixin):
    method _pick_stock_base_ui (line 81) | def _pick_stock_base_ui(self):
    method __init__ (line 107) | def __init__(self, wg_manager):
    method _init_widget (line 126) | def _init_widget(self):
    method make_pick_stock_unique (line 131) | def make_pick_stock_unique(self):
    method add_pick_stock (line 141) | def add_pick_stock(self, bt):
    method add_pick_stock_to_buy_factor (line 147) | def add_pick_stock_to_buy_factor(self, select):

FILE: abupy/WidgetBu/ABuWGPickStock.py
  class PSPriceWidget (line 20) | class PSPriceWidget(WidgetPickStockBase):
    method _init_widget (line 23) | def _init_widget(self):
    method make_pick_stock_unique (line 76) | def make_pick_stock_unique(self):
    method delegate_class (line 91) | def delegate_class(self):
  class PSRegressAngWidget (line 96) | class PSRegressAngWidget(WidgetPickStockBase):
    method _init_widget (line 99) | def _init_widget(self):
    method make_pick_stock_unique (line 153) | def make_pick_stock_unique(self):
    method delegate_class (line 167) | def delegate_class(self):
  class PSShiftDistanceWidget (line 172) | class PSShiftDistanceWidget(WidgetPickStockBase):
    method _init_widget (line 175) | def _init_widget(self):
    method make_pick_stock_unique (line 225) | def make_pick_stock_unique(self):
    method delegate_class (line 238) | def delegate_class(self):
  class PSNTopWidget (line 243) | class PSNTopWidget(WidgetPickStockBase):
    method _init_widget (line 246) | def _init_widget(self):
    method seed_choice_symbol_key (line 281) | def seed_choice_symbol_key(self):
    method make_pick_stock_unique (line 285) | def make_pick_stock_unique(self):
    method delegate_class (line 297) | def delegate_class(self):

FILE: abupy/WidgetBu/ABuWGPosBase.py
  class PosWGManager (line 19) | class PosWGManager(WidgetFactorManagerBase):
    method __init__ (line 22) | def __init__(self):
    method _init_widget (line 30) | def _init_widget(self):
    method register (line 52) | def register(self, buy_factor_manger):
  class WidgetPositionBase (line 59) | class WidgetPositionBase(WidgetFactorBase, BFSubscriberMixin):
    method __init__ (line 62) | def __init__(self, wg_manager):
    method _init_widget (line 80) | def _init_widget(self):
    method make_position_unique (line 85) | def make_position_unique(self):
    method add_position (line 95) | def add_position(self, bt):
    method add_position_to_buy_factor (line 101) | def add_position_to_buy_factor(self, select):

FILE: abupy/WidgetBu/ABuWGQuantTool.py
  class WidgetQuantTool (line 20) | class WidgetQuantTool(WidgetBase):
    method __init__ (line 23) | def __init__(self):

FILE: abupy/WidgetBu/ABuWGSFBase.py
  class SellFactorWGManager (line 19) | class SellFactorWGManager(WidgetFactorManagerBase):
    method _init_widget (line 22) | def _init_widget(self):
    method register (line 50) | def register(self, buy_factor_manger):
  class WidgetFactorSellBase (line 57) | class WidgetFactorSellBase(WidgetFactorBase, BFSubscriberMixin):
    method __init__ (line 60) | def __init__(self, wg_manager):
    method _init_widget (line 93) | def _init_widget(self):
    method make_sell_factor_unique (line 98) | def make_sell_factor_unique(self):
    method add_sell_factor (line 108) | def add_sell_factor(self, bt):
    method add_sell_factor_grid (line 115) | def add_sell_factor_grid(self, bt):
    method add_sell_factor_to_buy_factor (line 123) | def add_sell_factor_to_buy_factor(self, select):

FILE: abupy/WidgetBu/ABuWGSMTool.py
  class WidgetSMTool (line 29) | class WidgetSMTool(WidgetToolBase):
    method __init__ (line 32) | def __init__(self, tool_set):
    method _init_widget_list_action (line 55) | def _init_widget_list_action(self, callback_analyse, analyse_name, n_t...
    method init_coint_corr_ui (line 70) | def init_coint_corr_ui(self):
    method init_relative_corr_ui (line 97) | def init_relative_corr_ui(self):
    method init_market_corr_ui (line 126) | def init_market_corr_ui(self):
    method init_corr_ui (line 168) | def init_corr_ui(self):
    method init_distances_ui (line 184) | def init_distances_ui(self):
    method corr_analyse (line 218) | def corr_analyse(self, cg_df, bt):
    method distances_analyse (line 224) | def distances_analyse(self, cg_df, bt):
    method coint_corr_market_analyse (line 238) | def coint_corr_market_analyse(self, bt):
    method corr_relative_market_analyse (line 253) | def corr_relative_market_analyse(self, bt):
    method corr_market_analyse (line 267) | def corr_market_analyse(self, bt):

FILE: abupy/WidgetBu/ABuWGSellFactor.py
  class SellDMWidget (line 22) | class SellDMWidget(WidgetFactorSellBase):
    method _init_widget (line 25) | def _init_widget(self):
    method make_sell_factor_unique (line 69) | def make_sell_factor_unique(self):
    method delegate_class (line 75) | def delegate_class(self):
  class SellAtrNStopWidget (line 80) | class SellAtrNStopWidget(WidgetFactorSellBase):
    method _init_widget (line 83) | def _init_widget(self):
    method make_sell_factor_unique (line 127) | def make_sell_factor_unique(self):
    method delegate_class (line 135) | def delegate_class(self):
  class SellCloseAtrNWidget (line 140) | class SellCloseAtrNWidget(WidgetFactorSellBase):
    method _init_widget (line 143) | def _init_widget(self):
    method make_sell_factor_unique (line 172) | def make_sell_factor_unique(self):
    method delegate_class (line 179) | def delegate_class(self):
  class SellPreAtrNWidget (line 184) | class SellPreAtrNWidget(WidgetFactorSellBase):
    method _init_widget (line 187) | def _init_widget(self):
    method make_sell_factor_unique (line 215) | def make_sell_factor_unique(self):
    method delegate_class (line 222) | def delegate_class(self):
  class SellXDWidget (line 227) | class SellXDWidget(WidgetFactorSellBase):
    method _init_widget (line 230) | def _init_widget(self):
    method make_sell_factor_unique (line 256) | def make_sell_factor_unique(self):
    method delegate_class (line 262) | def delegate_class(self):
  class SellNDWidget (line 267) | class SellNDWidget(WidgetFactorSellBase):
    method _init_widget (line 270) | def _init_widget(self):
    method make_sell_factor_unique (line 301) | def make_sell_factor_unique(self):
    method delegate_class (line 308) | def delegate_class(self):

FILE: abupy/WidgetBu/ABuWGStockInfo.py
  class WidgetSearchStockInfo (line 25) | class WidgetSearchStockInfo(WidgetBase):
    method __init__ (line 26) | def __init__(self):
    method on_search_result_click (line 30) | def on_search_result_click(self, select):
  class WidgetStockInfo (line 46) | class WidgetStockInfo(WidgetBase):
    method __init__ (line 49) | def __init__(self, symbol_code):
    method other_industries_symbol (line 62) | def other_industries_symbol(self, stock_info):
    method _sub_split (line 101) | def _sub_split(self, n_buttons, n_split):
    method _combine_stock_name (line 114) | def _combine_stock_name(self, stock_info, only_name=False):
    method stock_base_info (line 126) | def stock_base_info(self, symbol_code):
    method make_sub_tab_widget (line 196) | def make_sub_tab_widget(self, stock_info, sub_dict):

FILE: abupy/WidgetBu/ABuWGTLTool.py
  class WidgetTLTool (line 26) | class WidgetTLTool(WidgetToolBase):
    method _init_tip_label_with_step_x (line 30) | def _init_tip_label_with_step_x(self, callback_analyse, analyse_name, ...
    method init_rs_ui (line 66) | def init_rs_ui(self):
    method init_jump_ui (line 88) | def init_jump_ui(self):
    method init_shift_distance_ui (line 137) | def init_shift_distance_ui(self):
    method init_regress_ui (line 155) | def init_regress_ui(self):
    method init_golden_line_ui (line 185) | def init_golden_line_ui(self):
    method init_skeleton_ui (line 217) | def init_skeleton_ui(self):
    method init_pair_speed_ui (line 235) | def init_pair_speed_ui(self):
    method __init__ (line 265) | def __init__(self, tool_set):
    method _pair_speed_analyse (line 289) | def _pair_speed_analyse(self, bt):
    method _jump_line_analyse (line 307) | def _jump_line_analyse(self, kl, kl_tl, bt):
    method _rs_line_analyse (line 322) | def _rs_line_analyse(self, kl, kl_tl, bt):
    method _shift_distance_analyse (line 335) | def _shift_distance_analyse(self, kl, kl_tl, bt):
    method _regress_analyse (line 341) | def _regress_analyse(self, kl, kl_tl, bt):
    method _golden_line_analyse (line 351) | def _golden_line_analyse(self, kl, kl_tl, bt):
    method _skeleton_analyse (line 361) | def _skeleton_analyse(self, kl, kl_tl, bt):

FILE: abupy/WidgetBu/ABuWGToolBase.py
  class WidgetToolSet (line 28) | class WidgetToolSet(WidgetBase, WidgetEnvSetMixin, WidgetTimeModeMixin):
    method __init__ (line 31) | def __init__(self):
    method time_mode_str (line 43) | def time_mode_str(self):
  function single_fetch_symbol_analyse (line 48) | def single_fetch_symbol_analyse(func):
  function multi_fetch_symbol_analyse (line 67) | def multi_fetch_symbol_analyse(func):
  function multi_fetch_symbol_df_analyse (line 84) | def multi_fetch_symbol_df_analyse(col_key):
  class WidgetToolBase (line 110) | class WidgetToolBase(WidgetBase):
    method __init__ (line 113) | def __init__(self, tool_set):
    method _sub_children (line 132) | def _sub_children(self, children, n_split):
    method data_mode_recover (line 145) | def data_mode_recover(self, is_example_mode):
    method map_tip_target_label (line 163) | def map_tip_target_label(self, n_target):
    method _start_end_n_fold (line 176) | def _start_end_n_fold(self):
    method info_change_set_mode (line 192) | def info_change_set_mode(self, symbol):
    method _fetch_single_kl (line 208) | def _fetch_single_kl(self, symbol):
    method _fetch_multi_kl (line 218) | def _fetch_multi_kl(self, choice_symbol):
    method _fetch_multi_kl_col (line 231) | def _fetch_multi_kl_col(self, choice_symbol, col_key, na_val=0):
    method _choice_symbol_single (line 251) | def _choice_symbol_single(self, default=None):
    method _choice_symbol_pair (line 265) | def _choice_symbol_pair(self, default=None):
    method _choice_symbol_multi (line 282) | def _choice_symbol_multi(self):

FILE: abupy/WidgetBu/ABuWGUmp.py
  class WidgetUmp (line 41) | class WidgetUmp(WidgetBase):
    method __init__ (line 45) | def __init__(self):
    method load_abu_result (line 62) | def load_abu_result(self):
    method load_train_ump (line 72) | def load_train_ump(self, ump_select_ui):
    method run_before (line 84) | def run_before(self):
    method run_end (line 119) | def run_end(self, abu_result_tuple, choice_symbols, buy_desc_list, sel...
    method _init_manager_ui (line 139) | def _init_manager_ui(self):
    method _init_predict_ui (line 173) | def _init_predict_ui(self):
    method remove_ump_select (line 201) | def remove_ump_select(self, select):
    method on_ump_select (line 206) | def on_ump_select(self, select):
    method _init_train_ui (line 211) | def _init_train_ui(self):
    method _init_feature_ui (line 241) | def _init_feature_ui(self):
    method _parse_custom (line 263) | def _parse_custom(self):
    method _do_delete_ump (line 284) | def _do_delete_ump(self, bt):
    method _do_delete_abu_result (line 312) | def _do_delete_abu_result(self, bt):
    method _do_train (line 320) | def _do_train(self, bt):

FILE: abupy/WidgetBu/ABuWGUpdate.py
  class WidgetUpdate (line 24) | class WidgetUpdate(WidgetBase, WidgetTimeModeMixin):
    method __init__ (line 27) | def __init__(self):
    method run_yun_down (line 109) | def run_yun_down(self, bt):
    method run_kl_update (line 114) | def run_kl_update(self, bt):
    method time_mode_str (line 136) | def time_mode_str(self):
    method on_date_source_change (line 140) | def on_date_source_change(self, change):
    method on_market_change (line 145) | def on_market_change(self, change):

FILE: abupy/WidgetBu/ABuWGVerifyTool.py
  class WidgetVerifyTool (line 19) | class WidgetVerifyTool(WidgetBase):
    method __init__ (line 22) | def __init__(self):
Copy disabled (too large) Download .json
Condensed preview — 327 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (16,485K chars).
[
  {
    "path": ".gitattributes",
    "chars": 32,
    "preview": "*.ipynb linguist-language=Python"
  },
  {
    "path": ".gitignore",
    "chars": 96,
    "preview": ".ipynb_checkpoints*\n.idea\n.DS_Store\nlogging.log\np.sh\n*.pyc\ntmp\ntest.py\n/abupy/RomDataBu/df_kl.h5"
  },
  {
    "path": "LICENSE",
    "chars": 35068,
    "preview": "GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation,"
  },
  {
    "path": "abupy/AlphaBu/ABuAlpha.py",
    "chars": 330,
    "preview": "from __future__ import absolute_import\n\n# noinspection PyUnresolvedReferences\nfrom .ABuPickStockExecute import do_pick_s"
  },
  {
    "path": "abupy/AlphaBu/ABuPickBase.py",
    "chars": 1239,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    择时与选股抽象基类\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_func"
  },
  {
    "path": "abupy/AlphaBu/ABuPickStockExecute.py",
    "chars": 1652,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    包装选股worker进行,完善前后工作\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import "
  },
  {
    "path": "abupy/AlphaBu/ABuPickStockMaster.py",
    "chars": 4699,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股并行多任务调度模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_fu"
  },
  {
    "path": "abupy/AlphaBu/ABuPickStockWorker.py",
    "chars": 5566,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股具体工作者,整合金融时间序列,选股因子,资金类进行\n    选股操作,在择时金融时间序列之前一段时间上迭代初始交易对象\n    进行选股因子的拟合操作\n\"\"\"\n\nfrom"
  },
  {
    "path": "abupy/AlphaBu/ABuPickTimeExecute.py",
    "chars": 7716,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    多支交易对象进行择时操作封装模块,内部通过AbuPickTimeWorker进行\n    择时,包装完善前后工作,包括多进程下的进度显示,错误处理捕获,结果\n    处理等事"
  },
  {
    "path": "abupy/AlphaBu/ABuPickTimeMaster.py",
    "chars": 4650,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    择时并行多任务调度模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division"
  },
  {
    "path": "abupy/AlphaBu/ABuPickTimeWorker.py",
    "chars": 11800,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    择时具体工作者,整合金融时间序列,买入因子,卖出因子,资金类进行\n    择时操作,以时间驱动择时事件的发生\n\"\"\"\n\nfrom __future__ import abso"
  },
  {
    "path": "abupy/AlphaBu/__init__.py",
    "chars": 666,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuPickBase import AbuPickTimeWorkBase, AbuPickStockWorkBase\n\nfrom .ABuPic"
  },
  {
    "path": "abupy/BetaBu/ABuAtrPosition.py",
    "chars": 1760,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    示例仓位管理:atr仓位管理模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import absolute_i"
  },
  {
    "path": "abupy/BetaBu/ABuBeta.py",
    "chars": 240,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import absolute_import\n\n# noinspection all\nfrom . import ABuPositionBase as pos"
  },
  {
    "path": "abupy/BetaBu/ABuKellyPosition.py",
    "chars": 1275,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例仓位管理:kelly仓位管理模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import absolute_impor"
  },
  {
    "path": "abupy/BetaBu/ABuPositionBase.py",
    "chars": 2545,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    风险控制仓位管理基础\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\n"
  },
  {
    "path": "abupy/BetaBu/ABuPtPosition.py",
    "chars": 1781,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例仓位管理:示例价格位置仓位模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import absolute_import"
  },
  {
    "path": "abupy/BetaBu/__init__.py",
    "chars": 381,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuPositionBase import AbuPositionBase\nfrom .ABuAtrPosition import AbuAtrP"
  },
  {
    "path": "abupy/CheckBu/ABuChecker.py",
    "chars": 9035,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    检查类,检查函数对象、函数参数、函数返回值\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import"
  },
  {
    "path": "abupy/CheckBu/ABuChecks.py",
    "chars": 2289,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    检查范围的函数\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_impo"
  },
  {
    "path": "abupy/CheckBu/ABuFuncUtil.py",
    "chars": 2833,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    函数对象的工具类\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/CheckBu/ABuProcessor.py",
    "chars": 2795,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    预处理函数参数或返回值\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_"
  },
  {
    "path": "abupy/CheckBu/__init__.py",
    "chars": 271,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuProcessor import arg_process, return_process\nfrom .ABuChecker import Fu"
  },
  {
    "path": "abupy/CoreBu/ABu.py",
    "chars": 9148,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import p"
  },
  {
    "path": "abupy/CoreBu/ABuBase.py",
    "chars": 5073,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    类基础通用模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfro"
  },
  {
    "path": "abupy/CoreBu/ABuDeprecated.py",
    "chars": 2168,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    Deprecated警告模块\n\"\"\"\n\nimport warnings\n\nfrom ..CoreBu.ABuFixes import six\n\n\nclass AbuDepre"
  },
  {
    "path": "abupy/CoreBu/ABuEnv.py",
    "chars": 14687,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    全局环境配置模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfr"
  },
  {
    "path": "abupy/CoreBu/ABuEnvProcess.py",
    "chars": 5058,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    多任务子进程拷贝跟随主进程设置模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import pr"
  },
  {
    "path": "abupy/CoreBu/ABuFixes.py",
    "chars": 12377,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    对各个依赖库不同版本,不同系统的规范进行统一以及问题修正模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __futur"
  },
  {
    "path": "abupy/CoreBu/ABuParallel.py",
    "chars": 3968,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    并行封装模块,主要针对不同平台统一接口规范:\n\n    windows 上使用joblib进行长时间的多任务,如超过10小时以上时,在任何最后有系统pop任务\n    的错误"
  },
  {
    "path": "abupy/CoreBu/ABuPdHelper.py",
    "chars": 8624,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    封装pandas中版本兼容问题,保持接口规范情况下,避免警告\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __futur"
  },
  {
    "path": "abupy/CoreBu/ABuStore.py",
    "chars": 11001,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"针对交易回测结果存储,读取模块\"\"\"\n\nimport os\nfrom collections import namedtuple\nfrom enum import Enum\nimpor"
  },
  {
    "path": "abupy/CoreBu/__init__.py",
    "chars": 1737,
    "preview": "# IN ABu LIST __all__\nfrom __future__ import absolute_import\n\nfrom .ABuFixes import *\nfrom .ABuPdHelper import *\nfrom . "
  },
  {
    "path": "abupy/CrawlBu/ABuXqApi.py",
    "chars": 2821,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ im"
  },
  {
    "path": "abupy/CrawlBu/ABuXqConsts.py",
    "chars": 1035,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ im"
  },
  {
    "path": "abupy/CrawlBu/ABuXqCrawl.py",
    "chars": 5213,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ im"
  },
  {
    "path": "abupy/CrawlBu/ABuXqCrawlImp.py",
    "chars": 10154,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ im"
  },
  {
    "path": "abupy/CrawlBu/ABuXqFile.py",
    "chars": 5024,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ im"
  },
  {
    "path": "abupy/CrawlBu/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "abupy/DLBu/ABuDL.py",
    "chars": 171,
    "preview": "from __future__ import absolute_import\n\n# noinspection PyUnresolvedReferences\nfrom .ABuDLImgStd import *\n# noinspection "
  },
  {
    "path": "abupy/DLBu/ABuDLImgStd.py",
    "chars": 3037,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    深度学习工具模块,为caffe等工具库标准化图片格式\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ "
  },
  {
    "path": "abupy/DLBu/ABuDLTVSplit.py",
    "chars": 1553,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    深度学习工具模块,为caffe工具库做数据集准备,\n    切割训练集\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __"
  },
  {
    "path": "abupy/DLBu/__init__.py",
    "chars": 134,
    "preview": "from __future__ import absolute_import\n\n# import ABuDLImgStd\n# import ABuDLTVSplit\nfrom . import ABuDL as dl\n\n__all__ = "
  },
  {
    "path": "abupy/DLBu/pb/deploy.prototxt",
    "chars": 35862,
    "preview": "name: \"GoogleNet\"\nlayer {\n  name: \"data\"\n  type: \"Input\"\n  top: \"data\"\n  input_param { shape: { dim: 10 dim: 3 dim: 224 "
  },
  {
    "path": "abupy/DLBu/pb/solver.prototxt",
    "chars": 388,
    "preview": "net: \"/Users/Bailey/Desktop/my_work/abu/Caffe/pb/train_val.prototxt\"\ntest_iter: 100\ntest_interval: 2000\ntest_initializat"
  },
  {
    "path": "abupy/DLBu/pb/train_val.prototxt",
    "chars": 40096,
    "preview": "name: \"GoogleNet\"\nlayer {\n  name: \"data\"\n  type: \"Data\"\n  top: \"data\"\n  top: \"label\"\n  include {\n    phase: TRAIN\n  }\n  "
  },
  {
    "path": "abupy/DLBu/sh/Lmdb.sh",
    "chars": 611,
    "preview": "#!/usr/bin/env bash\necho \"Begin...\"\nROOTFOLDER=$1\nOUTPUT=$2\n\necho $ROOTFOLDER\necho $OUTPUT\n\nROOTFOLDER=/Users/Bailey/Des"
  },
  {
    "path": "abupy/DLBu/sh/Mean.sh",
    "chars": 303,
    "preview": "#!/usr/bin/env bash\necho \"Begin...\"\n\nLMDB=../gen/img_train_lmdb\nMEANBIN=/Users/Bailey/caffe/build/tools/compute_image_me"
  },
  {
    "path": "abupy/DLBu/sh/Train.sh",
    "chars": 158,
    "preview": "#!/usr/bin/env bash\necho \"Begin....\"\n\nCAFEBIN=/Users/Bailey/caffe/build/tools/caffe\nSOLVER=../pb/solver.prototxt\n$CAFEBI"
  },
  {
    "path": "abupy/ExtBu/__init__.py",
    "chars": 42,
    "preview": "\n\"\"\"\nExternal, bundled dependencies.\n\n\"\"\"\n"
  },
  {
    "path": "abupy/ExtBu/empyrical/__init__.py",
    "chars": 1151,
    "preview": "#\n# Copyright 2016 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not us"
  },
  {
    "path": "abupy/ExtBu/empyrical/_version.py",
    "chars": 471,
    "preview": "\n# This file was generated by 'versioneer.py' (0.16) from\n# revision-control system data, or from the parent directory n"
  },
  {
    "path": "abupy/ExtBu/empyrical/stats.py",
    "chars": 33248,
    "preview": "#\n# Copyright 2016 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not us"
  },
  {
    "path": "abupy/ExtBu/empyrical/utils.py",
    "chars": 1048,
    "preview": "#\n# Copyright 2016 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not us"
  },
  {
    "path": "abupy/ExtBu/funcsigs.py",
    "chars": 29982,
    "preview": "# Copyright 2001-2013 Python Software Foundation; All Rights Reserved\n\"\"\"Function signature objects for callables\n\nBack "
  },
  {
    "path": "abupy/ExtBu/futures/__init__.py",
    "chars": 887,
    "preview": "# Copyright 2009 Brian Quinlan. All Rights Reserved.\n# Licensed to PSF under a Contributor Agreement.\n\n\"\"\"Execute comput"
  },
  {
    "path": "abupy/ExtBu/futures/_base.py",
    "chars": 21108,
    "preview": "# Copyright 2009 Brian Quinlan. All Rights Reserved.\n# Licensed to PSF under a Contributor Agreement.\n\nimport collection"
  },
  {
    "path": "abupy/ExtBu/futures/process.py",
    "chars": 14894,
    "preview": "# Copyright 2009 Brian Quinlan. All Rights Reserved.\n# Licensed to PSF under a Contributor Agreement.\n\n\"\"\"Implements Pro"
  },
  {
    "path": "abupy/ExtBu/futures/thread.py",
    "chars": 4658,
    "preview": "# Copyright 2009 Brian Quinlan. All Rights Reserved.\n# Licensed to PSF under a Contributor Agreement.\n\n\"\"\"Implements Thr"
  },
  {
    "path": "abupy/ExtBu/joblib/__init__.py",
    "chars": 5101,
    "preview": "\"\"\" Joblib is a set of tools to provide **lightweight pipelining in\nPython**. In particular, joblib offers:\n\n  1. transp"
  },
  {
    "path": "abupy/ExtBu/joblib/_compat.py",
    "chars": 467,
    "preview": "\"\"\"\nCompatibility layer for Python 3/Python 2 single codebase\n\"\"\"\nimport sys\n\nPY3_OR_LATER = sys.version_info[0] >= 3\nPY"
  },
  {
    "path": "abupy/ExtBu/joblib/_memory_helpers.py",
    "chars": 3605,
    "preview": "try:\n    # Available in Python 3\n    from tokenize import open as open_py_source\n\nexcept ImportError:\n    # Copied from "
  },
  {
    "path": "abupy/ExtBu/joblib/_multiprocessing_helpers.py",
    "chars": 1179,
    "preview": "\"\"\"Helper module to factorize the conditional multiprocessing import logic\n\nWe use a distinct module to simplify import "
  },
  {
    "path": "abupy/ExtBu/joblib/_parallel_backends.py",
    "chars": 14309,
    "preview": "\"\"\"\nBackends for embarrassingly parallel code.\n\"\"\"\n\nimport gc\nimport os\nimport sys\nimport warnings\nimport threading\nfrom"
  },
  {
    "path": "abupy/ExtBu/joblib/disk.py",
    "chars": 3235,
    "preview": "\"\"\"\nDisk management utilities.\n\"\"\"\n\n# Authors: Gael Varoquaux <gael dot varoquaux at normalesup dot org>\n#          Lars"
  },
  {
    "path": "abupy/ExtBu/joblib/format_stack.py",
    "chars": 15179,
    "preview": "\"\"\"\nRepresent an exception with a lot of information.\n\nProvides 2 useful functions:\n\nformat_exc: format an exception int"
  },
  {
    "path": "abupy/ExtBu/joblib/func_inspect.py",
    "chars": 13094,
    "preview": "\"\"\"\nMy own variation on function-specific inspect-like features.\n\"\"\"\n\n# Author: Gael Varoquaux <gael dot varoquaux at no"
  },
  {
    "path": "abupy/ExtBu/joblib/hashing.py",
    "chars": 10120,
    "preview": "\"\"\"\nFast cryptographic hash of Python objects, with a special case for fast\nhashing of numpy arrays.\n\"\"\"\n\n# Author: Gael"
  },
  {
    "path": "abupy/ExtBu/joblib/logger.py",
    "chars": 5135,
    "preview": "\"\"\"\nHelpers for logging.\n\nThis module needs much love to become useful.\n\"\"\"\n\n# Author: Gael Varoquaux <gael dot varoquau"
  },
  {
    "path": "abupy/ExtBu/joblib/memory.py",
    "chars": 36332,
    "preview": "\"\"\"\nA context object for caching a function's return value each time it\nis called with the same input arguments.\n\n\"\"\"\n\n#"
  },
  {
    "path": "abupy/ExtBu/joblib/my_exceptions.py",
    "chars": 3843,
    "preview": "\"\"\"\nExceptions\n\"\"\"\n# Author: Gael Varoquaux < gael dot varoquaux at normalesup dot org >\n# Copyright: 2010, Gael Varoqua"
  },
  {
    "path": "abupy/ExtBu/joblib/numpy_pickle.py",
    "chars": 23222,
    "preview": "\"\"\"Utilities for fast persistence of big data, with optional compression.\"\"\"\n\n# Author: Gael Varoquaux <gael dot varoqua"
  },
  {
    "path": "abupy/ExtBu/joblib/numpy_pickle_compat.py",
    "chars": 8440,
    "preview": "\"\"\"Numpy pickle compatibility functions.\"\"\"\n\nimport pickle\nimport os\nimport zlib\nfrom io import BytesIO\n\nfrom ._compat i"
  },
  {
    "path": "abupy/ExtBu/joblib/numpy_pickle_utils.py",
    "chars": 22668,
    "preview": "\"\"\"Utilities for fast persistence of big data, with optional compression.\"\"\"\n\n# Author: Gael Varoquaux <gael dot varoqua"
  },
  {
    "path": "abupy/ExtBu/joblib/parallel.py",
    "chars": 32728,
    "preview": "\"\"\"\nHelpers for embarrassingly parallel code.\n\"\"\"\n# Author: Gael Varoquaux < gael dot varoquaux at normalesup dot org >\n"
  },
  {
    "path": "abupy/ExtBu/joblib/pool.py",
    "chars": 25033,
    "preview": "\"\"\"Custom implementation of multiprocessing.Pool with custom pickler.\n\nThis module provides efficient ways of working wi"
  },
  {
    "path": "abupy/ExtBu/joblib/testing.py",
    "chars": 3042,
    "preview": "\"\"\"\nHelper for testing.\n\"\"\"\n\nimport sys\nimport warnings\nimport os.path\nimport re\nimport subprocess\nimport threading\n\nfro"
  },
  {
    "path": "abupy/ExtBu/odict.py",
    "chars": 9149,
    "preview": "# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.\n# Passes Python2.7's test suite and i"
  },
  {
    "path": "abupy/ExtBu/six.py",
    "chars": 20588,
    "preview": "\"\"\"Utilities for writing code that runs on Python 2 and 3\"\"\"\n\n# Copyright (c) 2010-2013 Benjamin Peterson\n#\n# Permission"
  },
  {
    "path": "abupy/FactorBuyBu/ABuBuyFactorWrap.py",
    "chars": 3235,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"买入因子类装饰器模块\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n"
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyBase.py",
    "chars": 15979,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    买入择时策略因子基础模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_f"
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyBreak.py",
    "chars": 3162,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    买入择时示例因子:突破买入择时因子\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import pr"
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyDM.py",
    "chars": 8259,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    买入择时示例因子:动态自适应双均线策略\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import "
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyDemo.py",
    "chars": 13045,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    示例买入择时因子\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_funct"
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyTrend.py",
    "chars": 4814,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    买入择时示例因子:长线趋势跟踪与短线均值回复的配合\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ i"
  },
  {
    "path": "abupy/FactorBuyBu/ABuFactorBuyWD.py",
    "chars": 3748,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    买入择时示例因子:日胜率均值买入择时因子\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import"
  },
  {
    "path": "abupy/FactorBuyBu/__init__.py",
    "chars": 1029,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuFactorBuyBase import AbuFactorBuyBase, AbuFactorBuyXD, AbuFactorBuyTD, "
  },
  {
    "path": "abupy/FactorSellBu/ABuFS.py",
    "chars": 204,
    "preview": "from __future__ import absolute_import\n\n# noinspection PyUnresolvedReferences\nfrom . import ABuFactorCloseAtrNStop as cl"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorAtrNStop.py",
    "chars": 2481,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子:n倍atr(止盈止损)择时卖出策略\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ "
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorCloseAtrNStop.py",
    "chars": 2306,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子: 较小利润值 < 买入后最大收益价格 - 今日价格 < 较大利润值 -> 止盈卖出\n    只做为单边止盈因子使用,作为利润保护因子使用\n\"\"\"\n\nfrom"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorPreAtrNStop.py",
    "chars": 1441,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子:单日最大跌幅n倍atr止损\n    做为单边止损因子使用,作为风险控制保护因子\n\"\"\"\n\nfrom __future__ import absolute_i"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorSellBase.py",
    "chars": 6508,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时策略因子基础模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_f"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorSellBreak.py",
    "chars": 1653,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子:突破卖出择时因子\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import pr"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorSellDM.py",
    "chars": 2358,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子,双均线策略\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print"
  },
  {
    "path": "abupy/FactorSellBu/ABuFactorSellNDay.py",
    "chars": 1239,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    卖出择时示例因子:n日卖出策略,不管什么结果,买入后只持有N天\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __futu"
  },
  {
    "path": "abupy/FactorSellBu/__init__.py",
    "chars": 733,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuFactorSellBase import AbuFactorSellBase, AbuFactorSellXD, ESupportDirec"
  },
  {
    "path": "abupy/IndicatorBu/ABuND.py",
    "chars": 262,
    "preview": "from __future__ import absolute_import\n\nfrom . import ABuNDAtr as atr\nfrom . import ABuNDBoll as boll\nfrom . import ABuN"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDAtr.py",
    "chars": 7482,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\nATR\n\nATR又称 Average true range平均真实波动范围,简称ATR指标,是由J.Welles Wilder 发明的,ATR指标主要是用来衡量市场波动的强烈度,\n即"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDBase.py",
    "chars": 3271,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    技术指标工具基础模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import print_fun"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDBoll.py",
    "chars": 4259,
    "preview": "# -*- encoding:utf-8 -*-\n\n\"\"\"\n股价的标准差及其信赖区间,从而确定股价的波动范围及未来走势,利用波带显示股价的安全高低价位,因而也被称为布林带。\n其上下限范围不固定,随股价的滚动而变化。布林指标和麦克指标MIKE"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDMa.py",
    "chars": 6325,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    移动平均线,Moving Average,简称MA,原本的意思是移动平均,由于我们将其制作成线形,所以一般称之为移动平均线,简称均线。\n    它是将某一段时间的收盘价之和除"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDMacd.py",
    "chars": 5456,
    "preview": "# -*- encoding:utf-8 -*-\n\n\"\"\"\nMACD\n\nMACD称为指数平滑异动移动平均线,是从双指数移动平均线发展而来的,由快的加权移动均线(EMA12)减去慢的加权移动均线(EMA26)\n得到DIF,再用DIF - (快"
  },
  {
    "path": "abupy/IndicatorBu/ABuNDRsi.py",
    "chars": 4500,
    "preview": "# -*- encoding:utf-8 -*-\n\n\"\"\"\n相对强弱指数(RSI)是通过比较一段时期内的平均收盘涨数和平均收盘跌数来分析市场买沽盘的意向和实力,\n从而作出未来市场的走势\n\n计算方法:\n\n具体计算实现可阅读代码中_calc_r"
  },
  {
    "path": "abupy/IndicatorBu/__init__.py",
    "chars": 90,
    "preview": "from __future__ import absolute_import\n\nfrom . import ABuND as nd\n\n__all__ = [\n    'nd'\n]\n"
  },
  {
    "path": "abupy/MLBu/ABuML.py",
    "chars": 82320,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n中间层,从上层拿到x,y,df\n拥有create estimator\n\n\"\"\"\nfrom __future__ import absolute_import\nfrom __futur"
  },
  {
    "path": "abupy/MLBu/ABuMLApi.py",
    "chars": 389,
    "preview": "from __future__ import absolute_import\n\n# noinspection PyUnresolvedReferences\nfrom .ABuMLBinsCs import *\n# noinspection "
  },
  {
    "path": "abupy/MLBu/ABuMLBinsCs.py",
    "chars": 3745,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"直观可视化制作qcut的bins点\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\n"
  },
  {
    "path": "abupy/MLBu/ABuMLCreater.py",
    "chars": 35526,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    封装常用学习器的初始化流程的模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import abso"
  },
  {
    "path": "abupy/MLBu/ABuMLExecute.py",
    "chars": 20920,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"封装常用的分析方式及流程模块\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfr"
  },
  {
    "path": "abupy/MLBu/ABuMLGrid.py",
    "chars": 15374,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"封装grid search相关操作模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_functio"
  },
  {
    "path": "abupy/MLBu/ABuMLPd.py",
    "chars": 11806,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"封装AbuML为业务逻辑层进行规范模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_functio"
  },
  {
    "path": "abupy/MLBu/__init__.py",
    "chars": 324,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuML import AbuML\nfrom .ABuMLCreater import AbuMLCreater\nfrom .ABuMLPd im"
  },
  {
    "path": "abupy/MarketBu/ABuDataBase.py",
    "chars": 5966,
    "preview": "# coding=utf-8\n\"\"\"\n    数据源基础模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future"
  },
  {
    "path": "abupy/MarketBu/ABuDataCache.py",
    "chars": 14528,
    "preview": "# coding=utf-8\n\"\"\"\n    对数据采集进行存储,读取,以及数据更新merge策略等实现模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ impor"
  },
  {
    "path": "abupy/MarketBu/ABuDataCheck.py",
    "chars": 8002,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"本地缓存监测模块\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfr"
  },
  {
    "path": "abupy/MarketBu/ABuDataFeed.py",
    "chars": 17232,
    "preview": "# coding=utf-8\n\"\"\"\n    内置数据源示例实现模块:\n\n    所有数据接口仅供学习使用,以及最基本使用测试,如需进一步使用,请购买数据\n\"\"\"\nfrom __future__ import absolute_import"
  },
  {
    "path": "abupy/MarketBu/ABuDataParser.py",
    "chars": 12334,
    "preview": "# coding=utf-8\n\"\"\"\n    数据源解析模块以及示例内置数据源的解析类实现\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import divisio"
  },
  {
    "path": "abupy/MarketBu/ABuDataSource.py",
    "chars": 7993,
    "preview": "# coding=utf-8\n\"\"\"\n    数据源模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__"
  },
  {
    "path": "abupy/MarketBu/ABuHkUnit.py",
    "chars": 2796,
    "preview": "# coding=utf-8\n\"\"\"\n    港股每一手交易数量模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfro"
  },
  {
    "path": "abupy/MarketBu/ABuIndustries.py",
    "chars": 15118,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    行业分类模块,仅支持美股,a股,港股\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import ab"
  },
  {
    "path": "abupy/MarketBu/ABuMarket.py",
    "chars": 14408,
    "preview": "# coding=utf-8\n\"\"\"\n    市场相关切割,选股,等操作模块\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute_import\n"
  },
  {
    "path": "abupy/MarketBu/ABuMarketDrawing.py",
    "chars": 13847,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    市场,数据可视化绘制模块\n\"\"\"\nfrom __future__ import division\nfrom __future__ import print_function\n"
  },
  {
    "path": "abupy/MarketBu/ABuNetWork.py",
    "chars": 3077,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    网络统一接口模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/MarketBu/ABuSymbol.py",
    "chars": 15389,
    "preview": "# coding=utf-8\n\"\"\"\n    symbol模块\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom __"
  },
  {
    "path": "abupy/MarketBu/ABuSymbolFutures.py",
    "chars": 7583,
    "preview": "# coding=utf-8\n\"\"\"\n    期货symbol数据模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfr"
  },
  {
    "path": "abupy/MarketBu/ABuSymbolPd.py",
    "chars": 16180,
    "preview": "# coding=utf-8\n\"\"\"\n    数据对外接口模块,其它模块需要数据都只应该使用ABuSymbolPd, 不应涉及其它内部模块的使用\n\"\"\"\n\nfrom __future__ import absolute_import\nfro"
  },
  {
    "path": "abupy/MarketBu/ABuSymbolStock.py",
    "chars": 13742,
    "preview": "# coding=utf-8\n\"\"\"\n    股票类型的symbol模块,a股,美股,港股\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute_"
  },
  {
    "path": "abupy/MarketBu/__init__.py",
    "chars": 1196,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuDataBase import BaseMarket, FuturesBaseMarket, StockBaseMarket, TCBaseM"
  },
  {
    "path": "abupy/MetricsBu/ABuCrossVal.py",
    "chars": 12878,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"策略验证模块\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __fut"
  },
  {
    "path": "abupy/MetricsBu/ABuGridHelper.py",
    "chars": 6890,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    组合参数辅助模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/MetricsBu/ABuGridSearch.py",
    "chars": 19643,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"借鉴sklearn GridSearch,针对买入因子,卖出因子,选股因子最合进行最优寻找分析\"\"\"\n\nfrom __future__ import print_function\nfr"
  },
  {
    "path": "abupy/MetricsBu/ABuMetrics.py",
    "chars": 39,
    "preview": "from __future__ import absolute_import\n"
  },
  {
    "path": "abupy/MetricsBu/ABuMetricsBase.py",
    "chars": 24104,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"度量模块基础\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __futu"
  },
  {
    "path": "abupy/MetricsBu/ABuMetricsFutures.py",
    "chars": 3730,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"期货度量模块\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __futu"
  },
  {
    "path": "abupy/MetricsBu/ABuMetricsScore.py",
    "chars": 7445,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"回测结果评分模块\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfro"
  },
  {
    "path": "abupy/MetricsBu/ABuMetricsTC.py",
    "chars": 374,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"比特币度量模块\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __fu"
  },
  {
    "path": "abupy/MetricsBu/__init__.py",
    "chars": 673,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuGridSearch import ParameterGrid, GridSearch\nfrom .ABuCrossVal import Ab"
  },
  {
    "path": "abupy/PickStockBu/ABuPickRegressAngMinMax.py",
    "chars": 1477,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股示例因子:价格拟合角度选股因子\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import abso"
  },
  {
    "path": "abupy/PickStockBu/ABuPickSimilarNTop.py",
    "chars": 3536,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股示例因子:相似度选股因子,主要示例fit_first_choice\n\"\"\"\n\nfrom __future__ import print_function\nfrom __f"
  },
  {
    "path": "abupy/PickStockBu/ABuPickStock.py",
    "chars": 191,
    "preview": "from __future__ import absolute_import\n\n# noinspection all\nfrom . import ABuPickSimilarNTop as similar_top\n# noinspectio"
  },
  {
    "path": "abupy/PickStockBu/ABuPickStockBase.py",
    "chars": 2276,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股因子抽象基类\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/PickStockBu/ABuPickStockDemo.py",
    "chars": 3856,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股示例因子:价格选股因子\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import divisio"
  },
  {
    "path": "abupy/PickStockBu/ABuPickStockPriceMinMax.py",
    "chars": 1462,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    选股示例因子:价格选股因子\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute"
  },
  {
    "path": "abupy/PickStockBu/__init__.py",
    "chars": 559,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuPickRegressAngMinMax import AbuPickRegressAngMinMax\nfrom .ABuPickSimila"
  },
  {
    "path": "abupy/RomDataBu/futures_cn.csv",
    "chars": 1170,
    "preview": ",symbol,product,min_deposit,min_unit,commission,exchange\n0,V0,PVC,0.07,5,2,DCE\n1,P0,棕榈,0.07,10,2.5,DCE\n2,B0,豆二,0.05,10,2"
  },
  {
    "path": "abupy/RomDataBu/futures_gb.csv",
    "chars": 488,
    "preview": ",symbol,product,min_deposit,min_unit,exchange\n0,NID,伦敦镍,0.07,6,LME\n1,PBD,伦敦铅,0.1,25,LME\n2,SND,伦敦锡,0.05,5,LME\n3,ZSD,伦敦锌,0"
  },
  {
    "path": "abupy/RomDataBu/hk_unit.csv",
    "chars": 29128,
    "preview": ",unit\nhk02011,2000\nhk01396,2000\nhk08112,4800\nhk08198,4000\nhk01143,4000\nhk00886,3000\nhk00559,10000\nhk00901,20000\nhk08292,"
  },
  {
    "path": "abupy/RomDataBu/hq_nav.txt",
    "chars": 904925,
    "preview": "(dp1\nccopy_reg\n_reconstructor\np2\n(cbs4.element\nNavigableString\np3\nc__builtin__\nunicode\np4\nV\\u9999\\u6e2f\\u80a1\\u5e02\ntRp5"
  },
  {
    "path": "abupy/RomDataBu/ml_test.csv",
    "chars": 60302,
    "preview": "PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked\n1,0,3,\"Braund, Mr. Owen Harris\",male,22,"
  },
  {
    "path": "abupy/RomDataBu/stock_code_CN.csv",
    "chars": 1146744,
    "preview": ",co_name,symbol,market,asset,co_business,cc,amplitude,pe_s_d,co_intro,exchange,mv,pb_d,ps_d,equity,industry\n0,中孚信息,30065"
  },
  {
    "path": "abupy/RomDataBu/stock_code_HK.csv",
    "chars": 552544,
    "preview": ",co_name,symbol,market,asset,co_business,amplitude,pe_s_d,co_intro,sc,hk_equity,exchange,mv,pe_s,pb_d,equity,ps,industry"
  },
  {
    "path": "abupy/RomDataBu/stock_code_US.csv",
    "chars": 1775306,
    "preview": ",co_name,symbol,market,asset,co_site,amplitude,pe_s_d,co_intro,sc,prospectus,co_tel,exchange,co_addr,mv,equity,industry,"
  },
  {
    "path": "abupy/RomDataBu/stock_code_cn.txt",
    "chars": 262811,
    "preview": "sz|0|000723|美锦能源|MJNY:MJNY:|meijinnengyuan:meijinnaiyuan|天宇电气:S天宇:ST天宇:||山西美锦能源股份有限公司\nsz|0|000725|京东方A|JDFA:|jingdongfan"
  },
  {
    "path": "abupy/RomDataBu/stock_code_hk.txt",
    "chars": 142532,
    "preview": "hk|0|00010|恒隆集团|HLJT:|henglongjituan|HANG LUNG GROUP||恒隆集团有限公司\nhk|0|00100|白马户外媒体|BMHWMT:BMHWMB:|baimahuwaimeiti:baimahuw"
  },
  {
    "path": "abupy/RomDataBu/stock_code_us.txt",
    "chars": 970016,
    "preview": "us|0|A|安捷伦科技|AJLKJ:|anjielunkeji|AGILENT TECHNOLOGIES Inc||AGILENTTECHNOLOGIESInc\nus|0|AA|美国铝业|MGLY:|meiguolvye|ALCOA IN"
  },
  {
    "path": "abupy/SimilarBu/ABuCorrcoef.py",
    "chars": 8392,
    "preview": "# coding=utf-8\n\"\"\"\n    相关系数具体计算功能实现模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __"
  },
  {
    "path": "abupy/SimilarBu/ABuSimilar.py",
    "chars": 17784,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    相关系数相似应用模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nf"
  },
  {
    "path": "abupy/SimilarBu/ABuSimilarCache.py",
    "chars": 889,
    "preview": "from __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ import division\n\nimport os\n"
  },
  {
    "path": "abupy/SimilarBu/ABuSimilarDrawing.py",
    "chars": 2717,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    相关系数,相似度可视化模块\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute"
  },
  {
    "path": "abupy/SimilarBu/__init__.py",
    "chars": 408,
    "preview": "from __future__ import absolute_import\n\nfrom . import ABuCorrcoef\nfrom . import ABuSimilar\nfrom .ABuCorrcoef import ECor"
  },
  {
    "path": "abupy/SlippageBu/ABuSlippage.py",
    "chars": 243,
    "preview": "# -*- encoding:utf-8 -*-\nfrom __future__ import absolute_import\n\n# noinspection all\nfrom . import ABuSlippageBuyBase as "
  },
  {
    "path": "abupy/SlippageBu/ABuSlippageBuyBase.py",
    "chars": 3472,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    日内滑点买入价格决策基础模块:暂时迁移简单实现方式,符合回测需求,如迁移实盘模块\n    需添加日内择时策略,通过日内分钟k线,实现日内分钟k线择时,更微观的\n    实现日"
  },
  {
    "path": "abupy/SlippageBu/ABuSlippageBuyMean.py",
    "chars": 1063,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    日内滑点买入示例实现:均价买入\n    最简单的回测买入方式,优点简单,且回测高效,在回测交易\n    数量足够多的前提下也能接近实盘\n\"\"\"\n\nfrom __future_"
  },
  {
    "path": "abupy/SlippageBu/ABuSlippageSellBase.py",
    "chars": 3215,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    日内滑点卖出价格决策基础模块:暂时迁移简单实现方式,符合回测需求,如迁移实盘模块\n    需添加日内择时策略,通过日内分钟k线,实现日内分钟k线择时,更微观的\n    实现日"
  },
  {
    "path": "abupy/SlippageBu/ABuSlippageSellMean.py",
    "chars": 677,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    日内滑点卖出示例实现:均价卖出\n    最简单的回测卖出方式,优点简单,且回测高效,在回测交易\n    数量足够多的前提下也能接近实盘\n\"\"\"\n\nfrom __future_"
  },
  {
    "path": "abupy/SlippageBu/__init__.py",
    "chars": 423,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuSlippageBuyBase import AbuSlippageBuyBase\nfrom .ABuSlippageBuyMean impo"
  },
  {
    "path": "abupy/TLineBu/ABuTL.py",
    "chars": 551,
    "preview": "from __future__ import absolute_import\n\nfrom . import ABuTLine as line\nfrom . import ABuTLExecute as execute\nfrom . impo"
  },
  {
    "path": "abupy/TLineBu/ABuTLAtr.py",
    "chars": 1986,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    计算线atr模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfro"
  },
  {
    "path": "abupy/TLineBu/ABuTLExecute.py",
    "chars": 23862,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    技术线内部执行模块\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/TLineBu/ABuTLGolden.py",
    "chars": 3765,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    黄金分割及比例分割示例模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolut"
  },
  {
    "path": "abupy/TLineBu/ABuTLJump.py",
    "chars": 12010,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    跳空缺口模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_impor"
  },
  {
    "path": "abupy/TLineBu/ABuTLSimilar.py",
    "chars": 28281,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    相关系数上层技术线应用模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_functio"
  },
  {
    "path": "abupy/TLineBu/ABuTLVwap.py",
    "chars": 1808,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    VWAP: Volume Weighted Average Price 成交量加权平均价\n\n    非标准传统意义vwap计算,即非使用高频的分钟k线和量进行计算,只是套用概"
  },
  {
    "path": "abupy/TLineBu/ABuTLWave.py",
    "chars": 6238,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    量化波动程度模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfro"
  },
  {
    "path": "abupy/TLineBu/ABuTLine.py",
    "chars": 26085,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    技术线对象,对外执行,输出模块\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import divis"
  },
  {
    "path": "abupy/TLineBu/__init__.py",
    "chars": 84,
    "preview": "from __future__ import absolute_import\n\nfrom . import ABuTL as tl\n\n__all__ = ['tl']\n"
  },
  {
    "path": "abupy/TradeBu/ABuBenchmark.py",
    "chars": 4542,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    基准模块,基准的作用在于交易时间范围确定,交易时间序列对齐,\n    抛弃异常时间序列,交易市场范围限制,以及对比与策略的度量结果等作用\n\"\"\"\n\nfrom __future"
  },
  {
    "path": "abupy/TradeBu/ABuCapital.py",
    "chars": 15502,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    资金模块,不区分美元,人民币等类型,做美股交易默认当作美元,a股默认当作人民币\n\"\"\"\n\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/TradeBu/ABuCommission.py",
    "chars": 7718,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    手续费模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_import"
  },
  {
    "path": "abupy/TradeBu/ABuKLManager.py",
    "chars": 10837,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    金融时间序列管理模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_i"
  },
  {
    "path": "abupy/TradeBu/ABuMLFeature.py",
    "chars": 25873,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    内置特征定义,以及用户特征扩展,定义模块\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import"
  },
  {
    "path": "abupy/TradeBu/ABuOrder.py",
    "chars": 8735,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    交易订单模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_impor"
  },
  {
    "path": "abupy/TradeBu/ABuTradeDrawer.py",
    "chars": 8166,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    交易可视化模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_impo"
  },
  {
    "path": "abupy/TradeBu/ABuTradeExecute.py",
    "chars": 7497,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    交易执行模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_impor"
  },
  {
    "path": "abupy/TradeBu/ABuTradeProxy.py",
    "chars": 11418,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    交易执行代理模块\n\"\"\"\n\nfrom __future__ import print_function\nfrom __future__ import absolute_imp"
  },
  {
    "path": "abupy/TradeBu/__init__.py",
    "chars": 804,
    "preview": "from __future__ import absolute_import\n\nfrom .ABuBenchmark import AbuBenchmark\nfrom .ABuCapital import AbuCapital\nfrom ."
  },
  {
    "path": "abupy/UmpBu/ABuUmp.py",
    "chars": 383,
    "preview": "from __future__ import absolute_import\n\n# noinspection all\nfrom . import ABuUmpEdgeBase as edge\n# noinspection all\nfrom "
  },
  {
    "path": "abupy/UmpBu/ABuUmpBase.py",
    "chars": 7787,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    ump基础模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgeBase.py",
    "chars": 22665,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    边裁基础实现模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfro"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgeDeg.py",
    "chars": 6251,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump边裁特征走势拟合角度模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\n"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgeFull.py",
    "chars": 8312,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump边裁特征多混模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgeMul.py",
    "chars": 5985,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump边裁特征单混模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgePrice.py",
    "chars": 5737,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump边裁特征价格模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/UmpBu/ABuUmpEdgeWave.py",
    "chars": 5156,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump边裁价格波动特征模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfr"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainBase.py",
    "chars": 61602,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"\n    主裁基础实现模块\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfro"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainDeg.py",
    "chars": 5895,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump主裁特征走势拟合角度模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\n"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainFull.py",
    "chars": 9581,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump多混特征模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom _"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainJump.py",
    "chars": 5407,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump主裁特征跳空模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainMul.py",
    "chars": 5672,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump单混特征模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom _"
  },
  {
    "path": "abupy/UmpBu/ABuUmpMainPrice.py",
    "chars": 5325,
    "preview": "# -*- encoding:utf-8 -*-\n\"\"\"示例ump价格特征模块\"\"\"\n\nfrom __future__ import division\nfrom __future__ import print_function\nfrom _"
  }
]

// ... and 127 more files (download for full content)

About this extraction

This page contains the full source code of the bbfamily/abu GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 327 files (33.4 MB), approximately 4.0M tokens, and a symbol index with 2158 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!