Code Monkey home page Code Monkey logo

vix_strategy_backtest's Introduction

vix_strategy_backtest

Logo

Fearful when others are greedy, and greedy when others are fearful.

Contents

What is Vix strategy?

The VIX index, also known as the “fear index” is reported by the Chicago Board Options Exchange and provides investors and traders valuable insight into current greed and fear levels in the market. The Cboe Volatility Index (VIX) is a real-time index that represents the market's expectations for the relative strength of near-term price changes of the S&P 500 index (SPX).

The strategy I have used

First of all I have plotted both the graph of s&p500 and vix index. According the the plotted graph, I have decided that whenever vix index hit 35 or more i will buy the shares as fear is in market. Then I have tested by selling the shares whenever vix index hit 10. But result was not so good. Then I have created a strategy where I will add 5000$ of cash to the broker at every 20 days or one market month. And buy stocks only when vix index hit 35. This gave a preety nice result.

Libraries

  • backtrader - It is an open-source framework that allows for strategy testing on historical data.
  • pandas - the most powerful and flexible open source data analysis / manipulation tool.
  • os - The OS module in Python provides functions for interacting with the operating system.
  • DateTime - This module supplies classes for manipulating dates and times.

Description of each file

  1. main.py - This is the main method of the project where strategy is being executed with the help of backtrader's cerebro method.
  2. VIXStrategy.py - Here I have created the strategy to implement the VIX index in S&P500.

Datasets

I have downloaded the S&P500 and VIX datasets and combine them to use my strategy as SPY_VIX.csv. Other stocks historical data also can be downloaded from yahoo finance.

How to use?

Finally one can run the project by typing as bellow:

$ python main.py

vix_strategy_backtest's People

Contributors

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