{"openapi":"3.1.0","info":{"title":"Trading Risk API","version":"1.0.0","description":"Trading risk-management maths as an API, computed locally and deterministically — the position-sizing and money-management numbers every disciplined trader runs before a trade. The position-size endpoint is instrument-agnostic: from an account balance, the percentage of it you are willing to risk, an entry and a stop-loss it returns the position size in units (shares, contracts, lots or coins), the cash at risk and, with a target, the potential reward and the risk-reward ratio — risk 1 % of a $10,000 account on a 50-pip stop and you trade 0.2 lots, losing exactly $100 if the stop hits. The pip-value endpoint gives the forex pip value for a lot or unit size in the quote currency, with a quote-to-account rate for non-account pairs — a standard lot at a 0.0001 pip is 10 units of the quote currency. The kelly endpoint computes the Kelly criterion optimal bet fraction f* = W − (1−W)/R from a win rate and the win/loss payoff ratio (or average win and loss), plus the half-Kelly many traders prefer and the per-unit expectancy, flagging whether the edge is positive at all. Everything is computed locally and deterministically, so it is instant and private. Ideal for trading-journal, broker, prop-firm, backtesting and fintech app developers, position-sizing and risk-management tools, and trading education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 compute endpoints. This is risk and position-sizing maths; for FX rate conversion use a currency API and for option pricing a Black-Scholes API.","contact":{"name":"PremiumApi","url":"https://www.oanor.com/by/premiumapi"}},"servers":[{"url":"https://api.oanor.com/trading-api","description":"oanor gateway"}],"tags":[{"name":"Trading"},{"name":"Meta"}],"components":{"securitySchemes":{"oanorKey":{"type":"apiKey","in":"header","name":"x-oanor-key","description":"Get your key at https://www.oanor.com/developer/keys"}}},"security":[{"oanorKey":[]}],"paths":{"/v1/kelly":{"get":{"operationId":"get_v1_kelly","tags":["Trading"],"summary":"Kelly criterion & expectancy","description":"","parameters":[{"name":"win_rate","in":"query","required":true,"description":"Win rate (0–1 or %)","schema":{"type":"string"},"example":"0.6"},{"name":"win_loss_ratio","in":"query","required":false,"description":"Win/loss payoff ratio","schema":{"type":"string"},"example":"2"},{"name":"avg_win","in":"query","required":false,"description":"Average win (with avg_loss)","schema":{"type":"string"}},{"name":"avg_loss","in":"query","required":false,"description":"Average loss","schema":{"type":"string"}}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"note":"Kelly f* = W − (1−W)/R; bet that fraction of capital for fastest long-run growth. Many traders use half-Kelly for a smoother ride. Expectancy = W·R − (1−W) per unit risked.","inputs":{"win_rate":0.6,"win_loss_ratio":2},"kelly_percent":40,"positive_edge":true,"kelly_fraction":0.4,"half_kelly_percent":20,"expectancy_per_unit":0.8},"meta":{"timestamp":"2026-06-05T21:48:46.506Z","request_id":"bd378b6b-ed0c-4469-b8d9-264f63590e43"},"status":"ok","message":"Kelly criterion","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/pip-value":{"get":{"operationId":"get_v1_pip_value","tags":["Trading"],"summary":"Forex pip value","description":"","parameters":[{"name":"lots","in":"query","required":false,"description":"Lots (default 1)","schema":{"type":"string"},"example":"1"},{"name":"contract_size","in":"query","required":false,"description":"Contract size (default 100000)","schema":{"type":"string"}},{"name":"pip_size","in":"query","required":false,"description":"Pip size (default 0.0001; 0.01 for JPY)","schema":{"type":"string"}},{"name":"units","in":"query","required":false,"description":"Units (instead of lots)","schema":{"type":"string"}},{"name":"quote_to_account_rate","in":"query","required":false,"description":"Quote→account rate (default 1)","schema":{"type":"string"}}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"note":"Pip value = position units × pip size, in the quote currency. A standard lot (100,000) at a 0.0001 pip is 10 of the quote currency; multiply by the quote-to-account rate for non-account quotes.","inputs":{"lots":1,"pip_size":0.0001,"contract_size":100000,"position_units":100000,"quote_to_account_rate":1},"pip_value_quote_currency":10,"pip_value_account_currency":10},"meta":{"timestamp":"2026-06-05T21:48:46.611Z","request_id":"12e53744-20fa-4490-98eb-eafa552a41ab"},"status":"ok","message":"Pip value","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/position-size":{"get":{"operationId":"get_v1_position_size","tags":["Trading"],"summary":"Position size & risk-reward","description":"","parameters":[{"name":"account_balance","in":"query","required":true,"description":"Account balance","schema":{"type":"string"},"example":"10000"},{"name":"risk_percent","in":"query","required":true,"description":"Risk per trade (%)","schema":{"type":"string"},"example":"1"},{"name":"entry","in":"query","required":true,"description":"Entry price","schema":{"type":"string"},"example":"1.2000"},{"name":"stop_loss","in":"query","required":true,"description":"Stop-loss price","schema":{"type":"string"},"example":"1.1950"},{"name":"target","in":"query","required":false,"description":"Take-profit price","schema":{"type":"string"},"example":"1.2100"}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"note":"Units = (account × risk%) / |entry − stop|. The most you lose if the stop hits is the risk amount, whatever the instrument.","inputs":{"entry":1.2,"stop_loss":1.195,"risk_percent":1,"account_balance":10000},"target":1.21,"risk_amount":100,"risk_per_unit":0.005,"position_units":20000,"position_value":24000,"reward_per_unit":0.01,"potential_reward":200,"risk_reward_ratio":2},"meta":{"timestamp":"2026-06-05T21:48:46.717Z","request_id":"46dcc8a7-2771-4ced-9c68-27738bffa1f5"},"status":"ok","message":"Position size","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/meta":{"get":{"operationId":"get_v1_meta","tags":["Meta"],"summary":"Spec","description":"","parameters":[],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"notes":"Position sizing is instrument-agnostic (stocks, futures, crypto, forex). Risk % is a percentage (1.5 = 1.5%). For FX rate conversion use a currency API and for option pricing a Black-Scholes API.","service":"trading-api","endpoints":{"GET /v1/meta":"This document.","GET /v1/kelly":"Kelly criterion fraction and expectancy from win rate and payoff ratio.","GET /v1/pip-value":"Forex pip value for a lot/unit size in the quote (and account) currency.","GET /v1/position-size":"Position size and risk-reward from account balance, risk %, entry, stop (and target)."},"description":"Trading risk-management maths: position sizing from account risk, forex pip value, and the Kelly criterion / expectancy."},"meta":{"timestamp":"2026-06-05T21:48:46.828Z","request_id":"0214d5d0-0270-43a3-8e3e-fa7f98dbb5d1"},"status":"ok","message":"Meta","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}}},"x-oanor-pricing":[{"slug":"free","name":"Free","price_cents_month":0,"monthly_call_quota":3450,"rps_limit":2,"hard_limit":true},{"slug":"starter","name":"Starter","price_cents_month":850,"monthly_call_quota":38000,"rps_limit":6,"hard_limit":true},{"slug":"pro","name":"Pro","price_cents_month":2150,"monthly_call_quota":186000,"rps_limit":15,"hard_limit":true},{"slug":"mega","name":"Mega","price_cents_month":6300,"monthly_call_quota":1050000,"rps_limit":40,"hard_limit":true}],"x-oanor-marketplace-url":"https://www.oanor.com/api/trading-api"}