Repository Public
1{"job":{"id":"62569cd3-bdb8-426b-8fad-2dd7f735ce23","tool":"bootstrap","params":{"symbol":"AAPL","period_days":1260,"statistic":"all","risk_free":0,"method":"stationary","block_length":0,"replications":2000,"confidence":0.95,"seed":12345},"status":"done","startedAt":1795217753648,"finishedAt":1795217757602,"error":null,"progress":1,"engineVersion":"1.0.0","durationMs":3954,"projectId":null,"sessionId":null,"cancellable":false,"code":"import numpy as np, pandas as pd\nfrom arch.bootstrap import StationaryBootstrap, optimal_block_length\n# prices: DataFrame of adjusted daily closes, columns ['AAPL'], 2021-11-12 → 2026-11-20\nr = prices.pct_change().dropna().values\nprint(optimal_block_length(r[:, 0]), optimal_block_length(r[:, 0] ** 2))\nsharpe = lambda d: np.array([(d[:, 0].mean() - 0.0) / d[:, 0].std(ddof=1) * np.sqrt(252)])\nbs = StationaryBootstrap(16.86353604511001, r, seed=12345)\ndist = bs.apply(sharpe, 2000)\nprint(\"Sharpe:\", sharpe(r), \" 95% percentile interval:\", np.quantile(dist, [0.0250, 0.9750]))","result":{"success":true,"schema":"lab/1","engine":"bootstrap","engineVersion":"1.0.0","title":"AAPL — bootstrap confidence intervals","headline":"AAPL: sharpe ratio (annualized) 0.745, 95% interval -0.054 to 1.564 (stationary bootstrap, block length 16.9, 2000 replications).","summary":[{"label":"Mean return (annualized)","value":0.20940278974957457,"unit":"percent","kind":"observed","decimals":null,"note":"95% BCa interval -3.04% to 41.13%"},{"label":"Volatility (annualized)","value":0.2811355205002228,"unit":"percent","kind":"observed","decimals":null,"note":"95% BCa interval 25.13% to 32.86%"},{"label":"Sharpe ratio (annualized)","value":0.7448464334104259,"unit":"ratio","kind":"calculated","decimals":3,"note":"95% BCa interval -0.098 to 1.531"},{"label":"Sortino ratio (annualized)","value":1.1040163861228627,"unit":"ratio","kind":"calculated","decimals":3,"note":"95% BCa interval -0.164 to 2.367"},{"label":"Maximum drawdown","value":-0.33359277708592694,"unit":"percent","kind":"observed","decimals":null,"note":"95% BCa interval -52.07% to -18.77%"},{"label":"Skewness (daily returns)","value":0.39312238462208837,"unit":"ratio","kind":"observed","decimals":3,"note":"95% BCa interval -0.104 to 1.178"},{"label":"Observations","value":1260,"unit":"count","kind":"observed","note":"2021-11-15 → 2026-11-20"},{"label":"Replications","value":2000,"unit":"count","kind":"assumption"},{"label":"Block length","value":16.86353604511001,"unit":"days","kind":"calculated","decimals":1,"note":"Automatic (Patton-Politis-White): largest optimum over returns and squared returns; mean length of geometric blocks"}],"tables":[{"id":"intervals","title":"95% confidence intervals — stationary bootstrap, 2000 replications","columns":[{"key":"statistic","label":"Statistic","align":"left","type":"text"},{"key":"estimate","label":"Estimate","decimals":4,"type":"number"},{"key":"boot_mean","label":"Bootstrap mean","decimals":4,"type":"number"},{"key":"bias","label":"Bias","decimals":4,"type":"number"},{"key":"std_error","label":"Std. error","decimals":4,"type":"number"},{"key":"pct_low","label":"Percentile low","decimals":4,"type":"number"},{"key":"pct_high","label":"Percentile high","decimals":4,"type":"number"},{"key":"bca_low","label":"BCa low","decimals":4,"type":"number"},{"key":"bca_high","label":"BCa high","decimals":4,"type":"number"},{"key":"analytic_low","label":"Analytic low (i.i.d.)","decimals":4,"type":"number"},{"key":"analytic_high","label":"Analytic high (i.i.d.)","decimals":4,"type":"number"}],"rows":[{"statistic":"Mean return (annualized)","estimate":0.20940278974957457,"boot_mean":0.21102218999267347,"bias":0.0016194002430988952,"std_error":0.11234033069007832,"pct_low":-0.016220761783138322,"pct_high":0.42414492287598815,"bca_low":-0.0304209714403231,"bca_high":0.41131765687138444,"analytic_low":-0.037255957294552805,"analytic_high":0.456061536793702},{"statistic":"Volatility (annualized)","estimate":0.2811355205002228,"boot_mean":0.28147806121536256,"bias":0.000342540715139783,"std_error":0.018936516986165837,"pct_low":0.2477084977790445,"pct_high":0.3214243448479793,"bca_low":0.2512590150710152,"bca_high":0.32857505100242695,"analytic_low":0.2705714635731907,"analytic_high":0.2925643314547287},{"statistic":"Sharpe ratio (annualized)","estimate":0.7448464334104259,"boot_mean":0.7605550880251252,"bias":0.01570865461469928,"std_error":0.41756947567248487,"pct_low":-0.05359693465627866,"pct_high":1.5643695098974832,"bca_low":-0.09794084044026569,"bca_high":1.531140521248111,"analytic_low":-0.13215840640309817,"analytic_high":1.62185127322395},{"statistic":"Sortino ratio (annualized)","estimate":1.1040163861228627,"boot_mean":1.145828509698645,"bias":0.041812123575782234,"std_error":0.6513948399899662,"pct_low":-0.07542569408995853,"pct_high":2.4059955744099155,"bca_low":-0.16363337472743078,"bca_high":2.3673392398322908,"analytic_low":null,"analytic_high":null},{"statistic":"Maximum drawdown","estimate":-0.33359277708592694,"boot_mean":-0.3697029983872931,"bias":-0.03611022130136615,"std_error":0.09852322101447387,"pct_low":-0.5961215159463928,"pct_high":-0.2167475655380584,"bca_low":-0.5207121339499104,"bca_high":-0.18773387496212834,"analytic_low":null,"analytic_high":null},{"statistic":"Skewness (daily returns)","estimate":0.39312238462208837,"boot_mean":0.37330609742758286,"bias":-0.01981628719450551,"std_error":0.31649354428627474,"pct_low":-0.22998003298398217,"pct_high":0.9786049794047995,"bca_low":-0.10358047607886135,"bca_high":1.1776825012388337,"analytic_low":null,"analytic_high":null}],"note":"Returns, volatility and drawdown as fractions (0.12 = 12 %). Analytic intervals assume i.i.d. observations (Student-t for the mean, χ² under normality for volatility, Lo (2002) for Sharpe, Fisher z for correlation) and are given as a reference only."},{"id":"block_length","title":"Automatic block length","columns":[{"key":"series","label":"Series","align":"left","type":"text"},{"key":"optimal","label":"Optimal block length","decimals":2,"type":"number"}],"rows":[{"series":"AAPL, returns","optimal":1.076181140570811},{"series":"AAPL, squared returns","optimal":16.86353604511001}],"note":"Politis-White (2004) selector with the Patton-Politis-White (2009) correction, from `arch.bootstrap.optimal_block_length`. The largest value is used so that the dependence in volatility is preserved."}],"charts":[{"id":"dist_mean","title":"Bootstrap distribution — Mean return (annualized)","type":"histogram","x":{"label":"Mean return (annualized)","type":"number","unit":"percent"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[-0.17359057695972852,-0.15809591333683548,-0.14260124971394247,-0.12710658609104944,-0.1116119224681564,-0.09611725884526337,-0.08062259522237036,-0.06512793159947733,-0.049633267976584294,-0.03413860435369126,-0.01864394073079824,-0.0031492771079052184,0.012345386514987816,0.027840050137880837,0.04333471376077386,0.05882937738366689,0.07432404100655993,0.08981870462945296,0.105313368252346,0.12080803187523903,0.13630269549813204,0.15179735912102504,0.16729202274391808,0.1827866863668111,0.19828134998970415,0.21377601361259718,0.22927067723549022,0.2447653408583832,0.26026000448127623,0.27575466810416926,0.2912493317270623,0.30674399534995533,0.3222386589728483,0.33773332259574135,0.3532279862186344,0.3687226498415274,0.38421731346442045,0.3997119770873135,0.4152066407102065,0.43070130433309955,0.4461959679559926,0.46169063157888557,0.4771852952017786,0.49267995882467164,0.5081746224475647,0.5236692860704577,0.5391639496933507,0.5546586133162438,0.5701532769391368,0.5856479405620298],"y":[1,0,1,2,2,1,6,7,13,10,9,18,30,29,32,48,41,57,64,82,99,84,109,80,118,121,110,118,101,86,86,75,66,60,50,56,39,23,14,17,9,6,7,1,5,3,1,1,0,2],"style":"bar"}],"annotations":[{"x":0.20940278974957457,"text":"Sample estimate"},{"x":-0.016220761783138322,"text":"95% percentile low"},{"x":0.42414492287598815,"text":"95% percentile high"}]},{"id":"dist_volatility","title":"Bootstrap distribution — Volatility (annualized)","type":"histogram","x":{"label":"Volatility (annualized)","type":"number","unit":"percent"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[0.23220304141666365,0.23456339618609073,0.23692375095551785,0.23928410572494493,0.24164446049437205,0.24400481526379914,0.24636517003322622,0.2487255248026533,0.25108587957208045,0.25344623434150754,0.2558065891109346,0.2581669438803617,0.2605272986497888,0.26288765341921594,0.265248008188643,0.2676083629580701,0.2699687177274972,0.2723290724969243,0.27468942726635137,0.27704978203577846,0.2794101368052056,0.2817704915746327,0.2841308463440598,0.28649120111348686,0.288851555882914,0.2912119106523411,0.2935722654217682,0.29593262019119526,0.29829297496062235,0.30065332973004943,0.3030136844994765,0.3053740392689036,0.30773439403833075,0.31009474880775784,0.3124551035771849,0.31481545834661206,0.31717581311603915,0.31953616788546624,0.3218965226548933,0.3242568774243204,0.3266172321937475,0.3289775869631746,0.33133794173260167,0.3336982965020288,0.3360586512714559,0.338419006040883,0.34077936081031013,0.3431397155797372,0.3455000703491643,0.3478604251185914],"y":[1,2,3,3,10,9,21,24,34,48,54,62,48,64,65,79,75,87,103,90,105,97,111,87,94,85,66,62,58,53,58,44,36,32,25,15,26,11,13,12,7,6,8,4,0,1,0,1,0,1],"style":"bar"}],"annotations":[{"x":0.2811355205002228,"text":"Sample estimate"},{"x":0.2477084977790445,"text":"95% percentile low"},{"x":0.3214243448479793,"text":"95% percentile high"}]},{"id":"dist_sharpe","title":"Bootstrap distribution — Sharpe ratio (annualized)","type":"histogram","x":{"label":"Sharpe ratio (annualized)","type":"number","unit":"ratio"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[-0.5580290225012718,-0.500355492630596,-0.4426819627599202,-0.3850084328892444,-0.32733490301856866,-0.26966137314789285,-0.21198784327721706,-0.15431431340654128,-0.09664078353586553,-0.03896725366518977,0.01870627620548604,0.07637980607616185,0.1340533359468376,0.19172686581751341,0.24940039568818922,0.307073925558865,0.36474745542954073,0.4224209853002165,0.4800945151708923,0.537768045041568,0.5954415749122438,0.6531151047829197,0.7107886346535954,0.7684621645242712,0.826135694394947,0.8838092242656228,0.9414827541362986,0.9991562840069744,1.0568298138776502,1.1145033437483258,1.1721768736190017,1.2298504034896776,1.2875239333603532,1.345197463231029,1.402870993101705,1.4605445229723806,1.5182180528430564,1.5758915827137323,1.633565112584408,1.6912386424550836,1.7489121723257595,1.8065857021964353,1.864259232067111,1.9219327619377868,1.9796062918084627,2.0372798216791383,2.0949533515498144,2.15262688142049,2.2103004112911657,2.2679739411618414],"y":[2,0,1,2,2,5,8,17,11,14,25,34,37,42,39,67,59,86,103,85,102,97,132,116,107,113,85,97,74,76,66,53,64,37,31,30,27,14,8,6,4,9,3,5,0,1,0,0,1,3],"style":"bar"}],"annotations":[{"x":0.7448464334104259,"text":"Sample estimate"},{"x":-0.05359693465627866,"text":"95% percentile low"},{"x":1.5643695098974832,"text":"95% percentile high"}]},{"id":"dist_sortino","title":"Bootstrap distribution — Sortino ratio (annualized)","type":"histogram","x":{"label":"Sortino ratio (annualized)","type":"number","unit":"ratio"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[-0.7744999325133668,-0.6822235356025734,-0.58994713869178,-0.49767074178098647,-0.405394344870193,-0.3131179479593995,-0.2208415510486061,-0.1285651541378126,-0.03628875722701913,0.05598763968377435,0.14826403659456783,0.24054043350536125,0.33281683041615473,0.4250932273269482,0.5173696242377417,0.6096460211485352,0.7019224180593285,0.794198814970122,0.8864752118809155,0.978751608791709,1.0710280057025026,1.163304402613296,1.2555807995240895,1.3478571964348829,1.4401335933456763,1.5324099902564698,1.6246863871672632,1.7169627840780566,1.8092391809888502,1.9015155778996438,1.9937919748104371,2.0860683717212307,2.178344768632024,2.2706211655428175,2.362897562453611,2.455173959364404,2.5474503562751982,2.6397267531859914,2.7320031500967845,2.8242795470075786,2.9165559439183717,3.008832340829165,3.101108737739959,3.193385134650752,3.2856615315615456,3.377937928472339,3.470214325383133,3.562490722293926,3.6547671192047195,3.747043516115513],"y":[2,0,2,2,4,10,17,13,15,38,32,47,48,67,61,97,101,101,102,105,122,123,121,107,84,91,73,72,58,57,53,38,31,25,32,9,6,8,3,6,5,4,3,1,0,0,1,1,0,2],"style":"bar"}],"annotations":[{"x":1.1040163861228627,"text":"Sample estimate"},{"x":-0.07542569408995853,"text":"95% percentile low"},{"x":2.4059955744099155,"text":"95% percentile high"}]},{"id":"dist_max_drawdown","title":"Bootstrap distribution — Maximum drawdown","type":"histogram","x":{"label":"Maximum drawdown","type":"number","unit":"percent"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[-0.7551624499001259,-0.743121239716809,-0.731080029533492,-0.719038819350175,-0.7069976091668579,-0.694956398983541,-0.6829151888002241,-0.670873978616907,-0.65883276843359,-0.646791558250273,-0.6347503480669561,-0.622709137883639,-0.610667927700322,-0.598626717517005,-0.5865855073336881,-0.574544297150371,-0.562503086967054,-0.550461876783737,-0.5384206666004201,-0.526379456417103,-0.514338246233786,-0.502297036050469,-0.490255825867152,-0.47821461568383505,-0.466173405500518,-0.45413219531720106,-0.442090985133884,-0.43004977495056707,-0.41800856476725,-0.40596735458393307,-0.393926144400616,-0.3818849342172991,-0.369843724033982,-0.3578025138506651,-0.34576130366734803,-0.3337200934840311,-0.32167888330071404,-0.3096376731173971,-0.29759646293408004,-0.2855552527507631,-0.27351404256744605,-0.26147283238412905,-0.24943162220081205,-0.23739041201749506,-0.22534920183417806,-0.21330799165086106,-0.20126678146754406,-0.18922557128422707,-0.17718436110091007,-0.16514315091759307],"y":[1,2,0,2,3,2,3,4,3,5,5,6,10,11,11,20,20,12,16,19,24,31,41,52,39,48,68,65,73,72,81,84,93,94,118,109,112,103,111,78,78,70,35,58,50,24,14,13,5,2],"style":"bar"}],"annotations":[{"x":-0.33359277708592694,"text":"Sample estimate"},{"x":-0.5961215159463928,"text":"95% percentile low"},{"x":-0.2167475655380584,"text":"95% percentile high"}]},{"id":"dist_skewness","title":"Bootstrap distribution — Skewness (daily returns)","type":"histogram","x":{"label":"Skewness (daily returns)","type":"number","unit":"ratio"},"y":{"label":"Replications","unit":"count"},"series":[{"name":"Bootstrap replications","kind":"calculated","x":[-0.5083883697637035,-0.4688960752692402,-0.429403780774777,-0.38991148628031375,-0.3504191917858505,-0.3109268972913872,-0.271434602796924,-0.23194230830246076,-0.19245001380799753,-0.1529577193135343,-0.11346542481907107,-0.07397313032460781,-0.03448083583014455,0.00501145866431868,0.04450375315878191,0.08399604765324514,0.12348834214770837,0.1629806366421716,0.20247293113663484,0.24196522563109807,0.2814575201255613,0.32094981462002453,0.36044210911448776,0.39993440360895105,0.43942669810341434,0.47891899259787757,0.5184112870923407,0.557903581586804,0.5973958760812672,0.6368881705757304,0.6763804650701937,0.7158727595646569,0.7553650540591202,0.7948573485535835,0.8343496430480467,0.8738419375425099,0.9133342320369732,0.9528265265314364,0.9923188210258996,1.0318111155203629,1.071303410014826,1.1107957045092893,1.1502879990037527,1.1897802934982158,1.229272587992679,1.2687648824871423,1.3082571769816056,1.3477494714760687,1.387241765970532,1.4267340604649954],"y":[1,4,4,2,12,7,9,17,17,34,39,39,53,42,61,61,76,80,95,85,102,87,91,95,104,83,83,81,85,72,61,51,57,44,35,30,22,24,12,14,8,3,7,5,0,1,1,2,1,1],"style":"bar"}],"annotations":[{"x":0.39312238462208837,"text":"Sample estimate"},{"x":-0.22998003298398217,"text":"95% percentile low"},{"x":0.9786049794047995,"text":"95% percentile high"}]}],"diagnostics":[{"name":"Ljung-Box Q(10) on AAPL returns","statistic":10.571278872961559,"pvalue":0.391879056043849,"conclusion":"No serial correlation in returns.","passed":true,"df":10},{"name":"Ljung-Box Q(10) on AAPL squared returns","statistic":141.35315291605767,"pvalue":2.2251899777259366e-25,"conclusion":"Volatility clusters: observations are not independent.","passed":false,"df":10},{"name":"Mean return (annualized) different from zero","statistic":0.20940278974957457,"pvalue":0.063,"conclusion":"Zero is inside the 95% percentile interval: not distinguishable from zero.","passed":null},{"name":"Sharpe ratio (annualized) different from zero","statistic":0.7448464334104259,"pvalue":0.063,"conclusion":"Zero is inside the 95% percentile interval: not distinguishable from zero.","passed":null},{"name":"Sortino ratio (annualized) different from zero","statistic":1.1040163861228627,"pvalue":0.063,"conclusion":"Zero is inside the 95% percentile interval: not distinguishable from zero.","passed":null},{"name":"Skewness (daily returns) different from zero","statistic":0.39312238462208837,"pvalue":0.259,"conclusion":"Zero is inside the 95% percentile interval: not distinguishable from zero.","passed":null}],"assumptions":["Maximum drawdown is path-dependent: a bootstrap path keeps the order of returns only inside a block, so its distribution describes what drawdowns this return process can produce, not uncertainty about the one historical path.","Daily simple returns from adjusted closes; annualization with 252 trading days a year (mean × 252, volatility × √252); risk-free rate 0.00% a year.","BCa intervals use the bias correction from the bootstrap distribution and an acceleration from a delete-group jackknife (delete-one up to 400 observations); with block resampling this is a BCa-style approximation."],"warnings":[],"methodology":"**Principle.** From the $n$ observed returns, $B$ pseudo-samples of length $n$ are drawn and the statistic $\\hat\\theta^*_b$ is recomputed on each; the spread of $\\hat\\theta^*$ estimates the sampling uncertainty of $\\hat\\theta$.\n\n**Resampling.** *i.i.d.*: observations drawn independently with replacement. *Moving block*: blocks of $\\ell$ consecutive observations. *Circular block*: the same with the sample wrapped around. *Stationary* (Politis-Romano 1994): blocks of random geometric length with mean $\\ell$, which keeps the pseudo-series stationary. Blocks preserve serial dependence (volatility clustering) up to lag $\\ell$. For two series the rows are resampled jointly, which preserves their cross-dependence.\n\n**Block length.** $\\ell$ is chosen by the Politis-White (2004) rule with the Patton-Politis-White (2009) correction, $\\ell^{opt}\\propto n^{1/3}$, computed for returns and squared returns; the largest value is used.\n\n**Intervals.** Percentile: $[\\hat\\theta^*_{(\\alpha/2)},\\hat\\theta^*_{(1-\\alpha/2)}]$. BCa: the quantile levels become $\\Phi\\!\\left(z_0+\\dfrac{z_0+z_{\\alpha}}{1-a(z_0+z_{\\alpha})}\\right)$ with bias correction $z_0=\\Phi^{-1}(\\#\\{\\hat\\theta^*<\\hat\\theta\\}/B)$ and acceleration $a=\\dfrac{\\sum_i(\\bar\\theta_{(\\cdot)}-\\hat\\theta_{(i)})^3}{6[\\sum_i(\\bar\\theta_{(\\cdot)}-\\hat\\theta_{(i)})^2]^{3/2}}$ from the jackknife.\n\n**Statistics** ($\\bar r$, $s$ daily mean and standard deviation, $A$ periods per year, $r_f$ daily risk-free rate): mean $A\\bar r$; volatility $s\\sqrt A$; Sharpe $\\frac{\\bar r-r_f}{s}\\sqrt A$; Sortino $\\frac{\\bar r-r_f}{\\sqrt{\\overline{\\min(r-r_f,0)^2}}}\\sqrt A$; maximum drawdown $\\min_t(W_t/\\max_{s\\le t}W_s-1)$; beta $\\widehat{\\text{cov}}(r,r_b)/\\widehat{\\text{var}}(r_b)$.\n\n**Zero test.** The reported p-value is $2\\min(P^*(\\hat\\theta^*\\le0),P^*(\\hat\\theta^*\\ge0))$, the inversion of the percentile interval.","provenance":{"data":[{"symbol":"AAPL","provider":"FMP","retrievedAt":"2026-11-20T23:35:56+00:00","start":"2021-11-10","end":"2026-11-20","observations":1263,"frequency":"1d","adjusted":"split_div","currency":null}],"spec":{"symbol":"AAPL","benchmark":null,"period_days":1260,"start":null,"end":null,"statistic":"all","risk_free":0,"method":"stationary","block_length":0,"replications":2000,"confidence":0.95,"seed":12345,"statistics":["mean","volatility","sharpe","sortino","max_drawdown","skewness"],"block_length_used":16.86353604511001,"periods_per_year":252},"seed":12345,"software":{"python":"3.14.4","numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","statsmodels":"0.14.6","arch":"8.0.0","scikit-learn":"1.8.0"},"computedAt":"2026-11-20T23:35:57+00:00","durationMs":2872,"reproduce":"import numpy as np, pandas as pd\nfrom arch.bootstrap import StationaryBootstrap, optimal_block_length\n# prices: DataFrame of adjusted daily closes, columns ['AAPL'], 2021-11-12 → 2026-11-20\nr = prices.pct_change().dropna().values\nprint(optimal_block_length(r[:, 0]), optimal_block_length(r[:, 0] ** 2))\nsharpe = lambda d: np.array([(d[:, 0].mean() - 0.0) / d[:, 0].std(ddof=1) * np.sqrt(252)])\nbs = StationaryBootstrap(16.86353604511001, r, seed=12345)\ndist = bs.apply(sharpe, 2000)\nprint(\"Sharpe:\", sharpe(r), \" 95% percentile interval:\", np.quantile(dist, [0.0250, 0.9750]))"}}}}2