Git Product home page Git Product logo

algo_trading_project's Introduction

algo_trading_project

binance_trade

回测框架和策略

  • 框架内有四份文件:Code文件夹、data文件夹、main.py
  • Code文件夹:Backtest.py
  • data文件夹:data.csv,为比特币的K线数据【由于上传限制,无法上传2018.1.1-2021.5.1全部数据,上传2021.1.1-2021.1.15数据为例】
  • main.py:回测框架运行文件

回测框架说明

  • 点开main.py,修改对应参数(年化天数、交易费率、无风险利率、输入文件夹和文件名以及布林带策略的对应参数),运行得到结果
  • 输出结果为该策略下的:整体收益率、年化收益率、年化波动率、最大回撤以及起止时间、夏普比率和信息比率
  • 绘制出策略和基准的净值曲线图

Howtrader回测框架修改说明

single_backtesting.py用于howtrader内部的策略回测;同样也用于检验我们自己的回测系统

策略说明

  • 采用的是布林带策略,回测区间以2021.1.1-2021.1.15为例
  • 当收盘价小于等于下轨时且持仓为0,买入1单位比特币
  • 当收盘价大于等于上轨时且持仓为1,卖出1单位比特币
  • 其他时候不做任何操作

image

GUI说明

  • 基于vnpy框架的UI界面进行了修改
  • 添加了币安交易所的API
  • 下载GUI所有文件后,运行main_window.py后,点击链接binance,输入币安apikey和apisecret,使用其功能。

策略部署

  • 添加策略,命名策略名称,选择交易对代码,初始化,调整策略参数后,运行
  • 添加自己新写的策略可在strategies中增加文件

数据导入直接版本

  • 点击数据管理,导入数据,选择本地已调整好格式的csv文件
  • 也可从系统直接下载数据,速度较慢,大批量数据不推荐使用

数据导入code版本

data_imp.py 用于将本地csv格式数据导入到VN trader的数据管理器中: 呈现格式为.db (SQLite)

(1) howtrader.trader.object里的BarData: record Candlestick bar data of a certain trading period.

(2) howtrader.trader.database里的database_manager.save_bar_data: 存储Sequence of "BarData"

(3) howtrader.trader.constant里的(Exchange,Interval):主要用于标准化语句:Exchange.BINANCE="BINANCE"; Interval.MINUTE: csv数据为分钟数据

binance_trade(实盘交易无界面版)

  • 运行binance_main.py进行运行
  • 主要展示UI界面中各个功能api的运行情况

Howtrader中重要的基础设置类

trader -> howtrader.trader: 对VN Trader中的变量做基础设置

(1) .constant: General constant string used in VN Trader -> Direction、Offset、Status、Product、OrderType、OptionType、Currency、Exchange、Interval

(2) .object: Basic data structure used for general trading function in VN Trader -> 父类:BaseData; 子类: TickData、BarData、OrderData、TradeData...

...

algo_trading_project's People

Contributors

algo21-220040033 avatar algo21-220040036 avatar algo21-220040071 avatar algo21-116020074 avatar algo21-116020075 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.