{"openapi":"3.1.0","info":{"title":"RiskReward Free Calculation API","version":"1.0.0","description":"Stateless trading calculations. No API key, account access, market data, trade execution or data persistence by the calculation service. Inputs must be supplied by the user. Hosting logs may contain request metadata."},"servers":[{"url":"https://riskreward.pro"}],"paths":{"/api/v1/position-size":{"post":{"operationId":"calculate_position_size","summary":"Fee-aware position size","description":"Calculate position quantity and notional for a linear crypto futures trade from user-specified account balance, risk percentage, entry and stop. Includes separate entry/stop fees and optional target profit and net R. Direction is derived. Use when asked how much to buy or sell for a specified risk budget. Ask for missing prices or risk preference; do not invent them. Does not calculate liquidation, leverage, inverse contracts, exchange lot rounding, signals, or execute orders.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"instrumentType":{"description":"Linear quote-margined instruments only. Inverse contracts and liquidation are unsupported.","type":"string","const":"linear"},"quoteCurrency":{"description":"Currency shared by all monetary inputs. Defaults to USD; no currency conversion is performed.","type":"string","pattern":"^[A-Z][A-Z0-9]{1,9}$"},"entryPrice":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Planned entry price in quote currency per base unit."},"stopPrice":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Planned stop price. Direction is derived from entry and stop."},"fees":{"description":"User-supplied rates. Omission explicitly assumes zero fees; no exchange rate lookup is performed.","type":"object","properties":{"entryPercent":{"type":"number","minimum":0,"exclusiveMaximum":100,"description":"Entry fee percent, e.g. 0.05 means 0.05%, not 5%."},"stopPercent":{"type":"number","minimum":0,"exclusiveMaximum":100,"description":"Stop exit fee percent, e.g. 0.05."},"targetPercent":{"description":"Target exit fee percent; defaults to stopPercent.","type":"number","minimum":0,"exclusiveMaximum":100}},"required":["entryPercent","stopPercent"],"additionalProperties":false},"accountBalance":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Account balance in the same quote currency as prices."},"riskPercent":{"type":"number","exclusiveMinimum":0,"maximum":100,"description":"User-chosen account risk percentage, e.g. 1 means 1%. Never infer a risk preference."},"targetPrice":{"description":"Optional profit target, opposite the stop relative to entry.","type":"number","exclusiveMinimum":0,"maximum":1000000000000}},"required":["entryPrice","stopPrice","accountBalance","riskPercent"],"additionalProperties":false},"example":{"accountBalance":10000,"riskPercent":1,"entryPrice":100000,"stopPrice":95000,"targetPrice":110000,"quoteCurrency":"USDT","fees":{"entryPercent":0.02,"stopPercent":0.05,"targetPercent":0.02}}}}},"responses":{"200":{"description":"Calculation with normalized inputs, explicit assumptions, units and reproducible link.","content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"tool":{"type":"string","enum":["calculate_position_size","calculate_net_risk_reward","analyze_trade_performance"]},"calculationVersion":{"type":"string","const":"1.0.0"},"inputs":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"metrics":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"object","properties":{"value":{"type":["number","null"]},"unit":{"type":"string"},"label":{"type":"string"}},"required":["value","unit","label"],"additionalProperties":false}},"assumptions":{"type":"array","items":{"type":"string"}},"warnings":{"type":"array","items":{"type":"string"}},"formulas":{"type":"array","items":{"type":"string"}},"documentationUrl":{"type":"string","format":"uri"},"reproduceUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}]}},"required":["tool","calculationVersion","inputs","metrics","assumptions","warnings","formulas","documentationUrl","reproduceUrl"],"additionalProperties":false}}}},"400":{"description":"Malformed JSON."},"403":{"description":"Invalid Host or Origin."},"413":{"description":"Body exceeds 64 KiB."},"415":{"description":"Content-Type must be application/json."},"422":{"description":"Missing/invalid inputs or unsupported scenario. Correct input before retrying."},"429":{"description":"Request rate exceeded. Respect Retry-After."}}}},"/api/v1/risk-reward":{"post":{"operationId":"calculate_net_risk_reward","summary":"Net risk/reward after fees","description":"Compare gross and fee-adjusted reward-to-risk, loss and profit per unit, and breakeven win rate for a linear trade with known entry, stop and target. Accepts distinct entry/stop/target fee percentages. Use for questions about a planned R ratio or how fees change it. Direction is derived from entry and stop. Does not fetch venue fees or predict execution, liquidation, or trade outcomes.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"instrumentType":{"description":"Linear quote-margined instruments only. Inverse contracts and liquidation are unsupported.","type":"string","const":"linear"},"quoteCurrency":{"description":"Currency shared by all monetary inputs. Defaults to USD; no currency conversion is performed.","type":"string","pattern":"^[A-Z][A-Z0-9]{1,9}$"},"entryPrice":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Planned entry price in quote currency per base unit."},"stopPrice":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Planned stop price. Direction is derived from entry and stop."},"fees":{"description":"User-supplied rates. Omission explicitly assumes zero fees; no exchange rate lookup is performed.","type":"object","properties":{"entryPercent":{"type":"number","minimum":0,"exclusiveMaximum":100,"description":"Entry fee percent, e.g. 0.05 means 0.05%, not 5%."},"stopPercent":{"type":"number","minimum":0,"exclusiveMaximum":100,"description":"Stop exit fee percent, e.g. 0.05."},"targetPercent":{"description":"Target exit fee percent; defaults to stopPercent.","type":"number","minimum":0,"exclusiveMaximum":100}},"required":["entryPercent","stopPercent"],"additionalProperties":false},"targetPrice":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Profit target price, opposite the stop relative to entry."}},"required":["entryPrice","stopPrice","targetPrice"],"additionalProperties":false},"example":{"entryPrice":100,"stopPrice":95,"targetPrice":110,"quoteCurrency":"USD","fees":{"entryPercent":0.02,"stopPercent":0.05,"targetPercent":0.02}}}}},"responses":{"200":{"description":"Calculation with normalized inputs, explicit assumptions, units and reproducible link.","content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"tool":{"type":"string","enum":["calculate_position_size","calculate_net_risk_reward","analyze_trade_performance"]},"calculationVersion":{"type":"string","const":"1.0.0"},"inputs":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"metrics":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"object","properties":{"value":{"type":["number","null"]},"unit":{"type":"string"},"label":{"type":"string"}},"required":["value","unit","label"],"additionalProperties":false}},"assumptions":{"type":"array","items":{"type":"string"}},"warnings":{"type":"array","items":{"type":"string"}},"formulas":{"type":"array","items":{"type":"string"}},"documentationUrl":{"type":"string","format":"uri"},"reproduceUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}]}},"required":["tool","calculationVersion","inputs","metrics","assumptions","warnings","formulas","documentationUrl","reproduceUrl"],"additionalProperties":false}}}},"400":{"description":"Malformed JSON."},"403":{"description":"Invalid Host or Origin."},"413":{"description":"Body exceeds 64 KiB."},"415":{"description":"Content-Type must be application/json."},"422":{"description":"Missing/invalid inputs or unsupported scenario. Correct input before retrying."},"429":{"description":"Request rate exceeded. Respect Retry-After."}}}},"/api/v1/performance":{"post":{"operationId":"analyze_trade_performance","summary":"Realized trading performance","description":"Analyze up to 500 chronological closed trades supplied by the user, each with net P&L after costs and original risk. Returns win rate, profit factor, expectancy in currency and R, total net R, and optional closed-trade equity drawdown when initial equity is supplied. Use for reviewing an existing trade sample. No account access, deposits, intratrade drawdown, forecasts, signals, or new risk recommendations.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"quoteCurrency":{"description":"Currency shared by all monetary inputs. Defaults to USD; no currency conversion is performed.","type":"string","pattern":"^[A-Z][A-Z0-9]{1,9}$"},"initialEquity":{"description":"Starting equity before the ordered trades. Required only for equity drawdown metrics. No deposits or withdrawals are modeled.","type":"number","exclusiveMinimum":0,"maximum":1000000000000},"trades":{"minItems":1,"maxItems":500,"type":"array","items":{"type":"object","properties":{"netPnl":{"type":"number","minimum":-1000000000000,"maximum":1000000000000,"description":"Realized P&L after all fees and costs. Positive is profit; negative is loss."},"initialRisk":{"type":"number","exclusiveMinimum":0,"maximum":1000000000000,"description":"Original planned risk amount, including planned fees if that is your convention. Do not replace it with a later stop risk."}},"required":["netPnl","initialRisk"],"additionalProperties":false},"description":"Closed trades ordered chronologically, all using the same currency and risk convention. Maximum 500."}},"required":["trades"],"additionalProperties":false},"example":{"quoteCurrency":"USD","initialEquity":10000,"trades":[{"netPnl":150,"initialRisk":100},{"netPnl":-100,"initialRisk":100},{"netPnl":50,"initialRisk":50}]}}}},"responses":{"200":{"description":"Calculation with normalized inputs, explicit assumptions, units and reproducible link.","content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"tool":{"type":"string","enum":["calculate_position_size","calculate_net_risk_reward","analyze_trade_performance"]},"calculationVersion":{"type":"string","const":"1.0.0"},"inputs":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"metrics":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"object","properties":{"value":{"type":["number","null"]},"unit":{"type":"string"},"label":{"type":"string"}},"required":["value","unit","label"],"additionalProperties":false}},"assumptions":{"type":"array","items":{"type":"string"}},"warnings":{"type":"array","items":{"type":"string"}},"formulas":{"type":"array","items":{"type":"string"}},"documentationUrl":{"type":"string","format":"uri"},"reproduceUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}]}},"required":["tool","calculationVersion","inputs","metrics","assumptions","warnings","formulas","documentationUrl","reproduceUrl"],"additionalProperties":false}}}},"400":{"description":"Malformed JSON."},"403":{"description":"Invalid Host or Origin."},"413":{"description":"Body exceeds 64 KiB."},"415":{"description":"Content-Type must be application/json."},"422":{"description":"Missing/invalid inputs or unsupported scenario. Correct input before retrying."},"429":{"description":"Request rate exceeded. Respect Retry-After."}}}}}}