Git Product home page Git Product logo

rqalpha-mod-futu's Introduction

rqalpha-mod-futu

RQAlpha 对接 futuquant 的扩展 Mod。通过启用该 Mod 来实现港股和美股交易策略的实盘交易。

rqalpha_mod_futu安装步骤

1. 安装python的Anaconda环境

下载Anaconda 4.4.0,并安装。

2. 安装rqalpha

在命令行中输入如下命令

pip install -U rqalpha

3. 安装futuquant

安装可在命令行中输入如下命令:

pip install futuquant

4. 安装rqalpha-mod-rqalpha

rqalpha mod install futu            # 安装futu mod
rqalpha mod list                    # 查看当前有哪些mod, 如果安装成功,应该会看到futu的mod
rqalpha mod enable futu             # 开启futu的mod
rqalpha mod disable sys_simulation  # 关闭sys_simulation

5. 开始编写策略

在examples文件夹中编写你自己的策略文件 mystrategy.py。修改debug_run_file.py中的配置如下。

# -*- coding: utf-8 -*-

from rqalpha import run_file

config = {
  "base": {
  ... # 这部分不用改,按照原来的配置即可
    "run_type": "b", # 设为回测
  },
  ... # 这部分不用改,按照原来的配置即可
}

strategy_file_path = "./strategy/mystrategy.py" # 设置策略文件

run_file(strategy_file_path, config)

然后运行debug_run_file.py文件即可。

关于如何编写你的mystrategy.py,请参考文档

使用说明
  1. 如何设置运行类型
    在debug_run_file的config里,将运行类型run_type改为相应的标识,其中“b”代表历史数据回测,“p”代表实时数据模拟交易,“r”代表实时数据实盘交易

  2. 如何新增策略文件
    在strategy文件夹中新建脚本,就可以开始写自己的策略了,记得在运行时把debug_run_file里的策略路径修改为对应的策略脚本路径

  3. 如何修改股票代码、起始资金、起始日期等
    参数配置方式遵循rqalpha的参数配置优先级,策略代码中配置 > 命令行参 = run_file传参 > 用户配置文件 > 系统默认配置文件。这里以run_file运行策略为例,在策略代码中设置股票代码,在debug_run_file的config里benchmark可以设置股票池,accounts设置起始资金,start_date, end_date设置起始日期。

  4. 如何设置ip
    在init.py中的config里可以配置ip,本地ip: 127.0.0.1,云端ip: 119.29.141.202

注意
  • 目前暂时只支持日K级别的回测
  • 港股下单不支持市价单,只支持限价单

  • 历史数据需要用户本地下载,历史K线下载指引文档参见历史K线数据下载指引

rqalpha-mod-futu's People

Contributors

jessexu117 avatar cppowboy avatar futunnopen avatar

Watchers

caoyadong avatar

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.