Giter Club home page Giter Club logo

kelly-criterion's Introduction

Kelly Criterion

Money management strategy based on Kelly J. L.'s formula described in "A New Interpretation of Information Rate" [1]. The formula was adopted to gambling and stock market by Ed Thorp, et al., see: "The Kelly Criterion in Blackjack Sports Betting, and the Stock Market" [2].

This program calculates the optimal capital allocation for the provided portfolio of securities with the formula:

    `f_i = m_i / s_i^2`

where

  • f_i is the calculated leverage of the i-th security from the portfolio
  • m_i is the mean of the return of the i-th security from the portfolio
  • s_i is the standard deviation of the return of the i-th security from the portfolio

assuming that the strategies for the securuties are all statistically independent.

The stock quotes are downloaded from Yahoo Finance using Pandas.

Reference (Matlab) implementation was taken from Ernie Chan's Quantitative Trading book [3].

Installation

pip install kelly_criterion

Usage

kelly_criterion [--risk-free-rate=<pct>] <start-date> <end-date> <security>...

Example

$ kelly_criterion --risk-free-rate 0.04 2001-02-26 2014-12-28 IBB VDE SPY
Kelly Criterion calculation
Arguments: risk-free-rate=0.04 start-date=2001-02-26 end-date=2014-12-28 securities=['IBB', 'VDE', 'SPY']

Leverages per security:
  IBB: 3.61
  SPY: -2.73
  VDE: 1.04
Sum leverage: 1.92

Dependencies

References

kelly-criterion's People

Contributors

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