Git Product home page Git Product logo

rqalpha-mod-tushare's Introduction

rqalpha-mod-tushare

Make Tushare compatible with RQAlpha

这个 mod 暂时处于 demo 阶段,由于没有对数据进行完整地还原,使用起来可能会出现诸多 bug。 在这个 mod 达到可用的状态前暂时不会发包到 pypi,所以暂时不能通过 pip 或者 rqalpha mod install 命令进行安装。 欢迎各位同学提交代码一起完成 tushare 数据源的对接。

rqalpha-mod-tushare's People

Contributors

cuizi7 avatar wh1100717 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

rqalpha-mod-tushare's Issues

运行多个样例出差:Exception: real has wrong dimensions

C:\Python35\python.exe C:/www/rqalpha-develop/rqalpha run -f C:\www\rqalpha-develop\rqalpha\examples\rsi.py -s 2017-01-01 -e 2017-04-01 --stock-starting-cash 100000 -mc tushare1.enable True
2017-01-03 ERROR Traceback (most recent call last):
File C:\www\rqalpha-develop\rqalpha\examples\rsi.py, line 38 in handle_bar
rsi_data = talib.RSI(prices, timeperiod=context.TIME_PERIOD)[-1]
--> context = Context({stocks = ['000001.XSHE', '601988.XSHG', '000068.XSHE'], ORDER_PERCENT = 0.3, s2 = '601988.XSHG', LOW_RSI = 30, s3 = '000068.XSHE', TIME_PERIOD = 14, HI ...
--> stock = '000001.XSHE'
--> prices = array([[ 9.42],
[ 9.4 ],
[ 9.25],
[ 9.25],
[ 9.2 ],
[ 9.11],
[ 9.16],
[ 9.14],
[ 9.08],
[ 9.12],
...
--> bar_dict = BarMap()

Exception: real has wrong dimensions
Traceback (most recent call last):
File "C:\www\rqalpha-develop\rqalpha\core\strategy.py", line 84, in handle_bar
self._handle_bar(self._user_context, bar_dict)
�� �� �� BarMap()
�� �� <rqalpha.core.strategy.Strategy object at 0x140AF8F0>
�� <rqalpha.core.strategy.Strategy object at 0x140AF8F0>
File "C:\www\rqalpha-develop\rqalpha\examples\rsi.py", line 38, in handle_bar
rsi_data = talib.RSI(prices, timeperiod=context.TIME_PERIOD)[-1]
�� �� �� Context({stocks = ['000001.XSHE', '601988.XSHG', '000068.XSHE'], ORDER_PERCENT = 0.3, s2 = '601988.XSHG', LOW_RSI = 30, s3 = '00...
�� �� array([[ 9.42],
[ 9.4 ],
[ 9.25],
[ 9.25],
[ 9.2 ],
[ 9.11],
[ 9.16],
[ 9.14],
...
�� <module 'talib' from 'C:\Python35\lib\site-packages\talib\init.py'>
File "talib/func.pyx", line 9649, in talib.func.RSI (talib\func.c:101770)
Exception: real has wrong dimensions

Process finished with exit code 0

assert broker is not None,Mod Import Error

C:\Python35\python.exe C:/www/huice/rqalpha/rqalpha run -f C:\www\huice\rqalpha\rqalpha\examples\golden_cross.py --stock-starting-cash 100000 -s 2015-01-01 -e 2016-08-09 -mc tushare1.enable True
[2017-04-08 21:46:34.427020] ERROR: system_log: **********
[2017-04-08 21:46:34.427020] ERROR: system_log: Mod Import Error:
[2017-04-08 21:46:34.427020] ERROR: system_log: No module named 'tushare1'
[2017-04-08 21:46:34.427020] ERROR: system_log: **********
0000-00-00 ERROR
[2017-04-08 21:46:34.786387] ERROR: system_log: 策略运行产生异常
Traceback (most recent call last):
File "C:/www/huice/rqalpha/rqalpha\main.py", line 208, in run
assert broker is not None
AssertionError

Process finished with exit code 0

怎么安装使用

我把对应的文件复制到mod目录中,然后到mod目录里面 敲
rqalpha mod install rqalpha_mod_tushare
报错

策略运行产生异常(最简单的样例 buy_and_hold.py)

C:\Python35\python.exe C:/www/huice/rqalpha/rqalpha run -f C:\www\huice\rqalpha\rqalpha\examples\golden_cross.py --stock-starting-cash 100000 -s 2015-01-01 -e 2016-08-09 -mc tushare1.enable True
0000-00-00 ERROR dict must be set to a dictionary, not a 'set'
[2017-04-08 23:21:58.630125] ERROR: system_log: 策略运行产生异常
Traceback (most recent call last):
File "C:/www/huice/rqalpha/rqalpha\main.py", line 190, in run
mod_handler.set_env(env)
File "C:\www\huice\rqalpha\rqalpha\mod_init_.py", line 57, in set_env
mod_config = RqAttrDict(copy.deepcopy(getattr(mod_module, "config", {})))
File "C:\www\huice\rqalpha\rqalpha\utils_init_.py", line 50, in init
self.dict = d if d is not None else dict()
TypeError: dict must be set to a dictionary, not a 'set'
Traceback (most recent call last):
File "C:\Python35\lib\runpy.py", line 170, in run_module_as_main
"main", mod_spec)
File "C:\Python35\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
�� �� {'entry_point': <function entry_point at 0x01172660>, 'spec': ModuleSpec(name='main', loader=<frozen_importlib_external...
�� <code object at 0x0116C750, file "C:/www/huice/rqalpha/rqalpha_main
.py", line 17>
File "C:/www/huice/rqalpha/rqalpha_main
.py", line 327, in
entry_point()
�� <function entry_point at 0x01172660>
File "C:/www/huice/rqalpha/rqalpha_main.py", line 68, in entry_point
cli(obj={})
�� <click.core.Group object at 0x05697CD0>
File "C:\Python35\lib\site-packages\click\core.py", line 722, in call
return self.main(*args, **kwargs)
�� �� �� {'obj': {'VERBOSE': 0}}
�� �� ()
�� <click.core.Group object at 0x05697CD0>
File "C:\Python35\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
�� �� <click.core.Context object at 0x056A39B0>
�� <click.core.Group object at 0x05697CD0>
File "C:\Python35\lib\site-packages\click\core.py", line 1066, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
�� �� �� <click.core.Context object at 0x056BCF10>
�� �� <click.core.Context object at 0x056BCF10>
�� <function MultiCommand.invoke..process_result at 0x056A7390>
File "C:\Python35\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
�� �� �� <click.core.Context object at 0x056BCF10>
�� �� <click.core.Command object at 0x056A3330>
�� <click.core.Context object at 0x056BCF10>
File "C:\Python35\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
�� �� �� {'base__end_date': Timestamp('2016-08-09 00:00:00'), 'base__securities': None, 'base__strategy_file': 'C:\www\huice\rqalpha\...
�� �� ()
�� <function run at 0x056A7540>
File "C:/www/huice/rqalpha/rqalpha_main
.py", line 120, in run
main.run(parse_config(kwargs, config_path))
�� �� �� �� None
�� �� �� {'mod__tushare1__enable': True, 'base__securities': None, 'base__strategy_file': 'C:\www\huice\rqalpha\rqalpha\examples\go...
�� �� <function parse_config at 0x0569FC00>
�� <module 'main' from 'C:/www/huice/rqalpha/rqalpha\main.py'>
File "C:/www/huice/rqalpha/rqalpha\main.py", line 321, in run
mod_handler.tear_down(code, user_exc)
�� �� �� CustomException(dict must be set to a dictionary, not a 'set',)
�� �� EXIT_CODE.EXIT_INTERNAL_ERROR
�� <rqalpha.mod.ModHandler object at 0x05AFCD90>
File "C:\www\huice\rqalpha\rqalpha\mod_init
.py", line 72, in tear_down
ret = self._mod_dict[mod_name].tear_down(*args)
�� �� �� (EXIT_CODE.EXIT_INTERNAL_ERROR, CustomException(dict must be set to a dictionary, not a 'set',))
�� �� 'tushare1'
�� <rqalpha.mod.ModHandler object at 0x05AFCD90>
KeyError: 'tushare1'

Process finished with exit code 1

Suggest to loosen the dependency on rqalpha

Hi, your project rqalpha-mod-tushare(commit id: 60809a7) requires "rqalpha==2.0.0" in its dependency. After analyzing the source code, we found that the following versions of rqalpha can also be suitable, i.e., rqalpha 0.3.12, 0.3.13, 0.3.14, 0.3.15, 0.3.16, 2.0.0b0, since all functions that you directly (2 APIs: rqalpha.interface.AbstractMod.init, rqalpha.data.base_data_source.BaseDataSource.init) or indirectly (propagate to 7 rqalpha's internal APIs and 6 outsider APIs) used from the package have not been changed in these versions, thus not affecting your usage.

Therefore, we believe that it is quite safe to loose your dependency on rqalpha from "rqalpha==2.0.0" to "rqalpha>=0.3.12,<=2.0.0". This will improve the applicability of rqalpha-mod-tushare and reduce the possibility of any further dependency conflict with other projects.

May I pull a request to further loosen the dependency on rqalpha?

By the way, could you please tell us whether such an automatic tool for dependency analysis may be potentially helpful for maintaining dependencies easier during your development?

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.