GithubHelp home page GithubHelp logo

betas's Introduction

Beta Analysis

The goal of this project is to develop scalable, reusable, extensible code that estimates the beta for a basket of individual stocks and visualizes the results using the Python programming language and supporting libraries.

This project is composed of two scripts:

  • etl/etl.py: imports about 3000 stocks (NASDAQ only) from Yahoo Finance and computes rolling betas (30 days) for each stock.

  • web/web.py: GUI that makes possible to show the rolling betas for each stock. It is build with React.js

Demo available here http://104.197.68.179/ (Tested under Google Chrome only)

Development Environment

Download and install Anaconda2-4.0.

Clone the repository:

$ git clone https://github.com/bhirbec/betas.git

Create Anaconda project:

$ conda create --name betas

Install eventlet and upgrade Numpy:

$ source activate betas
$ pip install eventlet
$ pip install numpy==1.12.0

Running the ETL

Run the ETL with the following command:

$ python etl/etl.py

Some options are available:

$ python etl.py -h
Usage: python etl.py [options]

Download historical prices from Yahoo Finance and compute some financial
indicators like stock Beta. The first ETL run will create a PyTables database.
Subsequent runs will only download the historical data generated between the previous
run and the current date (or `end_date` if specified).

Options:
  -h, --help            show this help message and exit
  --db-path=DB_PATH     Path to the PyTables file
  --start-date=START_DATE
                        Download history as of this date (yyyy-mm-dd). It has
                        no effect if the database already exists (default
                        2010-01-01)
  --end-date=END_DATE   Download history up to this date (yyyy-mm-dd). Default
                        to the current date
  --destroy             Destroy the PyTables file which forces all the stocks
                        to be downloaded since the `start_date`
  --no-download         Do not download any data from Yahoo - just compute
                        indicators
  --nb-greenthreads=NB_GREENTHREADS
                        Number of greenthreads used to download data
  --nb-proc=NB_PROC     Number of processors used to compute indicators
                        (default to multiprocessing.cpu_count())

Running the Web Server

Start the server with the following command:

$ PYTHONPATH=. python web/web.py

Point your browser (only tested on Google Chrome) at localhost:8080.

Here's the full description of the command:

$ PYTHONPATH=. python web/web.py
Usage: python web.py [options]

Start a web server that provides Financial reports.


Options:
  -h, --help         show this help message and exit
  --host=HOST        TCP Host (default: localhost)
  --port=PORT        TCP port (default: 8080)
  --db-path=DB_PATH  Path to the PyTables file

Running the Unit Tests

Run the test with the following command:

$ nosetests test/tests.py

Deployment

Install Ansible and run this playbook:

$ ansible-playbook ansible/deploy.yaml -i ansible/gce_hosts

betas's People

Contributors

bhirbec avatar

Watchers

James Cloos avatar  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.