GithubHelp home page GithubHelp logo

easyhistory's Introduction

easyhistory

用于获取维护股票的历史数据

引入

import easyhistory

读取 rqalpha 保存的历史数据

读取平安银行

easyhistory.history('000001') 

return pandas dataframe: 
                  open   close    high     low    volume  total_turnover  \
datetime
20050104000000  1.6668  1.6491  1.6668  1.6338   6961738        11465602
20050105000000  1.6491  1.6338  1.6567  1.6061  12739274        20718558
20050106000000  1.6440  1.6491  1.6668  1.6314  10542101        17333840
20050107000000  1.6643  1.6466  1.6693  1.6338   7457207        12302853
20050110000000  1.6466  1.6668  1.6668  1.6112  10406261        17111498

                limit_up  limit_down
datetime
20050104000000    1.8337      1.4999
20050105000000    1.8135      1.4846
20050106000000    1.7983      1.4695
20050107000000    1.8135      1.4846
20050110000000    1.8110      1.4822

读取上证指数

easyhistory.history('000001', market='sh')

初始化日线历史数据

easyhistory.init('D', export='csv', path='history')

注1: 下载后的原始数据在 path/day/raw_data 下, 复权后数据在 path/day/data

注2: 下载所有股票的历史数据需要很长时间,推荐直接从百度盘(数据到 20160318 )下载,

更新

easyhistory.update('D', export='csv', path='history')

指标系统

目前还在测试中,指标计算使用了 talibpandas, 可以直接调用 talib 计算一百多种指标,包括 MACD, EMA, MA

使用

his = easyhistory.History(dtype='D', path='行情目录')

# MA 计算, 直接调用的 talib 的对应函数
res = his['000001'].MA(5)


# 返回的是 pandas 的 dataframe 格式

             open   high  close    low     volume      amount  factor     MA5
date                                                                         
2016-03-10  10.24  10.35  10.15  10.13  506112.94  5193459.68  93.659  10.268
2016-03-11  10.10  10.22  10.16  10.04  409716.87  4160186.89  93.659  10.220

注: talib 可用指标以及相关参数 以及 pandas 相关

Q&A

Q:安装 talib 提示找不到 vcvarsall.bat ? A: 去 http://www.lfd.uci.edu/~gohlke/pythonlibs 下载 wheels版本的包使用 pip install xxx.whl 安装

easyhistory's People

Contributors

chuihero avatar daycount avatar fuxiao511 avatar shidenggui avatar

Watchers

 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.