Giter Site home page Giter Site logo

backtesting-rsi-algo's Introduction

Python RSI Momentum Trading Strategy Backtest with Zipline and Pyfolio

Use the RSI signal to drive algorithm buying and selling decisions. When the RSI is over 70, a stock is considered overbought and is sold. On the other hand, when the RSI is below 30, a stock is considered oversold and is bought. Here is additional information from Investorpedia.

Create and set-up a new virtual environment in Conda

Download and install Anaconda

Create a new environment in your conda navidagor or terminal and use Python version 3.5 given dependencies.

$ conda create -n env_zipline python=3.5

Activate the new environment.

$ conda activate env_zipline

Install the packages we need to run the strategy, backtest, and analyze the results

Install the Zipline backtesting library from Quantopian.

$ conda install -c Quantopian zipline

Install interactive Python shell and a Jupyter kernel to work with Python code in Jupyter notebooks and other interactive frontends.

$ conda install -c anaconda ipykernel

Install the Python wrapper for TA-Lib

$ pip install TA-Lib

Install Pyfolio, see documentation here for more information.

pip install pyfolio

Get the stock pricing data necessary for the algo strategy

Obtain a free API key from Quandl

Set an environmental variable in your terminal with your API key.

$ export QUANDL_API_KEY='your API key here'

Ingest the Quandl Wiki Prices data into Zipline

$ zipline ingest -b quandl

Running the backtest

Run the below code in your terminal, check the Zipline Documentation for additional information.

$ zipline run -f backtest.py --start 2014-1-1 --end 2018-1-1 -o perf.pickle --no-benchmark --capital-base 20000 --bundle quandl

backtesting-rsi-algo's People

Contributors

aspromatis 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.