{"id":13739684,"url":"https://github.com/deltaray-io/kelly-criterion","last_synced_at":"2026-03-09T08:36:17.043Z","repository":{"id":32031389,"uuid":"35602730","full_name":"deltaray-io/kelly-criterion","owner":"deltaray-io","description":"Kelly Criterion calculation","archived":false,"fork":false,"pushed_at":"2022-12-08T01:36:55.000Z","size":19,"stargazers_count":88,"open_issues_count":4,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-04T04:05:31.221Z","etag":null,"topics":["quantitative-finance","quantitative-trading","trading-algorithms"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deltaray-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-14T09:25:00.000Z","updated_at":"2024-07-10T01:51:26.000Z","dependencies_parsed_at":"2023-01-14T20:22:03.453Z","dependency_job_id":null,"html_url":"https://github.com/deltaray-io/kelly-criterion","commit_stats":null,"previous_names":["tibkiss/kelly-criterion"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deltaray-io%2Fkelly-criterion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deltaray-io%2Fkelly-criterion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deltaray-io%2Fkelly-criterion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deltaray-io%2Fkelly-criterion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deltaray-io","download_url":"https://codeload.github.com/deltaray-io/kelly-criterion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224758199,"owners_count":17364969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["quantitative-finance","quantitative-trading","trading-algorithms"],"created_at":"2024-08-03T04:00:36.527Z","updated_at":"2026-03-09T08:36:17.009Z","avatar_url":"https://github.com/deltaray-io.png","language":"Python","funding_links":[],"categories":["Python","Python：量化金融第一生态"],"sub_categories":["Financial Instruments and Pricing","五、投资组合优化与风险分析"],"readme":"Kelly Criterion\n===============\nMoney management strategy based on Kelly J. L.'s formula described in \"A New Interpretation of Information Rate\" [1]. \nThe formula was adopted to gambling and stock market by Ed Thorp, et al., see:\n\"The Kelly Criterion in Blackjack Sports Betting, and the Stock Market\" [2].\n\nThis program calculates the optimal capital allocation for the provided portfolio of securities with the formula:\n\n        `f_i = m_i / s_i^2`\n\nwhere\n  * `f_i` is the calculated leverage of the i-th security from the portfolio\n  * `m_i` is the mean of the return of the i-th security from the portfolio\n  * `s_i` is the standard deviation of the return of the i-th security from the portfolio\n\nassuming that the strategies for the securuties are all statistically independent.\n\nThe stock quotes are downloaded from Yahoo Finance using Pandas.\n\nReference (Matlab) implementation was taken from Ernie Chan's Quantitative Trading book [3].\n\nInstallation\n------------\n`pip install kelly_criterion`\n\nUsage\n-----\n`kelly_criterion [--risk-free-rate=\u003cpct\u003e] \u003cstart-date\u003e \u003cend-date\u003e \u003csecurity\u003e...`\n\nExample\n-------\n```\n$ kelly_criterion --risk-free-rate 0.04 2001-02-26 2014-12-28 IBB VDE SPY\nKelly Criterion calculation\nArguments: risk-free-rate=0.04 start-date=2001-02-26 end-date=2014-12-28 securities=['IBB', 'VDE', 'SPY']\n\nLeverages per security:\n  IBB: 3.61\n  SPY: -2.73\n  VDE: 1.04\nSum leverage: 1.92\n```\n\nDependencies\n------------\n  * Python 2.7\n  * [Numpy](http://www.numpy.org/)\n  * [Pandas](http://pandas.pydata.org/)\n  * [Docopt](http://docopt.org/)\n\nReferences\n----------\n  * [1]: [A New Interpretation of Information Rate](http://ieeexplore.ieee.org/stamp/stamp.jsp?reload=true\u0026tp=\u0026arnumber=6771227)\n  * [2]: [The Kelly Criterion in Blackjack Sports Betting, and the Stock Market](http://www.edwardothorp.com/sitebuildercontent/sitebuilderfiles/beatthemarket.pdf)\n  * [3]: [Ernest P. Chan: Quantitative Trading (ISBN 978-0470284889)](http://www.amazon.com/Quantitative-Trading-Build-Algorithmic-Business/dp/0470284889)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeltaray-io%2Fkelly-criterion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeltaray-io%2Fkelly-criterion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeltaray-io%2Fkelly-criterion/lists"}