{"uid":"cap_QTc7ZqmWK6HVbNE19-Fj7","slug":"api-quantoracle-dev-71b5ac03","name":"QuantOracle Portfolio Optimizer","description":"QuantOracle: portfolio/optimize","url":"https://api.quantoracle.dev/v1/portfolio/optimize","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"mode":{"enum":["max_sharpe","min_vol","risk_parity"],"type":"string","title":"Mode","default":"max_sharpe","description":"Optimization objective"},"returns":{"type":"object","title":"Returns","description":"Named return series per asset, e.g. {\"AAPL\": [...], \"MSFT\": [...]}","additionalProperties":{"type":"array","items":{"type":"number"}}},"risk_free_rate":{"type":"number","title":"Risk Free Rate","default":0.05,"description":"Annual risk-free rate"}}},"responseSchema":null,"example":{"request":{"input":{"body":{"mode":"max_sharpe","returns":{"AAPL":[0.01,-0.005,0.02,0.015,-0.01,0.008,0.012,-0.003,0.018,0.005],"MSFT":[0.008,0.003,-0.01,0.012,0.006,-0.002,0.014,0.009,-0.005,0.011],"TSLA":[0.03,-0.02,0.015,0.025,-0.015,0.022,0.018,-0.008,0.028,0.012]},"risk_free_rate":0.05},"type":"http","method":"POST","bodyType":"json"}},"response":{"ms":42.8,"vol":0.0819,"mode":"max_sharpe","_meta":{"url":"https://quantoracle.dev","docs":"https://api.quantoracle.dev/docs","powered_by":"QuantOracle"},"return":1.4393,"sharpe":16.9612,"weights":{"AAPL":0.4632,"MSFT":0.5368,"TSLA":0}}},"exampleRequest":{"mode":"max_sharpe","returns":{"AAPL":[0.01,-0.005,0.02,0.015,-0.01,0.008,0.012,-0.003,0.018,0.005],"MSFT":[0.008,0.003,-0.01,0.012,0.006,-0.002,0.014,0.009,-0.005,0.011],"TSLA":[0.03,-0.02,0.015,0.025,-0.015,0.022,0.018,-0.008,0.028,0.012]},"risk_free_rate":0.05},"tags":["x402"],"displayCostAmount":"0.015","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.015/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_hL__WzaWd8IKzjRlHBfl4","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.015","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Optimizes a multi-asset portfolio's weight allocation using mean-variance analysis (e.g. max Sharpe ratio) given historical return series and a risk-free rate","exampleAgentPrompt":"Optimize the weights for my portfolio of AAPL, MSFT, and TSLA to maximize the Sharpe ratio — here are 10 periods of returns for each: AAPL [0.01, -0.005, 0.02, 0.015, -0.01, 0.008, 0.012, -0.003, 0.018, 0.005], MSFT [0.008, 0.003, -0.01, 0.012, 0.006, -0.002, 0.014, 0.009, -0.005, 0.011], TSLA [0.03, -0.02, 0.015, 0.025, -0.015, 0.022, 0.018, -0.008, 0.028, 0.012], and use a risk-free rate of 5%.","exampleUseCases":null,"resultDescription":"Returns the optimal portfolio weight for each asset (summing to 1), the annualized expected return, portfolio volatility, Sharpe ratio, the optimization mode used, and computation time in milliseconds. Assets with zero weight are excluded from the optimal allocation.","failureModes":["Insufficient return data (fewer periods than assets) leading to singular covariance matrix","Mismatched return series lengths across assets","Invalid or unsupported optimization mode","Risk-free rate provided as decimal vs percentage mismatch","All-zero or constant return series causing division errors","Network or payment (x402) failure returning 402 or 5xx"],"whenToPreferThis":"Use this endpoint when you need quantitative, mean-variance portfolio optimization (e.g. max Sharpe or min volatility) given raw historical return series. Prefer this over simpler equal-weight or rule-based rebalancing endpoints when you have asset return history and want mathematically optimal weight allocation with Sharpe ratio output.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T12:52:13.177Z","isFirstParty":false}