# Investing Math Position sizing, drawdowns, Sharpe, DCA, dividends, FIRE and option payoffs for trading bots and planners. ## How to pay Machine-payable over x402. USDC on: Base (eip155:8453), Solana (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp), Polygon (eip155:137), Arbitrum One (eip155:42161). No accounts. No API keys. No signup. The paying wallet is the account. ## Machine-readable - OpenAPI: https://invest-math.x402tookit.com/openapi.json - x402 manifest: https://invest-math.x402tookit.com/.well-known/x402 - Catalog (free): https://invest-math.x402tookit.com/catalog - Health (free): https://invest-math.x402tookit.com/health - Uptime (free): https://invest-math.x402tookit.com/uptime ## Endpoints (12) ### GET /dca-vs-lump — $0.02 Compare equal periodic buys (dollar-cost averaging) with one lump sum on the first date, over a list of prices. Params: prices: string, perBuy: number Example: https://invest-math.x402tookit.com/dca-vs-lump?prices=100%2C90%2C80%2C95%2C110%2C105&perBuy=1000 ### GET /dividend-math — $0.02 Dividend yield, yearly income, and yield on cost and total dividends after years of dividend growth. Params: price: number, annualDividend: number, shares?: number, growthPct?: number, years?: integer Example: https://invest-math.x402tookit.com/dividend-math?price=50&annualDividend=2&shares=100&growthPct=5&years=10 ### GET /drawdown-recovery — $0.02 Gain needed to recover a percentage loss, or the maximum drawdown and recovery gain from a list of period returns. Params: lossPct?: number, returnsPct?: string Example: https://invest-math.x402tookit.com/drawdown-recovery?lossPct=50 ### GET /expected-move — $0.02 The price range implied by volatility over a number of days: one and two standard deviations, from implied or historical vol. Params: price: number, volPct: number, days: number Example: https://invest-math.x402tookit.com/expected-move?price=100&volPct=30&days=30 ### GET /fire-number — $0.02 Financial-independence number from yearly spending and a withdrawal rate, and years to reach it from savings and contributions. Params: annualSpending: number, withdrawalRatePct?: number, currentSavings?: number, yearlyContribution?: number, realReturnPct?: number Example: https://invest-math.x402tookit.com/fire-number?annualSpending=40000&withdrawalRatePct=4¤tSavings=100000&yearlyContribution=20000&realReturnPct=5 ### GET /inflation-adjust — $0.02 What an amount costs or is worth after years of steady inflation, plus the real return after inflation for a nominal return. Params: amount: number, inflationPct: number, years: number, nominalReturnPct?: number Example: https://invest-math.x402tookit.com/inflation-adjust?amount=100&inflationPct=3&years=10&nominalReturnPct=7 ### GET /margin-call — $0.02 Margin call price for shares bought on margin: your cash, the loan, the maintenance requirement and the trigger price. Params: shares: number, price: number, initialMarginPct?: number, maintenancePct?: number Example: https://invest-math.x402tookit.com/margin-call?shares=100&price=50&initialMarginPct=50&maintenancePct=25 ### GET /option-payoff — $0.02 Expiry profit and loss for a long or short call or put: break-even, maximum gain and loss, and a payoff table. Params: type: string, side: string, strike: number, premium: number, contracts?: integer, spot?: number Example: https://invest-math.x402tookit.com/option-payoff?type=call&side=long&strike=100&premium=5&contracts=1&spot=112 ### GET /portfolio-risk — $0.02 Return and volatility of a two-asset mix from each asset's return, volatility and correlation, plus the lowest-risk weight. Params: weightA: number, returnAPct: number, returnBPct: number, volAPct: number, volBPct: number, correlation: number Example: https://invest-math.x402tookit.com/portfolio-risk?weightA=60&returnAPct=8&returnBPct=4&volAPct=16&volBPct=6&correlation=0.2 ### GET /position-size — $0.02 Position size from account size, risk percent, entry and stop: units to buy, dollars at risk, cost and R-multiple targets. Params: account: number, riskPct: number, entry: number, stop: number, feePct?: number Example: https://invest-math.x402tookit.com/position-size?account=10000&riskPct=1&entry=50&stop=48 ### GET /return-stats — $0.02 Performance stats from period returns: average, volatility, Sharpe, Sortino, compound growth and max drawdown. Params: returnsPct: string, periodsPerYear?: integer, riskFreePct?: number Example: https://invest-math.x402tookit.com/return-stats?returnsPct=2%2C-1%2C3%2C1.5%2C-2%2C4%2C0.5%2C-0.5%2C2.5%2C1%2C-1.5%2C3&periodsPerYear=12&riskFreePct=2 ### GET /risk-reward — $0.02 Reward-to-risk ratio from entry, stop and target, the win rate needed to break even, and expectancy at your win rate. Params: entry: number, stop: number, target: number, winRatePct?: number Example: https://invest-math.x402tookit.com/risk-reward?entry=100&stop=95&target=115&winRatePct=40 ## Terms Educational arithmetic from standard formulas. It is not investment, tax or legal advice, a recommendation to buy or sell anything, or a prediction. Results depend entirely on the numbers you supply; past returns do not guarantee future results.