maxbeizer / lot-size-calculator

Calculate your ForEx lot size

Home Page:https://maxbeizer.github.io/lot-size-calculator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lot Size Calculator

logo 256

Created with Create React App

Development

script/setup
script/test
script/dev # or npm run

Deployment

via GitHub Pages:

script/deploy
# or
npm run deploy

docs: https://create-react-app.dev/docs/deployment#github-pages

Understanding the algorithm

Pips at risk * pip value * lots traded = amount at risk
  1. Account balance is $10,000 USD
  2. Risk is 1%
  3. Stop loss is 10 pips
  4. Convert risk to local currency. If base currency is denmoninator, then bid price. If numerator, then ask price.
    1. If account currency is denominator, then pip value is 1. So risk in dollars/pips in dollars == position . $100/ 10 pips * $1 => 10 mini lots (1 standard)
    2. EUR/CAD. USD/CAD ask is 1/1.2219.
      1. $100 / 10 pips * 1.2219 = 1.2219 standard or 12.21 mini
    3. GBP/AUD. AUD/USD bid is 1.4458 so
      1. 1AUD/1.4458USD => 1/1.4458=0.6913 => $1USD = $0.69AUD
      2. position size is therefore .6913 * 100k
      3. Standard lot is .6913. Mini lot is 6.913 etc
    4. EUR/JPY. USD/JPY ask 135.774
      1. $100 / 10 pips * 135.774 / 1000 (for yen) = 1.35 standard, 13.5 mini

Copilot version

interface Input {
  accountBalance: number;
  riskPercentage: number;
  stopLossPips: number;
  baseCurrency: string;
  quoteCurrency: string;
  bidPrice: number;
  askPrice: number;
}

interface Output {
  positionSize: number;
  pipValue: number;
  lotSize: number;
}

function calculatePositionSize(input: Input): Output {
  const {
    accountBalance,
    riskPercentage,
    stopLossPips,
    baseCurrency,
    quoteCurrency,
    bidPrice,
    askPrice,
  } = input;

  const riskAmount = accountBalance * (riskPercentage / 100);
  const pipValue =
    (riskAmount / stopLossPips) *
    (quoteCurrency === baseCurrency ? 1 : askPrice);
  const lotSize = pipValue / 10;

  return {
    positionSize: riskAmount / (stopLossPips * pipValue),
    pipValue,
    lotSize,
  };
}

About

Calculate your ForEx lot size

https://maxbeizer.github.io/lot-size-calculator/


Languages

Language:TypeScript 89.1%Language:HTML 7.5%Language:CSS 2.0%Language:Shell 0.9%Language:JavaScript 0.4%