Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Mar 6, 2022
2 parents 9a6f376 + 4731df7 commit 688db62
Show file tree
Hide file tree
Showing 9 changed files with 357 additions and 36 deletions.
Binary file added docs/source/_static/indparam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/portfolio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 71 additions & 7 deletions docs/source/release.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,75 @@
版本发布说明
===============
=======================

1.2.2 (待发布)
1.2.3 (待发布)
-------------------------

1. 指标支持动态参数

1.2.1
在通道信等证券行情软件中,其技术指标中的窗口参数通常支持整数,也支持使用指标,如::
T1:=HHVBARS(H,120); {120内的最高点距今天的天数}
L120:=LLV(L,T1+1); {120内的最高点至今,这个区间的最低点}

现在,在 Hikyuu 中,也可以使用指标作为参数::
T1 = HHVBARS(H, 120)
L120 = LLV(L, T1+1)
L120.set_context(k)
L120.plot()

.. figure:: _static/indparam.png

**注意事项**

由于无法区分 Indicator(ind) 形式时,ind 究竟是指标参数还是待计算的输出数据,此时如果希望 ind 作为参数,需要通过 IndParam 进行显示指定,如:EMA(IndParam(ind))。

最佳的的方式,则是通过指定参数名,来明确说明使用的是参数::

x = EMA(c) # 以收盘价作为计算的输入
y = EMA(IndParam(c)) # 以收盘价作为 n 参数
z = EMA(n=c) # 以收盘价作为参数 n



2. 完善 PF、AF、SE

现在可以正常使用资产组合。::

# 创建一个系统策略
my_mm = MM_FixedCount(100)
my_sg = my_sg = SG_Flex(EMA(n=5), slow_n=10)
my_sys = SYS_Simple(sg=my_sg, mm=my_mm)

# 创建一个选择算法,用于在每日选定交易系统
# 此处是固定选择器,即每日选出的都是指定的交易系统
my_se = SE_Fixed([s for s in blocka if s.valid], my_sys)

# 创建一个资产分配器,用于确定如何在选定的交易系统中进行资产分配
# 此处创建的是一个等比例分配资产的分配器,即按相同比例在选出的系统中进行资金分配
my_af = AF_EqualWeight()

# 创建资产组合
# 创建一个从2001年1月1日开始的账户,初始资金200万元。这里由于使用的等比例分配器,意味着将账户剩余资金在所有选中的系统中平均分配,
# 如果初始资金过小,将导致每个系统都没有充足的资金完成交易。
my_tm = crtTM(Datetime(200101010000), 2000000)
my_pf = PF_Simple(tm=my_tm, af=my_af, se=my_se)

# 运行投资组合
q = Query(-500)
%time my_pf.run(Query(-500))

x = my_tm.get_funds_curve(sm.get_trading_calendar(q))
PRICELIST(x).plot()

.. figure:: _static/portfolio.png

3. 修复fedora 34编译找不到路径报错,waning 提示
4. fixed mysql 升级脚本错误
5. fixed 复权后计算的净收益不对,并在使用前复权数据进行回测时给出警告(前复权回测属于未来函数)


1.2.1 - 2022年2月2日
-------------------------

1. 修复 importdata 无法导入的问题
Expand All @@ -17,7 +81,7 @@
7. 修改其他文档帮助错误


1.2.0
1.2.0 - 2022年1月11日
-------------------------

1. HikyuuTdx 执行导入时自动保存配置,避免第一次使用 hikyuu 必须退出先退出 Hikyuutdx 的问题
Expand All @@ -32,7 +96,7 @@
10. 优化 HikyuuTDX GUI控制台日志,捕获子进程日志输出


1.1.9
1.1.9 - 2021年11月11日
-------------------------

1. 补充科创板
Expand All @@ -46,13 +110,13 @@
9. 取消编译时指定的AVX指令集,防止不支持的CPU架构


1.1.8
1.1.8 - 2021年2月27日
-------------------------
1. HikyuuTDX 切换mysql导入时错误提示目录不存在
2. tdx本地导入修复,并支持导入MySQL


1.1.7
1.1.7 - 2021年2月13日
-------------------------

1. 更新examples/notebook相关示例
Expand Down
7 changes: 4 additions & 3 deletions hikyuu/examples/notebook/000-Index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"* [006 TradeManager应用](006-TradeManager.ipynb?flush_cache=True)\n",
"* [007 系统策略演示](007-SystemDetails.ipynb?flush_cache=True)\n",
"* [008 序列化说明](008-Pickle.ipynb?flush_cache=True)\n",
"* [009_获取实时日线数据](009-RealData.ipynb?flush_cache=True)"
"* [009_获取实时日线数据](009-RealData.ipynb?flush_cache=True)\n",
"* [010_资产组合](010-Portfolio.ipynb?flush_cache=True)"
]
},
{
Expand All @@ -53,7 +54,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -67,7 +68,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
140 changes: 118 additions & 22 deletions hikyuu/examples/notebook/004-IndicatorOverview.ipynb

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions hikyuu/examples/notebook/010-Portfolio.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hikyuu_pywrap/indicator/_build_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ void export_Indicator_build_in() {

def("EMA", EMA_1, (arg("n") = 22));
def("EMA", EMA_2, (arg("n")));
def("EMA", EMA_3, (arg("data"), arg("n")));
def("EMA", EMA_4, (arg("data"), arg("n")));
def("EMA", EMA_5, (arg("data"), arg("n")));
def("EMA", EMA_3, (arg("data"), arg("n") = 22), R"(EMA([data, n=22])
def("EMA", EMA_5, (arg("data"), arg("n") = 22), R"(EMA([data, n=22])
指数移动平均线(Exponential Moving Average)
Expand Down
2 changes: 1 addition & 1 deletion sub_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Developers',
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if not is_plat("windows") then
end

-- version
set_version("1.2.2", {build="%Y%m%d%H%M"})
set_version("1.2.3", {build="%Y%m%d%H%M"})
set_configvar("LOG_ACTIVE_LEVEL", 0) -- 激活的日志级别
--if is_mode("debug") then
-- set_configvar("LOG_ACTIVE_LEVEL", 0) -- 激活的日志级别
Expand Down

0 comments on commit 688db62

Please sign in to comment.