Giter Site home page Giter Site logo

lagrangepointtwo / positionsizing Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 9 KB

A javascript simulation demonstrating the effect of position sizing on the outcomes of a series of bets.

License: MIT License

HTML 100.00%
betting geometric-mean odds position-size position-sizing probability risk-reward simulation simulations trading

positionsizing's Introduction

PositionSizing

A javascript simulation demonstrating the effect of position sizing on the outcomes of a series of bets.

  • For this demo the odds of winning are 51%, and of losing are 49%.
  • The reward for winning is +75%, and you risk losing 50%.
  • The optimal position size given by the Kelly Criterion is f* = (0.51/0.50) - (0.49/0.75) = 0.3666667.

DISCLAIMER: Nothing in this repository, code or description is financial advice. If you place bets, trades or investments in real life, you do so at your own risk. This demonstration is NOT a solicitation to buy, trade, or bet anything, and is for educational purposes ONLY.

Why Position Sizing is Important

A lot of people mainly consider odds and the risk vs. reward when placing bets or trading assets, but fail to understand the importance of position sizing (the fraction of their allotted money/resource to place on that bet). While choosing good bets or being able to find good trading opportunities is a precursor to a successful long term strategy, it is only half the story.

An example run of three competing strategies:

image

(1) "Bet the Farm" (100% Position Size)
(2) "Smaller Bets" (15% Position Size)
(3) "Kelly Optimized" (Calculated dynamically, 36.7% in this case)

Simulation run details are logged in the console:



Long term success will largely be determined by sizing positions correctly, which ends up having a large effect since results are compounded. Even a strategy that exclusively places bets with a positive average percent gain can lose big over the long run (with avg. percent gain calculated arithmetically i.e. avg = win_prob * amount_to_win% - loss_prob * amount_to_lose% > 0). It is therefore important to think in terms of geometric gain expectency which for high risk bets can be negative if sized incorrectly even when arithmetic gain expectency is positive.

Additional Resources:

Wikipedia Entry on the Kelly Criterion: https://en.wikipedia.org/wiki/Kelly_criterion
Paper on Position Sizing Experiment: https://arxiv.org/pdf/1701.01427.pdf

positionsizing's People

Contributors

lagrangepointtwo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.