All Projects → bopo → pyalgotrade_tushare

bopo / pyalgotrade_tushare

Licence: other
pyalgotrade 的 tushare 数据源

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to pyalgotrade tushare

Akshare
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Stars: ✭ 4,334 (+14844.83%)
Mutual labels:  quant, tushare
akshare
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Stars: ✭ 5,155 (+17675.86%)
Mutual labels:  quant, tushare
Zipline
Zipline, a Pythonic Algorithmic Trading Library
Stars: ✭ 14,712 (+50631.03%)
Mutual labels:  quant
pandas-datareader-gdax
GDAX data for Pandas in the style of DataReader
Stars: ✭ 11 (-62.07%)
Mutual labels:  quant
wtpy
wtpy是基于wondertrader为底层的针对python的子框架
Stars: ✭ 283 (+875.86%)
Mutual labels:  quant
Wondertrader
WonderTrader——量化研发交易一站式框架
Stars: ✭ 221 (+662.07%)
Mutual labels:  quant
backend-ctp
CTP接口封装,使用redis做消息中转
Stars: ✭ 26 (-10.34%)
Mutual labels:  quant
Stock
30天掌握量化交易 (持续更新)
Stars: ✭ 2,966 (+10127.59%)
Mutual labels:  quant
DeltaTrader
极简版Python量化交易工具
Stars: ✭ 174 (+500%)
Mutual labels:  quant
IBATS HuobiFeeder old
【停止维护】新版本更新已迁移到 IBATS 项目组对应名称项目中。连接火币交易所,获取火币实时行情、火币历史行情,保存到mysql数据库同时redis广播,供 ABAT 交易平台进行策略回测、分析,交易使用
Stars: ✭ 38 (+31.03%)
Mutual labels:  quant
goex backtest
goex orderbook回测, fetch驱动非event驱动的数字货币回测系统
Stars: ✭ 33 (+13.79%)
Mutual labels:  quant
Starquant
a light-weighted, integrated trading/backtesting system/platform(综合量化交易回测系统/平台)
Stars: ✭ 250 (+762.07%)
Mutual labels:  quant
Vnpy
基于Python的开源量化交易平台开发框架
Stars: ✭ 17,054 (+58706.9%)
Mutual labels:  quant
mooquant
MooQuant 是一个基于 pyalgotrade 衍生而来的支持 python3 的支持国内A股的量化交易框架。
Stars: ✭ 24 (-17.24%)
Mutual labels:  quant
Sphinx Quant
一个基于vnpy,支持多账户,多策略,实盘交易,数据分析,分布式在线回测,风险管理,多交易节点的量化交易系统;支持CTP期货,股票,期权,数字货币等金融产品
Stars: ✭ 217 (+648.28%)
Mutual labels:  quant
cryptoquant
An Quantatitive trading library for crypto-assets 数字货币量化交易框架
Stars: ✭ 96 (+231.03%)
Mutual labels:  quant
Awesome Quant
中国的Quant相关资源索引
Stars: ✭ 2,529 (+8620.69%)
Mutual labels:  quant
Pandoratrader
CTP 高频量化交易平台 C++ Trade Platform for quant developer
Stars: ✭ 238 (+720.69%)
Mutual labels:  quant
MyTT
MyTT将通达信,同花顺,文华麦语言等指标公式,最简移植到Python中,核心库单个文件,仅百行代码,十几个核心函数,神奇的实现所有常见技术指标算法(不依赖talib库)的纯python实现和转换通达信MACD,RSI,BOLL,ATR,KDJ,CCI,PSY等公式,全部基于pandas函数计算方法封装,简洁且高性能,能非常方便的应用在股票指标公式,股市期货量化框架分析,自动程序化交易,数字货币量化等领域,它是您最精练的股市量化工具。Python library with most stock market indicators.
Stars: ✭ 888 (+2962.07%)
Mutual labels:  quant
quant
代码迁移到 https://github.com/yutiansut/quantaxis
Stars: ✭ 19 (-34.48%)
Mutual labels:  quant

PyAlgoTrade tushare module

Documentation Status Updates

安装方法

# PIP 自动安装方法
pip install pyalgotrade_tushare

# 手动下载源码安装
git clone https://github.com/bopo/pyalgotrade_tushare.git
cd pyalgotrade_tushare
python setup.py install

使用说明

不多话,简单一个例子

from pyalgotrade import plotter, strategy
from pyalgotrade.stratanalyzer import sharpe
from pyalgotrade.technical import ma

from pyalgotrade_tushare import tools


class MyStrategy(strategy.BacktestingStrategy):
    def __init__(self, feed, instrument):
        super().__init__(feed)

        self.__position = None
        self.__sma = ma.SMA(feed[instrument].getCloseDataSeries(), 150)
        self.__instrument = instrument
        self.getBroker()

    def onEnterOk(self, position):
        execInfo = position.getEntryOrder().getExecutionInfo()
        self.info("买入 %.2f" % (execInfo.getPrice()))

    def onEnterCanceled(self, position):
        self.__position = None

    def onExitOk(self, position):
        execInfo = position.getExitOrder().getExecutionInfo()
        self.info("卖出 %.2f" % (execInfo.getPrice()))
        self.__position = None

    def onExitCanceled(self, position):
        # If the exit was canceled, re-submit it.
        self.__position.exitMarket()

    def getSMA(self):
        return self.__sma

    def onBars(self, bars):
        # 每一个数据都会抵达这里,就像becktest中的next
        # Wait for enough bars to be available to calculate a SMA.
        if self.__sma[-1] is None:
            return

        # bar.getTyoicalPrice = (bar.getHigh() + bar.getLow() + bar.getClose())/ 3.0
        bar = bars[self.__instrument]

        # If a position was not opened, check if we should enter a long position.
        if self.__position is None:
            if bar.getPrice() > self.__sma[-1]:
                # 开多头.
                self.__position = self.enterLong(self.__instrument, 100, True)

        # 平掉多头头寸.
        elif bar.getPrice() < self.__sma[-1] and not self.__position.exitActive():
            self.__position.exitMarket()


if __name__ == '__main__':
    instruments = ["600036"]

    feeds = tools.build_feed(instruments, 2013, 2018, "histdata")

    # 3.实例化策略
    strat = MyStrategy(feeds, instruments[0])

    # 4.设置指标和绘图
    ratio = sharpe.SharpeRatio()
    strat.attachAnalyzer(ratio)
    plter = plotter.StrategyPlotter(strat)

    # 5.运行策略
    strat.run()
    strat.info("最终收益: %.2f" % strat.getResult())

    # 6.输出夏普率、绘图
    strat.info("夏普比率: " + str(ratio.getSharpeRatio(0)))
    plter.plot()

版本更新

  • 修改了 PIP 安装程序问题
  • 本程序只支持 python3.

贡献名单

  • bopo.wang
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].