mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 20:08:26 +08:00
update
This commit is contained in:
parent
1bbe573ce4
commit
bbd5d7e0fd
@ -68,39 +68,4 @@
|
|||||||
</Folder>
|
</Folder>
|
||||||
<File name="tools\setup.py" />
|
<File name="tools\setup.py" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project name="hikyuu_doc">
|
|
||||||
<File name="tools\hikyuu\docs\source\conf.py" />
|
|
||||||
<File name="tools\hikyuu\docs\source\index.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\reference.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\quickstart.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\install.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\overview.rst" />
|
|
||||||
<Folder name="trade_manage">
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_manage\trade_manage.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_manage\trade_cost.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_manage\TradeManager.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_manage\record_struct.rst" />
|
|
||||||
</Folder>
|
|
||||||
<Folder name="trade_sys">
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\signal.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\trade_sys.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\stoploss.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\money_manager.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\profitgoal.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\slippage.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\condition.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\trade_sys\environment.rst" />
|
|
||||||
</Folder>
|
|
||||||
<Folder name="indicator">
|
|
||||||
<File name="tools\hikyuu\docs\source\indicator\index.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\indicator\indicator.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\indicator\overview.rst" />
|
|
||||||
</Folder>
|
|
||||||
<Folder name="base">
|
|
||||||
<File name="tools\hikyuu\docs\source\base\datatype.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\base\index.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\base\stock_manager.rst" />
|
|
||||||
<File name="tools\hikyuu\docs\source\base\utilities.rst" />
|
|
||||||
</Folder>
|
|
||||||
</Project>
|
|
||||||
</NotepadPlus>
|
</NotepadPlus>
|
||||||
|
@ -121,12 +121,36 @@ class Query(KQuery):
|
|||||||
EQUAL_FORWARD = KQuery.RecoverType.EQUAL_FORWARD
|
EQUAL_FORWARD = KQuery.RecoverType.EQUAL_FORWARD
|
||||||
EQUAL_BACKWARD = KQuery.RecoverType.EQUAL_BACKWARD
|
EQUAL_BACKWARD = KQuery.RecoverType.EQUAL_BACKWARD
|
||||||
|
|
||||||
def __init__(self, start = 0, end = constant.null_int64,
|
def __init__(self, start = 0, end = None,
|
||||||
kType = KQuery.KType.DAY, recoverType = KQuery.RecoverType.NO_RECOVER):
|
kType = KQuery.KType.DAY, recoverType = KQuery.RecoverType.NO_RECOVER):
|
||||||
super(Query, self).__init__(start, end, kType, recoverType)
|
"""
|
||||||
|
构建按索引方式 [start, end) 查询K线数据条件,查询[start, end)的K线记录
|
||||||
|
start: int 起始位置(默认0)
|
||||||
|
end : int 结束位置(默认为全部数量)
|
||||||
|
kType: KQuery.KType.DAY K线类型(默认为日线)
|
||||||
|
recoverType: KQuery.RecoverType.NO_RECOVER 复权类型(默认不复权)
|
||||||
|
"""
|
||||||
|
end_pos = constant.null_int64 if end is None else end
|
||||||
|
super(Query, self).__init__(start, end_pos, kType, recoverType)
|
||||||
|
|
||||||
|
QueryByIndex = Query
|
||||||
|
|
||||||
|
def QueryByDate(start=None, end=None, kType=Query.DAY,
|
||||||
|
recoverType=Query.NO_RECOVER):
|
||||||
|
"""
|
||||||
|
构建按日期 [start, end) 查询K线数据条件
|
||||||
|
start: Datetime 起始日期(默认为支持的最小日期)
|
||||||
|
end : Datetime 结束日期(默认为支持的最大日期)
|
||||||
|
kType: KQuery.KType K线类型(默认为日线)
|
||||||
|
recoverType: KQuery.RecoverType 复权类型(默认不复权)
|
||||||
|
|
||||||
|
return KQuery K线数据查询条件
|
||||||
|
|
||||||
|
"""
|
||||||
|
start_date = Datetime.minDatetime() if start is None else start
|
||||||
|
end_date = Datetime.maxDatetime() if end is None else end
|
||||||
|
return KQueryByDate(start_date, end_date, kType, recoverType)
|
||||||
|
|
||||||
QueryByIndex = KQueryByIndex
|
|
||||||
QueryByDate = KQueryByDate
|
|
||||||
|
|
||||||
KQuery.INDEX = KQuery.QueryType.INDEX
|
KQuery.INDEX = KQuery.QueryType.INDEX
|
||||||
KQuery.DATE = KQuery.QueryType.DATE
|
KQuery.DATE = KQuery.QueryType.DATE
|
||||||
|
@ -50,9 +50,6 @@ INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (13,1,'
|
|||||||
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (18,2,'300',8,'创业板');
|
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (18,2,'300',8,'创业板');
|
||||||
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (19,1,'603',1,'上证A股');
|
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (19,1,'603',1,'上证A股');
|
||||||
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (20,1,'519',4,'上证基金');
|
INSERT INTO `CodeRuleType` (id,marketid,codepre,type,description) VALUES (20,1,'519',4,'上证基金');
|
||||||
CREATE INDEX "ix_stockid_stock" ON "stock" (stockid);
|
|
||||||
CREATE INDEX "ix_marketid_stock" ON "stock" (marketid);
|
|
||||||
CREATE INDEX "ix_marketid_code_stock" ON "stock" (marketid, code);
|
|
||||||
CREATE INDEX "ix_stkWeight_stockid" ON "stkWeight" (stockid);
|
CREATE INDEX "ix_stkWeight_stockid" ON "stkWeight" (stockid);
|
||||||
CREATE INDEX "ix_stkWeight_date" ON "stkWeight" (date);
|
CREATE INDEX "ix_stkWeight_date" ON "stkWeight" (date);
|
||||||
CREATE INDEX "ix_stkWeight" ON "stkWeight" (stockid, date);
|
CREATE INDEX "ix_stkWeight" ON "stkWeight" (stockid, date);
|
||||||
|
BIN
tools/hikyuu/docs/source/_static/10000-overview.png
Normal file
BIN
tools/hikyuu/docs/source/_static/10000-overview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
@ -58,7 +58,7 @@ author = 'fasiondog'
|
|||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '1.0'
|
version = '1.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '1.0.0'
|
release = '0.1.0'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -1,2 +1,18 @@
|
|||||||
安装指南
|
安装指南
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
下载安装包
|
||||||
|
----------
|
||||||
|
|
||||||
|
请从此次下载安装包:
|
||||||
|
|
||||||
|
注::
|
||||||
|
|
||||||
|
目前尚未上传 PIP
|
||||||
|
|
||||||
|
配置数据存放路径
|
||||||
|
----------------
|
||||||
|
|
||||||
|
|
||||||
|
修改数据导入配置
|
||||||
|
----------------
|
@ -4,10 +4,35 @@
|
|||||||
什么是Hikyuu Quant Framework?
|
什么是Hikyuu Quant Framework?
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
Hikyuu Quant Framework是一款开源的量化交易研究框架,其核心思想基于当前成熟的系统化交易方法,将整个系统化交易抽象为由市场环境判断策略、系统有效条件、信号指示器、止损/止盈策略、资金管理策略、盈利目标策略、移滑价差算法七大组件,你可以分别构建这些组件的策略资产库,在实际研究中对它们进行自由组合来观察系统的有效性、稳定性以及单一种类策略的效果。
|
Hikyuu Quant Framework是一款基于C++/Python的开源量化交易研究框架,目前用于国内A股及基金的策略分析及回测。其核心思想基于当前成熟的系统化交易方法,将整个系统化交易抽象为由市场环境判断策略、系统有效条件、信号指示器、止损/止盈策略、资金管理策略、盈利目标策略、移滑价差算法七大组件,你可以分别构建这些组件的策略资产库,在实际研究中对它们自由组合来观察系统的有效性、稳定性以及单一种类策略的效果。例如:
|
||||||
|
|
||||||
为何选择Hikyuu Quant Framework?
|
::
|
||||||
--------------------------------
|
|
||||||
|
#创建模拟交易账户进行回测,初始资金30万
|
||||||
|
my_tm = crtTM(initCash = 300000)
|
||||||
|
|
||||||
|
#创建信号指示器(以5日EMA为快线,5日EMA自身的10日EMA最为慢线,快线向上穿越慢线时买入,反之卖出)
|
||||||
|
my_sg = SG_Flex(OP(EMA(n=5)), slow_n=10)
|
||||||
|
|
||||||
|
#固定每次买入1000股
|
||||||
|
my_mm = MM_FixedCount(1000)
|
||||||
|
|
||||||
|
#创建交易系统并运行
|
||||||
|
sys = SYS_Simple(tm = my_tm, sg = my_sg, mm = my_mm)
|
||||||
|
sys.run(sm['sz000001'], Query(-150))
|
||||||
|
|
||||||
|
.. figure:: _static/10000-overview.png
|
||||||
|
|
||||||
|
完整示例参见:`<http://nbviewer.jupyter.org/github/fasiondog/hikyuu/blob/master/examples/001-overview.ipynb>`_
|
||||||
|
|
||||||
|
Maybe,你已经注意到了,上面没有“选股策略”?!是的,选股策略是股票交易的重要方面,肯定不会少。事实上,之前所述的交易系统都是针对一个交易对象的,也就是经常听到的策略,但很多所谓的“策略”其实仅仅只是买入、卖出的指示信号而已,并非完整的交易策略。为了区别,在这里直接以系统指称,表示一个完整的系统化交易方法或策略。而在系统之上,称为Portfolio资产组合,选股策略则是Portfolio的组件,Portfolio的另一重要组成则是资金分配策略,比如选股策略选定了4个交易对象(股票或基金等),那么如何在它们之间进行合理的资金分配?
|
||||||
|
|
||||||
|
所以,Hikyuu Quant Framework其实是在System和Portfolio基础之上、包含了九大策略组件:市场环境判断策略、系统有效条件、信号指示器、止损/止盈策略、资金管理策略、盈利目标策略、移滑价差算法、交易对象选择策略、资金分配策略。可以在此基础上构建自己的策略库,并进行灵活的组合和测试,甚至可以更进一步,在选择交易对象的同时,选取与之匹配的最优系统交易策略(System)。
|
||||||
|
|
||||||
|
| *注:Portfolio、选股策略、资金分配策略的组件及接口尚在实现中…… :(*
|
||||||
|
|
||||||
|
为什么选择Hikyuu Quant Framework?
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
Hikyuu的优势与特点?
|
Hikyuu的优势与特点?
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -284,7 +284,7 @@ def realtimeUpdate_from_tushare():
|
|||||||
record.datetime = Datetime(d)
|
record.datetime = Datetime(d)
|
||||||
stock.realtimeUpdate(record)
|
stock.realtimeUpdate(record)
|
||||||
|
|
||||||
def realtimeUpdate(source = 'sina'):
|
def realtimeUpdate(source = 'tushare'):
|
||||||
if source == 'sina' or source == 'qq':
|
if source == 'sina' or source == 'qq':
|
||||||
realtimeUpdate_from_sina_qq(source)
|
realtimeUpdate_from_sina_qq(source)
|
||||||
elif source == 'tushare':
|
elif source == 'tushare':
|
||||||
|
Loading…
Reference in New Issue
Block a user