Giter Site home page Giter Site logo

fasiondog / hikyuu Goto Github PK

View Code? Open in Web Editor NEW
2.1K 115.0 565.0 192.65 MB

Hikyuu Quant Framework 基于C++/Python的开源量化交易研究框架

Home Page: http://hikyuu.org/

License: Apache License 2.0

C++ 90.89% Lua 0.28% Python 8.83%
quant backtest backtesting-trading-strategies system-trading

hikyuu's Introduction

title


img img img img img img

Hikyuu Quant Framework是一款基于C++/Python的开源量化交易研究框架,用于策略分析及回测(目前主要用于国内A股市场)。其核心**基于当前成熟的系统化交易方法,将整个系统化交易抽象为由市场环境判断策略、系统有效条件、信号指示器、止损/止盈策略、资金管理策略、盈利目标策略、移滑价差算法七大组件,你可以分别构建这些组件的策略资产库,在实际研究中对它们自由组合来观察系统的有效性、稳定性以及单一种类策略的效果。

详细文档:https://hikyuu.org/

感谢网友提供的 Hikyuu Ubuntu虚拟机环境, 百度网盘下载(提取码: ht8j): https://pan.baidu.com/s/1CAiUWDdgV0c0VhPpe4AgVw?pwd=ht8j

示例:

    #创建模拟交易账户进行回测,初始资金30万
    my_tm = crtTM(init_cash = 300000)

    #创建信号指示器(以5日EMA为快线,5日EMA自身的10日EMA作为慢线,快线向上穿越慢线时买入,反之卖出)
    my_sg = SG_Flex(EMA(CLOSE(), 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))

img

完整示例参见:https://nbviewer.jupyter.org/github/fasiondog/hikyuu/blob/master/hikyuu/examples/notebook/000-Index.ipynb?flush_cache=True

为什么选择 Hikyuu?

  • 组合灵活,分类构建策略资产库 Hikyuu对系统化交易方法进行了良好的抽象,包含了九大策略组件:市场环境判断策略、系统有效条件、信号指示器、止损/止盈策略、资金管理策略、盈利目标策略、移滑价差算法、交易对象选择策略、资金分配策略。可以在此基础上构建自己的策略库,并进行灵活的组合和测试。在进行策略探索时,可以更加专注于某一方面的策略性能与影响。其主要功能模块如下:img
  • 性能保障,打造自己的专属应用 目前项目包含了3个主要组成部分:基于C++的核心库、对C++进行包装的Python库(hikyuu)、基于Python的交互式工具。
    • AMD 7950x 实测:A股全市场(1913万日K线)仅加载全部日线计算 20日 MA 并求最后 MA 累积和,首次执行含数据加载 耗时 6秒,数据加载完毕后计算耗时 166 毫秒,详见: 性能实测
    • C++核心库,提供了整体的策略框架,在保证性能的同时,已经考虑了对多线程和多核处理的支持,在未来追求更高运算速度提供便利。C++核心库,可以单独剥离使用,自行构建自己的客户端工具。
    • Python库(hikyuu),提供了对C++库的包装,同时集成了talib库(如TA_SMA,对应talib.SMA),可以与numpy、pandas数据结构进行互相转换,为使用其他成熟的python数据分析工具提供了便利。
    • hikyuu.interactive 交互式探索工具,提供了K线、指标、系统信号等的基本绘图功能,用于对量化策略的探索和回测。
  • 代码简洁,探索更便捷、自由 同时支持面向对象和命令行编程范式。其中,命令行在进行策略探索时,代码简洁、探索更便捷、自由。
  • 安全、自由、隐私,搭建自己的专属云量化平台 结合 Python + Jupyter 的强大能力与云服务器,可以搭建自己专属的云量化平台。将Jupyter部署在云服务器上,随时随地的访问自己的云平台,即刻实现自己新的想法,如下图所示通过手机访问自己的云平台。结合Python强大成熟的数据分析、人工智能工具(如 numpy、scipy、pandas、TensorFlow)搭建更强大的人工智能平台。
  • 数据存储方式可扩展 目前支持本地HDF5格式、MySQL存储。默认使用HDF5,数据文件体积小、速度更快、备份更便利。截止至2017年4月21日,沪市日线数据文件149M、深市日线数据文件184M、5分钟线数据各不到2G。

img

想要更多了解Hikyuu?请使用以下方式联系:

加入知识星球

更多示例与策略部件的及时分享(您的加入将视为对项目的捐赠)。项目交流和问题答复将转移至知识星球-【Hikyuu量化】。

img

关注公众号:

img

加入微信群(请注明“加入hikyuu”):

img

QQ交流群(逐渐废弃):114910869, 或扫码加入

img

hikyuu's People

Contributors

19317362 avatar 280185386 avatar alenstarx avatar archya avatar cg82616424 avatar dota3 avatar eltociear avatar fasiondog avatar ijetli avatar kbugstar avatar mydown51 avatar pchaos avatar smartai avatar ted88368 avatar waruqi avatar wingc-china avatar xiyandd avatar yangrq1018 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hikyuu's Issues

项目示例测试太久了

运行项目时报错误。但是通过工具只有1,5,日线数据文件。没有下面几个文件。
运行代码没有获取到测试数据。不知道怎么弄
2021-02-26 18:02:31.262 [HKU-E] - Can't open h5file: e:\stock/sh_time.h5 (H5KDataDriver.cpp:141)
2021-02-26 18:02:31.262 [HKU-E] - Can't open h5file: e:\stock/sh_trans.h5 (H5KDataDriver.cpp:141)
2021-02-26 18:02:31.263 [HKU-E] - Can't open h5file: e:\stock/sz_time.h5 (H5KDataDriver.cpp:141)
2021-02-26 18:02:31.263 [HKU-E] - Can't open h5file: e:\stock/sz_trans.h5 (H5KDataDriver.cpp:141)

你好,mac m1 安装出错,请问如何处理

python setup.py install
checking xmake ...
xmake v2.6.2+dev.200fc56, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
_
__ ___ __ __ __ | | ______
\ / / | / |/ _ | |/ / __
> < | _
/ | /| | < /
/
/__|
| |
|_
||____|
by ruki, xmake.io

👉  Manual: https://xmake.io/#/getting_started
🙏  Donate: https://xmake.io/#/sponsor

current python version: 3.9000000000000004
BOOST_ROOT: /Volumes/Data/Code/trader/hikyuu/boost
BOOST_LIB: /Volumes/Data/Code/trader/hikyuu/boost/stage/lib
[100%]: build ok!
[100%]: build ok!
current python version: 3.9000000000000004
/Users/admin/.local/lib/python3.9/site-packages/hikyuu
cp: hikyuu/: No such file or directory
error: install failed, exec(cp -f -r hikyuu/
/Users/admin/.local/lib/python3.9/site-packages/hikyuu) failed(1)

win10 使用模块报错 No section: 'hikyuu'

我用的是python3.6 64位,安装好模块后在jupyter notebook中使用如下:

%matplotlib inline
%time from hikyuu.interactive.interactive import *

#use_draw_engine('echarts')

但报如下的错误:
No section: 'hikyuu'
如何解决呢

CN触发的离场信号就比SG触发的离场信号,晚一个周期

测试了使用CN离场和SG离场两种实现方法:
方式1,CN离场,使用week close >= week close ma20作为CN有效条件,SG中不进行_add_buy_signal和_add_sell_signal;开启CN开仓;
方式2,SG离场,不部署CN,SG中使用week close < week close ma20进行_add_sell_signal;

对比发现,CN市场失效触发的离场信号,会较SG直接触发的离场信号,晚一个周期被执行。

LLV 函数第二个参数 兼容性提升

T1:=HHVBARS(H,120); {120内的最高点距今天的天数}
L120:=LLV(L,T1+1); {120内的最高点至今,这个区间的最低点}

目前LLV 第二个函数只能是数字类型,希望能增加第二个参数为变量的情况。

采用mingw编译有问题

采用xmake编译时,提示
checking for the vswhere.exe ... no
checking for the vswhere ... no
checking for the microsoft visual studio(x64)version ... no

后面找xmake兄弟确认,说交叉编译需要用xmake f -p mingw --sdk=${GCC_PATH} -a x86_64。确实没有检查visual studio了。但是提示下面错误。

stack traceback:
    [C]: in function 'error'
    [F:\xmake/core/base/os.lua:705]: in function 'raise'
    [F:\xmake\core\sandbox\modules\os.lua:352]: in function 'iorun'
    [F:\codes\hikyuu\hikyuu\hikyuu_pywrap\xmake_on_load.lua:29]:
    [C]: in function 'load'
    [F:\xmake/core/project/target.lua:229]: in function '_load'
    [F:\xmake/core/project/project.lua:542]: in function '_load_targets'
    [F:\xmake/core/project/project.lua:705]: in function 'targets'
    [F:\xmake\actions\config\main.lua:128]: in function '_check_target'
    [F:\xmake\actions\config\main.lua:283]:
    [C]: in function 'load'
    [F:\xmake/core/base/task.lua:512]: in function 'run'
    [F:\xmake/core/main.lua:246]:

stack traceback:
    [C]: in function 'error'
    [F:\xmake/core/base/os.lua:705]: in function 'raise'
    [F:\xmake/core/project/project.lua:707]: in function 'targets'
    [F:\xmake\actions\config\main.lua:128]: in function '_check_target'
    [F:\xmake\actions\config\main.lua:283]:
    [C]: in function 'load'
    [F:\xmake/core/base/task.lua:512]: in function 'run'
    [F:\xmake/core/main.lua:246]:

我根据前面一个帖子信息说没有安装Python。但是我是已经安装python,并且把python路径设置到path了。
C:\Users\Derek>echo %path%
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Git\cmd;F:\codes\mingw64\bin;;**F:\xmake;F:\Python\Python37\Scripts;F:\Python\Python37;**C:\Users\Derek\AppData\Local\Microsoft\WindowsApps;C:\Users\Derek\AppData\Local\Programs\Microsoft VS Code\bin;F:\xmake;

api bug

1、不能使用断点调试,会异常退出。
2、部分函数使用时,不能正常返回数据。
例如
(1)blk = sm.get_block("指数板块", "上证380")
报出信息如下
2021-03-02 16:48:00.755 [HKU-I] - No such category (指数板块)! (QLBlockInfoDriver.cpp:24)

(2)
s = sm['sh000001']
k = s.get_kdata(Query(-100))
k.plot()
没有画出图

哪个linuxDocker安装后在python中运行也出错误提示.

root@d427a9d9d289:~# python
Python 3.6.5 |Anaconda custom (64-bit)| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from hikyuu.interactive.interactive import *
Traceback (most recent call last):
File "", line 1, in
File "/home/fasiondog/hikyuu/tools/hikyuu/init.py", line 56, in
from .core import *
File "/home/fasiondog/hikyuu/tools/hikyuu/core.py", line 34, in
from .core_doc import *
File "/home/fasiondog/hikyuu/tools/hikyuu/core_doc.py", line 28, in
from hikyuu._hikyuu import *
ImportError: libhikyuu.so: cannot open shared object file: No such file or directory
exit
Use exit() or Ctrl-D (i.e. EOF) to exit

root@d427a9d9d289:# find ./ -name libhikyuu.so
./hikyuu/build/hikyuu/gcc-5.4.0/release/libhikyuu.so
./hikyuu/tools/hikyuu/libhikyuu.so
root@d427a9d9d289:
#

除权计算不生效

问题描述:
测试策略中发现结果异常,回查K线数据,发现前复权计算似乎没有生效,经绘制K线对比,确认数据有问题。

重现方法:
股票代码:sh603392

ipynb代码

%matplotlib inline
%time from hikyuu.interactive import *

s = sm['sh603392']

# 查看权息信息
ws = sm['sh603392'].get_weight()
for w in ws:
    print(w)
#查询股票最后200个交易日K线数据,不复权
k = s.get_kdata(Query(-200))
k.plot()

0E~$J3115FF6OQY6TY{AQVE

#查询股票最后200个交易日K线数据,前向复权
k = s.get_kdata(Query(-200, recover_type=Query.FORWARD))
k.plot()

F@MZN1Z82}M@Q9DX W{@ GY

#查询股票最后200个交易日K线数据,后向复权
k = s.get_kdata(Query(-200, recover_type=Query.BACKWARD))
k.plot()

NSC{5A16SU5O3VEQ7%}BR

改变数据源应该怎么处理,HDF5或者SQL的具体格式是什么样?怎么添加本地csv/pandas数据

你好,我想问一下,我看了一下pytdx_data_driver.py,我不想使用通达信的数据源,我自己已经有pandas的数据了,我的数据是期货数据,不是股票数据,我应该怎么改才能把我的数据源导入呢?
我尝试把pandas转成hdf5格式,但是不能使用,我用pandas读取hikyuu下载的hdf5文件也失败,所以可不可以告诉我正确的处理方法呢,或者怎样把我的数据转成hdf5格式?
我可能需要 open, high, low, close, amount, vol之外的数据, 比如持仓量,换手率之类也导入到系统中,这时候我应该怎么处理呢?
还有就是周线以及月线数据是怎么自动生成的啊?比如五一放三天假 或者国庆放七天假的时候,有时候可能一天的数据就是一周的数据,这个时候是怎么把日线变成周线或者月线呢?
问题比较多,谢谢回答!

作者,你好, 我在macos下编译出现如下错误, 不知能否赐教

current python version: 3.7
BOOST_ROOT: /Users/wood/Desktop/sofaware/hikyuu-master/boost_1_73_0
BOOST_LIB: /Users/wood/Desktop/sofaware/hikyuu-master/boost_1_73_0/stage/lib
checking for the architecture ... x86_64
checking for the Xcode directory ... /Applications/Xcode.app
checking for the SDK version of Xcode ... 10.15
checking for the Codesign Identity of Xcode ... no
error: bad argument #1 to 'parse' (string expected, got nil)
[100%]: build ok!
[ 80%]: compiling.release hikyuu_pywrap/trade_manage/_FundsRecord.cpp
[ 76%]: compiling.release hikyuu_pywrap/_KData.cpp
[ 81%]: compiling.release hikyuu_pywrap/trade_manage/_Performance.cpp
[ 77%]: compiling.release hikyuu_pywrap/indicator/_build_in.cpp
[ 78%]: compiling.release hikyuu_pywrap/trade_manage/_build_in.cpp
[ 77%]: compiling.release hikyuu_pywrap/indicator/_IndicatorImp.cpp
[ 80%]: compiling.release hikyuu_pywrap/trade_manage/_PositionRecord.cpp
[ 78%]: compiling.release hikyuu_pywrap/indicator/_Indicator.cpp
[ 81%]: compiling.release hikyuu_pywrap/trade_manage/_TradeCost.cpp
[ 76%]: compiling.release hikyuu_pywrap/trade_instance/_AmaInstance.cpp
[ 79%]: compiling.release hikyuu_pywrap/trade_manage/_BorrowRecord.cpp
[ 79%]: compiling.release hikyuu_pywrap/trade_manage/_CostRecord.cpp
error: hikyuu_pywrap/indicator/../pybind_utils.h:36:33: error: template argument for template type parameter must be a type; did you forget 'typename'?
result[i] = py::extract<T::value_type>(pylist[i])();
^
typename
/Users/wood/Desktop/sofaware/hikyuu-master/boost_1_73_0/boost/python/extract.hpp:125:17: note: template parameter is declared here
template
^
1 warning and 1 error generated.
warning: add_cxflags("-wd4251") is ignored, please pass {force = true} or call set_policy("check.auto_ignore_flags", false) if you want to set it.
current python version: 3.7
cp: hikyuu/*: No such file or directory

由于对c++不熟悉, 也不知其语法, 不知道从哪入手解决, 还望指点下.

fatal error: config.h: 没有那个文件或目录

rror: hikyuu_cpp/hikyuu/trade_sys/system/crt/../../environment/../../Log.h:12:10: fatal error: config.h: 没有那个文件或目录
12 | #include "config.h"

使用git仓库里的最新代码,boost 1.72, python 3.7,系统是ubuntu 20.04,已经安装说明配置好了boost

hikyuu 1.1.9 HHV()执行结果异常。

查询股票为688078',数据为11月26日之前20个交易日 。10日最高成交量结果异常。
print(sm['sh688078'].getKData(Query(-20)).to_df())
for i in HHV(AMO(sm['sh688078'].getKData(Query(-20))),10):
print(i)
open high low close amount volume
datetime
2021-11-01 53.50 55.19 51.80 53.76 4508.4 8383.0
2021-11-02 53.79 55.60 53.60 54.15 3994.6 7322.0
2021-11-03 54.15 56.91 54.15 55.08 2815.6 5115.0
2021-11-04 55.14 59.48 54.93 58.26 3438.6 5915.0
2021-11-05 59.00 59.45 57.10 58.18 2525.0 4321.0
2021-11-08 60.00 69.82 58.00 69.82 12943.1 19150.0
2021-11-09 69.66 76.60 67.00 72.00 16302.7 22849.0
2021-11-10 70.38 72.59 70.00 71.18 8211.5 11527.0
2021-11-11 70.00 72.50 69.14 71.39 5704.6 7978.0
2021-11-12 71.74 73.33 69.00 70.90 4660.4 6647.0
2021-11-15 70.70 70.77 67.90 68.88 4868.6 7075.0
2021-11-16 69.05 70.50 64.40 69.86 8107.4 12014.0
2021-11-17 67.16 71.00 67.16 68.74 3940.5 5700.0
2021-11-18 70.56 73.70 68.00 68.60 6332.1 8920.0
2021-11-19 68.44 69.99 66.13 69.99 3129.0 4580.0
2021-11-22 68.69 73.38 67.22 70.80 4750.9 6734.0
2021-11-23 74.54 74.90 67.21 67.52 4582.6 6608.0
2021-11-24 66.72 71.80 66.66 70.68 5859.2 8459.0
2021-11-25 70.54 71.00 67.62 67.70 3825.7 5583.0
2021-11-26 67.44 67.99 62.55 65.29 7030.2 10847.0
警告: "Stock.getKData" 即将被废弃,请使用 "Stock.get_kdata" 代替
4508.400000000001
4508.400000000001
4508.400000000001
4508.400000000001
4508.400000000001
12943.1
16302.7
16302.7
16302.7
16302.7
16302.7
16302.7
16302.7
16302.7
16302.7
16302.7
8211.5
5859.200000000001
5859.200000000001
8107.400000000001
微信图片_20211129092035

bokeh绘图问题

bokeh_draw.py kplot方法:
axes.add_tools(HoverTool(tooltips=[("index", "$index"), ('日期', get_date_format(k)),
("开盘价", "@OPEN{0.0000}"), ("最高价", "@high{0.0000}"),
("最低价", "@low{0.0000}"),("收盘价", "@close{0.0000}"),
("成交金额", "@amount{0.0000}"), ("成交量", "@Volume{0.0000}")],
formatters = { "datetime": "datetime"}))
formatters 少了一个@符号

get_date_format方法返回逻辑似乎写反了

下载数据有点问题,直接运行exe文件时下载不了,进度条没反应,等了很久也没有新文件生成

下载数据有点问题,改变时间没用,直接运行exe文件时下载不了,进度条没反应,文件也不更新。
改成在命令行直接运行python HikyuuTDX.py可以下载,但是不管怎么改变时间,下载的数据都只有不到100条。
下载完之后生成了 importdata-gui.ini跟hikyuu.ini,但是没用,重新用命令行打开下载仍然是旧的设置,时间不变,下载的仍然只有不到100条
下载选择sql,整个过程没看到新的sql文件生成,或者说文件放在别的地方了?
用importdata下载,提示TypeError: init() missing 1 required positional argument: 'config',然后我去检查了一下UsePytdxImportToH5Thread, 发现在UsePytdxImportToH5Thread中的初始化是__init__(self, parent, config),但是在importdata.py中却是self.hdf5_import_thread = UsePytdxImportToH5Thread(config),这里应该是有问题。
还有就是examples里面的几个例子quick_crtsg, Turtle_SG是老版本的,没法运行,trade_sys文件夹更新过。

my_bool 没有定义

环境 :使用git仓库里的最新代码,boost 1.72, python 3.7,系统是ubuntu 20.04,已经安装说明配置好了boost
错误如下:

error: hikyuu_cpp/hikyuu/utilities/db_connect/mysql/MySQLStatement.h:62:12: error: ‘my_bool’ was not declared in this scope; did you mean ‘bool’?
   62 |     vector<my_bool> m_result_is_null;
      |            ^~~~~~~

可否加强对linux支持.下面为在linux非Docker安装设想,有待验证

安装开发环境:
apt-get install build-essential git bzip2
apt-get install libmysqlclient-dev libmysqlclient20
apt-get install libhdf5-dev libhdf5-serial-dev
apt-get install libqt5x11extras5 unrar

install Anaconda3

参考:http://rqalpha.readthedocs.io/zh_CN/latest/intro/detail_install.html#intro-detail-create-env
安装 TA-Lib
参考:https://mrjbq7.github.io/ta-lib/install.html
Linux

Download ta-lib-0.4.0-src.tar.gz and:

$ untar and cd
$ ./configure --prefix=/usr
$ make
$ sudo make install
$ pip install TA-Lib

以上为安装hikyuu,rqalpha等量化程序公共环境

install boost###是否可用系统apt-get install libboost*代替。??

tar xzvf boost_1_64_0.tar.gz
boostsource=$tmpdir/"boost_1_64_0.tar.gz"

[ -f $boostsource ] &&
tar xzvf $boostsource &&
cd boost_1_64_0 &&
./bootstrap.sh --exec-prefix=/usr/local &&
./b2 -q -j 4 threading=multi &&
./b2 install threading=multi &&
cp b2 bjam /usr/local/bin/ &&
cd .. &&
rm $boostsource

install log4cplus ###是否可用系统apt-get install liblog4cplus*代替。??

log4c="log4cplus-1.2.1-rc2"
log4cfile=$tmpdir/$log4c.tar.gz
#[ ! -f $log4cfile ] && wget -c -O $log4cfile https://sourceforge.net/projects/log4cplus/files/log4cplus-stable/1.2.1/log4cplus-1.2.1-rc2.tar.gz/download
tar -xzf $log4cfile
cd $log4c
#./configure --prefix=/usr CXXFLAGS="std=-c++11"
./configure --prefix=/usr/local CXXFLAGS=-std=c++0x
make -j 4
make install
cd ..
rm $log4cfile
rm -rf $log4c

install hikyuu ####原作者是否可做成跨平台通用的pip install hikyuu,如rqalpha,pip install rqalpha -i https://pypi.tuna.tsinghua.edu.cn/simple ???###

git clone https://github.com/fasiondog/hikyuu.git
cd hikyuu

hikyuu编译打补丁

echo ".............................. patch Jamroot"
cp Jamroot.linux Jamroot.linux.orig
patch -p0 <30_patchfile.hikyuu
echo ".............................. patch importdata.cpp"
#sed -i 's/\\///g' ./tools/importdata/importdata.cpp

./build.sh

cp Jamroot.linux.orig Jamroot.linux
rm Jamroot.linux.orig

hikyuu_cpp/hikyuu/global/agent/spot_generated.h:157:12: error: no matching member function for call to 'VerifyField'

mac上build失败,报错如下

[ 58%]: compiling.release hikyuu_cpp/hikyuu/utilities/Parameter.cpp
error: hikyuu_cpp/hikyuu/global/agent/spot_generated.h:156:12: error: no matching member function for call to 'VerifyField'
VerifyField(verifier, VT_YESTERDAY_CLOSE) &&
^~~~~~~~~~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note: candidate function template not viable: requires 3 arguments, but 2 were provided
bool VerifyField(const Verifier &verifier, voffset_t field,
^
In file included from hikyuu_cpp/hikyuu/GlobalInitializer.cpp:22:
In file included from hikyuu_cpp/hikyuu/global/GlobalSpotAgent.h:8:
In file included from hikyuu_cpp/hikyuu/global/agent/SpotAgent.h:12:
hikyuu_cpp/hikyuu/global/agent/spot_generated.h:157:12: error: no matching member function for call to 'VerifyField'
VerifyField(verifier, VT_OPEN) &&
^~~~~~~~~~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note: candidate function template not viable: requires 3 arguments, but 2 were provided
bool VerifyField(const Verifier &verifier, voffset_t field,
^
In file included from hikyuu_cpp/hikyuu/GlobalInitializer.cpp:22:
In file included from hikyuu_cpp/hikyuu/global/GlobalSpotAgent.h:8:
warning: target(hikyuu).add_linkdirs("/Users/wangjinlong/workspace/hikyuu/boost_1_79_0/stage/lib") path not found at ./xmake.lua:78
[ 44%]: compiling.release hikyuu_cpp/hikyuu/GlobalInitializer.cpp
[ 44%]: compiling.release hikyuu_cpp/hikyuu/utilities/Parameter.cpp
error: hikyuu_cpp/hikyuu/global/agent/spot_generated.h:156:12: error: no matching member function for call to 'VerifyField'
VerifyField(verifier, VT_YESTERDAY_CLOSE) &&
^~~~~~~~~~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note: candidate function template not viable: requires 3 arguments, but 2 were provided
bool VerifyField(const Verifier &verifier, voffset_t field,
^
In file included from hikyuu_cpp/hikyuu/GlobalInitializer.cpp:22:
In file included from hikyuu_cpp/hikyuu/global/GlobalSpotAgent.h:8:
In file included from hikyuu_cpp/hikyuu/global/agent/SpotAgent.h:12:
hikyuu_cpp/hikyuu/global/agent/spot_generated.h:157:12: error: no matching member function for call to 'VerifyField'
VerifyField(verifier, VT_OPEN) &&
^~~~~~~~~~~~~~~~~~~
/usr/local/include/flatbuffers/table.h:115:8: note: candidate function template not viable: requires 3 arguments, but 2 were provided
bool VerifyField(const Verifier &verifier, voffset_t field,
^
In file included from hikyuu_cpp/hikyuu/GlobalInitializer.cpp:22:
In file included from hikyuu_cpp/hikyuu/global/GlobalSpotAgent.h:8:

importdata以后c:\stock没有数据

您好,感谢开发了这款产品。我按照文档安装好,执行importdata时日志如下,但是运行测试30万本金的sz000001买入时提示stock为空。

日志:
^^^^^^^^^^^^^^^^^^^^^^^
c:\Python36\Lib\site-packages\hikyuu>importdata
目标数据库: c:\stock/stock.db
通达信数据源: c:\TdxW_HuaTai
sh_day 目标文件: c:\stock/sh_day.h5
sz_day 目标文件: c:\stock/sz_day.h5
sh_5min 目标文件: c:\stock/sh_5min.h5
sz_5min 目标文件: c:\stock/sz_5min.h5
sh_1min 目标文件: c:\stock/sh_1min.h5
sz_1min 目标文件: c:\stock/sz_1min.h5

从通达信导入股票代码表
0.109s

导入数据[sh_1min]: c:\TdxW_HuaTai/vipdoc/sh/minline
[==================================================] 100%
导入数量:0
17.347s

导入数据[sh_5min]: c:\TdxW_HuaTai/vipdoc/sh/fzline
[==================================================] 100%
导入数量:0
17.909s

导入数据[sh_day]: c:\TdxW_HuaTai/vipdoc/sh/lday
[==================================================] 100%
导入数量:0
16.957s

导入数据[sz_1min]: c:\TdxW_HuaTai/vipdoc/sz/minline
[==================================================] 100%
导入数量:0
18.689s

导入数据[sz_5min]: c:\TdxW_HuaTai/vipdoc/sz/fzline
[==================================================] 100%
导入数量:0
19.563s

导入数据[sz_day]: c:\TdxW_HuaTai/vipdoc/sz/lday
[==================================================] 100%
导入数量:0
18.876s

更新股票日期信息...
更新上证股票日期信息...
更新深证股票日期信息...
0.328s

导入上证权息信息: c:\stock/weight/shase/weight
[import_stock_weight] dir_path(c:\stock/weight/shase/weight) not exist!
0s

导入深证权息信息: c:\stock/weight/sznse/weight
[import_stock_weight] dir_path(c:\stock/weight/sznse/weight) not exist!
0.015s

总耗时:1.83093m 109.856s

Closing c:\stock/sz_day.h5...Closed!
Closing c:\stock/sz_5min.h5...Closed!
Closing c:\stock/sz_1min.h5...Closed!
Closing c:\stock/sh_day.h5...Closed!
Closing c:\stock/sh_5min.h5...Closed!
Closing c:\stock/sh_1min.h5...Closed!
Closing Sqlite3 database...Closed!

^^^^^^^^^^^^^^^^^^^^^^^
想请教一下:
1)怎么样才能获取到这份数据“沪市日线数据文件149M、深市日线数据文件184M、5分钟线数据各不到2G。”
2)为什么为会空

望赐教~

使用通达信盘后数据导入数据库报错

'gbk' codec can't decode byte 0xbb in position 7: incomplete multibyte sequence
导入完毕!
无法执行,
我想是这两个文件的问题,有一个太久未更新了,谢谢
tdx_to_h5.py
tdx_to_mysql.py

如何在windows上编译debug版本

目的:
release版本运行正常,但没法调试C++部分,在VS里无法将源码附加到进程。为了调试,需要编译debug版本。

做了如下步骤:

  1. 编译安装boost 1.68的debug,release版本
  2. 正常安装xmake
  3. 在官网下载了hdf5 1.10.2和mysql connector C 6.1.11的源码和cmake脚本,编译了debug版本,在hikyuu_extern_libs里新建相关目录(inc or lib/debug/windows/x64)并仿照release目录里的内容拷贝了编译出来的文件
  4. xmake f -m debug,之后就正常编译安装

结果:
编译没有报错,但没法正常运行,很明显c++部分没编译成功。执行from hikyuu.interactive.interactive import *后出现:
发生异常: ImportError DLL load failed: 找不到指定的模块。 File "C:\Users\seedn\OneDrive\Projects\Python\hikyuu\hikyuu\core_doc.py", line 28, in <module> from hikyuu._hikyuu import * File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "C:\Users\seedn\OneDrive\Projects\Python\hikyuu\hikyuu\core.py", line 34, in <module> from .core_doc import * File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "C:\Users\seedn\OneDrive\Projects\Python\hikyuu\hikyuu\__init__.py", line 51, in <module> from .core import * File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 953, in _find_and_load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 953, in _find_and_load_unlocked File "C:\users\seedn\onedrive\projects\python\hikyuu\&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "C:\Users\seedn\OneDrive\Projects\Python\hikyuu\backtest.py", line 3, in <module> from hikyuu.interactive.interactive import *
求大佬指条明路,或者指点一下如何在release版本中调试。

Mac上编译总是显示 mysql/mysql.h not found error

On Mac, I simply cannot run apt-get install libmysqlclient-dev, therefore when I run "python setup.py build", I get many errors about mysql.h such as:

error: hikyuu_cpp/hikyuu/utilities/db_connect/mysql/MySQLStatement.h:20:14: fatal error: 'mysql/mysql.h' file not found
#include <mysql/mysql.h>
^~~~~~~~~~~~~~~
1 error generated.

This error makes sense to me, because on my Macbook, mysql.h is under /usr/local/mysql/include/ , not /usr/include/mysql.

Then the question is: how to fix my build error?

Traditionally, in order to fix this error, I can simply add the path where mysql.h is located to "gcc -I [additional path]". I am not very familiar with how the build tool works in hikyuu, so it will be appreciated if someone can teach me how to add /usr/local/mysql/include in. Many thanks!

James

mangled name for boost::python::detail::caller<F, CallPolicies, Sig>::caller(F, CallPolicies)

  1. build environment:
    Ubuntu: 18.04.1
    hikyuu: 1.0.9
    xmake: 2.2.2
    g++: 7.3.0
    python: 3.6.6
    boost: 1.67.0
    ※ 按照 C++ 开发者指南 文档来编译的。

  2. error message:

[21%]: compiling.release hikyuu_pywrap/trade_sys/_AllocateFunds.cpp
[22%]: compiling.release hikyuu_pywrap/trade_sys/_System.cpp
[24%]: compiling.release hikyuu_pywrap/trade_sys/_Selector.cpp
[26%]: compiling.release hikyuu_pywrap/trade_sys/_Condition.cpp
error: /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/detail/caller.hpp:174:5: error: mangled name for ‘boost::python::detail::caller::caller(F, CallPolicies) [with F = long unsigned int (std::vector::*)() const noexcept; CallPolicies = boost::python::default_call_policies; Sig = boost::mpl::vector2&>]’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type]
     caller(F f, CallPolicies p) : base(f,p) {}
     ^~~~~~
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/detail/caller.hpp:174:5: error: mangled name for ‘boost::python::detail::caller::caller(F, CallPolicies) [with F = long unsigned int (std::vector::*)() const noexcept; CallPolicies = boost::python::default_call_policies; Sig = boost::mpl::vector2&>]’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type]
In file included from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/object/function_handle.hpp:10:0,
                 from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/converter/arg_to_python.hpp:19,
                 from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/call.hpp:15,
                 from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/object_core.hpp:14,
                 from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/args.hpp:22,
                 from /home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python.hpp:11,
                 from hikyuu_pywrap/trade_sys/_AllocateFunds.cpp:8:
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/object/py_function.hpp: In instantiation of ‘boost::python::objects::py_function::py_function(const Caller&) [with Caller = boost::python::detail::caller::*)() const noexcept, boost::python::default_call_policies, boost::mpl::vector2&> >]’:
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/make_function.hpp:60:38:   required from ‘boost::python::api::object boost::python::detail::make_function_aux(F, const CallPolicies&, const Sig&, const keyword_range&, NumKeywords) [with F = long unsigned int (std::vector::*)() const noexcept; CallPolicies = boost::python::default_call_policies; Sig = boost::mpl::vector2&>; NumKeywords = mpl_::int_<0>; boost::python::detail::keyword_range = std::pair]’
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/make_function.hpp:140:37:   required from ‘boost::python::api::object boost::python::make_function(F, const CallPolicies&, const Keywords&, const Signature&) [with F = long unsigned int (std::vector::*)() const noexcept; CallPolicies = boost::python::default_call_policies; Keywords = boost::python::detail::keywords<0>; Signature = boost::mpl::vector2&>]’
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/class.hpp:493:26:   required from ‘void boost::python::class_::def_impl(T*, const char*, Fn, const Helper&, ...) [with T = std::vector; Fn = long unsigned int (std::vector::*)() const noexcept; Helper = boost::python::detail::def_helper; W = std::vector; X1 = boost::python::detail::not_specified; X2 = boost::python::detail::not_specified; X3 = boost::python::detail::not_specified]’
/home/puppy/workspace/Hikyuu/boost_1_67_0/boost/python/class.hpp:231:9:   required from ‘boost::python::class_::self& boost::python::class_::def(const char*, F) [with F = long unsigned int (std::vector::*)() const noexcept; W = std::vector; X1 = boost::python::detail::not_specified; X2 = boost::python::detail::not_specified; X3 = boost::python::detail::not_specified; boost::python::class_::self = boost::python::class_ >]’
hikyuu_pywrap/trade_sys/_AllocateFunds.cpp:62:49:   required from here

mysql删除后在linux上手动安装成功。boost换成最新的1_67_0无法成功,过程如下

$ cat Install_hikyuu_on_Linux
linux mint 18.3 64bit,默认中文安装系统上通过。boost换成最新的1_67_0无法成功
sudo apt-get install vim git bzip2 build-essential autotools-dev automake autoconf

sudo apt-get install hdf5-helpers libhdf5-cpp-11 libhdf5-dev libhdf5-10 libhdf5-serial-dev
sudo apt-get install libmysqlclient-dev libmysqlclient20 libmysql++-dev libsqlite3-dev libbz2-dev
下面语句可选.
sudo apt-get install libboost-all-dev liblog4cplus-dev gccxml python3-dev liblzma-dev

tar zxvf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install

chmod +x Anaconda3-5.2.0-Linux-x86_64.sh
./Anaconda3-5.2.0-Linux-x86_64.sh
安装完成后关闭终端,再打开。
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
conda config --set show_channel_urls yes

#conda install -y libgcc
#conda install -y pandas numpy flask beautifulsoup4 requests ipython
#conda install -y matplotlib lxml hdf5 jupyter
#conda install -y mkl
#conda install -y mysql-python
#conda create --name hiyuu python=3.6
#pip install mysql-connector-python -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install ta-lib -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyperclip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyecharts -i https://pypi.tuna.tsinghua.edu.cn/simple

export CPLUS_INCLUDE_PATH=/home/zhangshoug/anaconda3/include/python3.6m/

tar zxvf boost_1_64_0.tar.gz
cd boost_1_64_0/
./bootstrap.sh --exec-prefix=/usr/local
./b2 -q -j 4 threading=multi
根据提示
export BOOST_ROOT=/home/zhangshoug/boost_1_64_0
export BOOST_LIB=/home/zhangshoug/boost_1_64_0//stage/lib
sudo ./b2 install threading=multi

tar zxvf log4cplus-1.2.1.tar.gz
cd log4cplus-1.2.1/
./configure --prefix=/usr/local CXXFLAGS=-std=c++0x
make -j 4
sudo make install

export LD_RUN_PATH="/usr/local/lib:$LD_RUN_PATH"
export PYTHONPATH=/home/zhangshoug/hikyuu/tools:/home/zhangshoug/anaconda3/
export HIKYUU=/home/zhangshoug/hikyuu
export LD_LIBRARY_PATH=./:/usr/local/lib:/usr/lib:/home/zhangshoug/hikyuu/tools/hikyuu/
export CPLUS_INCLUDE_PATH=/home/zhangshoug/anaconda3/include/python3.6m/::/home/zhangshoug/hikyuu/extern-libs/sqlite3/:/home/zhangshoug/hikyuu/extern-libs/mysql/:/usr/include/:/usr/include/hdf5/serial/:/usr/local/include/log4cplus/

git clone https://github.com/fasiondog/hikyuu.git
cd hikyuu/
如出现mysql相关错误。
zhangshoug@zhangshouguo-VirtualBox ~ $ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from hikyuu.interactive.interactive import *
Traceback (most recent call last):
File "", line 1, in
File "/home/zhangshoug/hikyuu/tools/hikyuu/init.py", line 56, in
from .core import *
File "/home/zhangshoug/hikyuu/tools/hikyuu/core.py", line 34, in
from .core_doc import *
File "/home/zhangshoug/hikyuu/tools/hikyuu/core_doc.py", line 28, in
from hikyuu._hikyuu import *
ImportError: /home/zhangshoug/hikyuu/tools/hikyuu/libhikyuu.so: undefined symbol: mysql_num_rows
则如下操作:
find ./ -name mysql|xargs rm -rf
find ./ -type f -name '.cpp'|xargs grep 'mysql'
find ./ -type f -name '
.cpp'|xargs grep 'MySQL'
修改cpp,删除mysql相关语句。

cp Jamroot.linux Jamroot.linux.orig
vi +13 Jamroot.linux
改成如下:你的python版本和python安装目录
using python : 3.6 : : /home/zhangshoug/anaconda3 ;

./build.sh
如遇错误:
cd tools/hikyuu/
python hku_config.py
./importdata
再返回运行
./build.sh

$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from hikyuu.interactive.interactive import *
21:13:17 TRACE - SQLITE3: /home/zhangshoug/stock/stock.db
21:13:17 TRACE - Loading market information...
21:13:17 TRACE - Loading stock type information...
21:13:17 TRACE - Loading stock information...
21:13:17 TRACE - Loading KData...
21:13:17 TRACE - Preload all day kdata to buffer! [StockManager::setKDataDriver]
21:13:18 TRACE - 1.6755 seconds Loaded Data.
exit()
21:13:22 TRACE - Closed Sqlite3 database!
21:13:22 TRACE - Quit Hikyuu system!
安装完成后将如下语句加入.bashrc
export PATH="/home/zhangshoug/hikyuu/tools/hikyuu:$PATH"

技术指标 RSI,KDJ

运行代码 如下
st = sm['SH000001']
kd = st.get_kdata(Query(-100,ktype=Query.WEEK))
r1,r2,r3 = RSI(kd)
报错在RSI里
技术指标

未导入成功talib,k.plot()后无图片

在Win10 + VS2017环境,按照指导安装版本,测试没有出现K线图。我根据网上一些信息,通过pip安装了talib

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from hikyuu.interactive.interactive import *
warning: can't import talib, maybe loss some Indicator from talib!
std::cout are redirected to python::stdout
std::cerr are redirected to python::stderr
[2019-02-16 22:36:26.510] [trace] SQLITE3: F:\Stocks\stockdata/stock.db
[2019-02-16 22:36:26.510] [info] Loading market information...
[2019-02-16 22:36:26.511] [info] Loading stock type information...
[2019-02-16 22:36:26.511] [info] Loading stock information...
[2019-02-16 22:36:26.712] [info] Loading KData...
[2019-02-16 22:36:26.714] [info] Preload all day kdata to buffer! [StockManager::setKDataDriver]
[2019-02-16 22:36:27.310] [info] 0.597821s Loaded Data.
>>> s=sm['sh000001']
>>> k=s.getKData(Query(-150))
>>> k.plot()
>>>

windows 10 通过python setup.py install 安装出错

Python 版本 3.74
错误信息如下:
/*************************************************************************************************

C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock2.h(2662): error C2375: “WSACancelAsyncRequest”: 重定义;不同的链接
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(936): note: 参见“WSACancelAsyncRequest”的声明
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock2.h(2680): error C2375: “WSAAsyncSelect”: 重定义;不同的链接
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(938): note: 参见“WSAAsyncSelect”的声明
hikyuu_extern_libs\pkg\mysql.pkg\inc\release\windows\x64\mysql.h(752): error C2059: 语法错误:“}”
hikyuu_extern_libs\pkg\mysql.pkg\inc\release\windows\x64\mysql.h(752): error C2143: 语法错误: 缺少“;”(在“}”的前面)
E:\Experiment\C++\hikyuu\hikyuu_cpp\hikyuu\data_driver/base_info/mysql/MySQLBaseInfoDriver.h(20): error C2143: 语法错误: 缺少“;”(在“{”的前面)
E:\Experiment\C++\hikyuu\hikyuu_cpp\hikyuu\data_driver/base_info/mysql/MySQLBaseInfoDriver.h(20): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
hikyuu_cpp\hikyuu\StockManager.cpp(99): error C2065: “MySQLBaseInfoDriver”: 未声明的标识符
hikyuu_cpp\hikyuu\StockManager.cpp(99): error C2672: “std::make_shared”: 未找到匹配的重载函数
hikyuu_cpp\hikyuu\StockManager.cpp(99): error C2974: 'std::make_shared' : 模板 对于 '_Ty'是无效参数,应为类型
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\include\memory(1607): note: 参见“std::make_shared”的声明

[ 38%]: compiling.release hikyuu_cpp\hikyuu\StockManager.cpp
[ 38%]: compiling.release hikyuu_cpp\hikyuu\Stock.cpp
[ 39%]: compiling.release hikyuu_cpp\hikyuu\trade_sys\moneymanager\imp\FixedCapitalMoneyManager.cpp
[ 39%]: compiling.release hikyuu_cpp\hikyuu\data_driver\KDataTempCsvDriver.cpp
error: StockManager.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(103): error C2220: 警告被视为错误 - 没有生成“object”文件
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(103): warning C4005: “AF_IPX”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(457): note: 参见“AF_IPX”的前一个定义C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(147): warning C4005: “A
F_MAX”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(476): note: 参见“AF_MAX”的前一个定义C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(185): warning C4005: “S
O_DONTLINGER”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(399): note: 参见“SO_DONTLINGER”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(238): error C2011: “sockaddr”:“struct”类型重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(1007): note: 参见“sockaddr”的声明
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(440): error C2143: 语法错误: 缺少“}”(在“常数”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(440): error C2059: 语法错误:“常数”
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(494): error C2143: 语法错误: 缺少“;”(在“}”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(494): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(494): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(575): warning C4005: “IN_CLASSA”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(284): note: 参见“IN_CLASSA”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(581): warning C4005: “IN_CLASSB”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(290): note: 参见“IN_CLASSB”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(587): warning C4005: “IN_CLASSC”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(296): note: 参见“IN_CLASSC”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(598): warning C4005: “INADDR_ANY”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(301): note: 参见“INADDR_ANY”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(600): warning C4005: “INADDR_BROADCAST”: 宏重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(303): note: 参见“INADDR_BROADCAST”的前一个定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\ws2def.h(636): error C2011: “sockaddr_in”:“struct”类型重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(1011): note: 参见“sockaddr_in”的声明C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock2.h(136): error C2011: “fd_se
t”:“struct”类型重定义
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\winsock.h(1019): note: 参见“fd_set”的声明

Improve to find and get python info in xmake.lua

https://github.com/fasiondog/hikyuu/blob/master/hikyuu_pywrap/xmake_on_load.lua 中对python的查找可以改进下,我更新了下 xmake,增加了对python查找的支持,windows上即使没加path环境,通过下面的脚本,也是可以找到并使用的。。

import("lib.detect.find_tool")

function main(target)

    -- find python
    local python = assert(find_tool("python", {version = true}), "python not found, please install it first!")

    -- get python version
    print(python.version)

    -- get python directory
    local pydir = os.iorunv(python.program, {"-c", "import sys; print(sys.executable)"})

    -- find python3
    local python3 = assert(find_tool("python3", {version = true}), "python3 not found, please install it first!")
    print(python3.program, python3.version)
end

https://github.com/tboox/xmake/releases/download/v2.2.1/xmake-v2.2.2-dev.exe

hikyuu-1.1.8 build/test/install 提示 error: unknown target(sqlite3) for hikyuu.deps! 谢谢!

checking xmake ...
xmake v2.5.7+202110011221, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
_
__ ___ __ __ __ | | ______
\ / / | / |/ _ | |/ / __
> < | _
/ | /| | < /
/
/__|
| |
|_
||____|
by ruki, xmake.io

�  Manual: https://xmake.io/#/getting_started
�  Donate: https://xmake.io/#/sponsor

current python version: 3.7
BOOST_ROOT: E:\AllInOne\Hikyuu\hikyuu-1.1.8/boost_1_77_0
BOOST_LIB: E:\AllInOne\Hikyuu\hikyuu-1.1.8/boost_1_77_0/stage/lib
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
error: unknown target(sqlite3) for hikyuu.deps!
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
error: unknown target(sqlite3) for hikyuu.deps!
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
error: unknown target(sqlite3) for hikyuu.deps!
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
error: unknown target(sqlite3) for hikyuu.deps!

我找了一下hikyuu_extern_lib这个目录下是空的

xmake过程报错,另 python版本应使用哪个版本

Xmake报错:
error: C:\Program Files (x86)\xmake/core/base/os.lua:691: C:\Program Files (x86)\xmake/core/base/os.lua:691: F:\Workspace\Quant\hikyuu\hikyuu_pywrap\xmake.lua:22: attempt to call global 'get_config' (a nil value)
stack traceback:
[F:\Workspace\Quant\hikyuu\hikyuu_pywrap\xmake.lua:22]: in main chunk

stack traceback:
[C]: in function 'error'
[C:\Program Files (x86)\xmake/core/base/os.lua:691]: in function 'raise'
[C:\Program Files (x86)\xmake/core/base/interpreter.lua:1593]: in function 'add_subdirs'
[F:\Workspace\Quant\hikyuu\xmake.lua:79]: in main chunk
--with-python编译报
libs\python\src\exec.cpp(112): error C3861: “_Py_fopen”: 找不到标识符

求解……

TradeManager对象以指定价格卖出全部数量指定股票操作时报错

执行代码示例006-TradeManager中的
td = my_tm.sell(Datetime(201702210000), sm['sz000001'], 9.60)
报错
————————————————————————————————————————————————————————————

ArgumentError Traceback (most recent call last)
in ()
1 my_tm = crtTM(initCash=100000, datetime=Datetime(201701010000))
2 td = my_tm.buy(Datetime(201701030000),sm['sz000001'],9.11,100)
----> 3 td = my_tm.sell(Datetime(201802220000),sm['sz000001'],9.6)
4

ArgumentError: Python argument types in
TradeManager.sell(TradeManager, Datetime, Stock, float)
did not match C++ signature:
sell(class hku::TradeManager {lvalue}, class hku::Datetime datetime, class hku::Stock stock, double realPrice, unsigned __int64 num, double stoploss=0.0, double goalPrice=0.0, double planPrice=0.0, enum hku::SystemPart part=hikyuu.trade_sys._trade_sys.Part.INVALID)

————————————————————————————————————————————————————————————
而执行
td = my_tm.sell(Datetime(201702210000), sm['sz000001'], 9.60, 100)
是可以的

动态任意周期的K线

如3日K,4日K,5日K.主要用于解决周K,月K交易天数不一样,比较成交量判断缩量放量标准不一的问题.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.