Skip to main content
aifinhub

Worked example

Running the shipped efficient-frontier-builder engine on the input below produces exactly this output. Continuous integration recomputes it against the engine bundle on every build, so these numbers cannot drift from the code.

Input

{
  "tool": "efficient-frontier-builder",
  "name": "",
  "returns": [
    0.01,
    0.02,
    -0.005,
    0.015,
    -0.01
  ],
  "risk_free_annual": 0.04,
  "steps": 60,
  "assets": [
    {
      "name": "US Equities",
      "returns": [
        -0.026084,
        -0.009339,
        0.022423,
        0.024265,
        -0.00407,
        -0.032333,
        -0.00286,
        -0.013928,
        0.011828,
        0.020775,
        0.011517,
        0.006625,
        0.003477,
        0.00601,
        -0.008305,
        -0.01288,
        -0.013881,
        0.015359,
        0.011678,
        -0.016119,
        -0.003055,
        0.010377,
        -0.010538,
        -0.022867,
        0.001126,
        0.004041,
        -0.019115,
        -0.020235,
        0.016568,
        -0.005748,
        -0.011775,
        0.032105,
        0.002526,
        -0.000716,
        0.021207,
        0.005723,
        -0.002615,
        0.014075,
        0.017308,
        0.012199,
        0.014812,
        -0.024036,
        -0.007398,
        -0.009666,
        0.034898,
        -0.00267,
        -0.008985,
        0.013844,
        0.006004,
        -0.012636,
        0.00792,
        -0.001344,
        -0.033702,
        0.010719,
        -0.009275,
        -0.002554,
        -0.001274,
        -0.004542,
        0.009619,
        0.003683,
        0.00918,
        0.008551,
        0.003124,
        -0.04027,
        -0.004669,
        0.022377,
        0.027628,
        0.008361,
        0.000285,
        -0.010508,
        0.010258,
        -0.003251,
        0.015045,
        -0.007165,
        -0.004979,
        0.020983,
        0.008768,
        0.012502,
        0.000001,
        0.020556,
        -0.021939,
        0.018329,
        -0.001071,
        -0.004927,
        0.005116,
        -0.019207,
        -0.01628,
        -0.016438,
        -0.013193,
        0.011414,
        0.005628,
        -0.02627,
        -0.030247,
        0.015763,
        -0.006258,
        0.023799
      ]
    },
    {
      "name": "Intl Equities",
      "returns": [
        -0.01789,
        -0.016342,
        0.011449,
        0.013527,
        0.002128,
        -0.000148,
        -0.003973,
        -0.005458,
        0.004932,
        0.012879,
        0.00009,
        -0.004105,
        0.004944,
        0.005493,
        0.012637,
        0.016019,
        -0.011988,
        0.012194,
        0.008298,
        -0.00734,
        -0.002411,
        -0.01554,
        -0.003597,
        -0.026939,
        0.014074,
        0.001976,
        -0.001698,
        0.000053,
        -0.002408,
        0.015902,
        -0.007393,
        0.009357,
        -0.004008,
        0.001894,
        0.013792,
        -0.000589,
        0.00913,
        0.007222,
        0.003309,
        0.016436,
        0.006723,
        -0.009458,
        -0.000424,
        -0.036102,
        0.020203,
        -0.001423,
        0.006391,
        0.0019,
        -0.011855,
        -0.008596,
        -0.000051,
        -0.020171,
        -0.002348,
        0.008743,
        0.002821,
        0.013084,
        0.024959,
        0.005673,
        -0.01992,
        0.01727,
        0.007925,
        0.025043,
        0.019246,
        -0.018409,
        0.007818,
        -0.012283,
        0.005164,
        -0.000647,
        0.000651,
        0.016975,
        -0.016459,
        0.010047,
        0.011959,
        0.008598,
        0.008194,
        -0.020397,
        0.016703,
        0.000529,
        0.008447,
        0.008478,
        -0.025,
        0.011464,
        0.007115,
        -0.003013,
        -0.003825,
        -0.030416,
        -0.001629,
        -0.007607,
        -0.009038,
        -0.011127,
        0.004869,
        -0.014431,
        -0.003256,
        0.011009,
        -0.000182,
        0.030479
      ]
    },
    {
      "name": "Aggregate Bonds",
      "returns": [
        0.003383,
        -0.005414,
        -0.000468,
        0.003312,
        0.001429,
        0.005737,
        -0.005907,
        -0.000994,
        -0.002542,
        0.004991,
        -0.004859,
        0.00201,
        0.001642,
        0.000324,
        -0.003314,
        -0.002803,
        0.00019,
        -0.000551,
        -0.007022,
        -0.000428,
        -0.001826,
        0.005103,
        0.00709,
        -0.002827,
        -0.002037,
        0.00013,
        0.004804,
        0.005379,
        0.002667,
        -0.00091,
        -0.003758,
        -0.007383,
        0.001706,
        0.000864,
        0.005508,
        -0.007142,
        0.004368,
        -0.004738,
        -0.007385,
        0.001689,
        -0.004507,
        -0.000357,
        -0.000415,
        0.005325,
        0.004308,
        -0.000416,
        0.00277,
        -0.007876,
        0.001166,
        -0.006418,
        -0.005774,
        -0.001906,
        0.0091,
        -0.002563,
        -0.002665,
        -0.001689,
        -0.005174,
        -0.003989,
        0.00354,
        0.001622,
        0.001807,
        -0.008514,
        0.007035,
        0.010241,
        -0.001968,
        -0.000503,
        -0.005232,
        -0.000794,
        0.009881,
        -0.001286,
        0.006395,
        -0.002523,
        0.004048,
        0.00066,
        -0.003002,
        0.003417,
        -0.000537,
        -0.00362,
        0.003066,
        -0.005197,
        -0.00165,
        -0.005964,
        -0.001629,
        -0.007396,
        -0.003472,
        -0.001102,
        0.005919,
        -0.000683,
        0.001568,
        -0.000526,
        0.004182,
        -0.002288,
        0.008541,
        -0.002672,
        0.00223,
        -0.000601
      ]
    },
    {
      "name": "Commodities",
      "returns": [
        0.010693,
        -0.014358,
        0.001653,
        0.026449,
        0.036177,
        -0.024715,
        -0.01015,
        0.003149,
        -0.004191,
        0.008498,
        0.006201,
        0.006443,
        0.007429,
        0.001224,
        0.008414,
        0.004634,
        -0.026895,
        0.014692,
        -0.009684,
        0.003576,
        0.01979,
        -0.013675,
        0.006075,
        -0.006749,
        0.017848,
        -0.024232,
        0.006072,
        -0.00843,
        -0.005465,
        -0.010567,
        0.005011,
        -0.00479,
        -0.002642,
        -0.006506,
        0.005338,
        -0.015151,
        -0.010684,
        -0.02011,
        -0.017681,
        -0.01455,
        -0.014944,
        0.003162,
        0.015392,
        -0.015318,
        0.009544,
        -0.000737,
        -0.01655,
        -0.003292,
        0.013558,
        0.007808,
        -0.010701,
        0.006641,
        -0.014237,
        -0.022369,
        0.011828,
        -0.004968,
        0.008261,
        0.019919,
        0.00125,
        -0.009036,
        -0.003743,
        0.00962,
        -0.012011,
        0.025194,
        0.006848,
        0.037353,
        0.011328,
        -0.021955,
        -0.00327,
        -0.007504,
        -0.0303,
        0.008215,
        -0.000348,
        -0.012391,
        0.007949,
        -0.002983,
        -0.013971,
        -0.009568,
        -0.009759,
        -0.009918,
        -0.013714,
        -0.022232,
        -0.013597,
        0.016836,
        -0.003036,
        -0.004977,
        -0.024345,
        -0.024586,
        0.002842,
        0.014054,
        0.005342,
        -0.004593,
        -0.010622,
        -0.018985,
        0.012889,
        0.014289
      ]
    }
  ]
}

Output

{
  "columns": [
    "US Equities",
    "Intl Equities",
    "Aggregate Bonds",
    "Commodities"
  ],
  "n": 96,
  "m": 4,
  "muAnn": [
    0.10824677834315044,
    0.32172564550942684,
    -0.04632810214601113,
    -0.3640822055854188
  ],
  "covAnn": [
    [
      0.06005084492742633,
      0.02126302514959736,
      -0.004521882289713158,
      0.0033754819244447357
    ],
    [
      0.02126302514959736,
      0.03980710739214078,
      -0.002234536684661843,
      0.0027682012518907887
    ],
    [
      -0.004521882289713158,
      -0.002234536684661843,
      0.004720885403435526,
      -0.00020612282429605238
    ],
    [
      0.0033754819244447357,
      0.0027682012518907887,
      -0.00020612282429605238,
      0.04881626811906711
    ]
  ],
  "minVar": {
    "weights": [
      0.08156014102944362,
      0.07570121087946384,
      0.7847332422390177,
      0.05800540585207477
    ],
    "retAnn": -0.024290294458629423,
    "volAnn": 0.05616686728621343,
    "sharpeAnn": -1.1446302342450556
  },
  "tangency": {
    "weights": [
      0.12431145098102418,
      -0.39555685072102514,
      0.8476498302855296,
      0.42359556945447135
    ],
    "retAnn": -0.3072980861787519,
    "volAnn": 0.13054453310651856,
    "sharpeAnn": -2.660380162341781
  },
  "frontier": [
    {
      "weights": [
        0.16706276093260472,
        -0.8668149123215139,
        0.9105664183320411,
        0.7891857330568679
      ],
      "retAnn": -0.5903058778988742,
      "volAnn": 0.24228774123705546,
      "sharpeAnn": -2.6014765529642707
    },
    {
      "weights": [
        0.16421267360249933,
        -0.8353977082148145,
        0.9063719791289403,
        0.7648130554833747
      ],
      "retAnn": -0.5714386917841994,
      "volAnn": 0.23465256888659755,
      "sharpeAnn": -2.605719147612206
    },
    {
      "weights": [
        0.16136258627239397,
        -0.8039805041081155,
        0.9021775399258396,
        0.7404403779098818
      ],
      "retAnn": -0.5525715056695246,
      "volAnn": 0.2270324823062161,
      "sharpeAnn": -2.6100736760226146
    },
    {
      "weights": [
        0.1585124989422886,
        -0.7725633000014163,
        0.8979831007227388,
        0.7160677003363887
      ],
      "retAnn": -0.5337043195548499,
      "volAnn": 0.2194290531467585,
      "sharpeAnn": -2.614532174876337
    },
    {
      "weights": [
        0.15566241161218322,
        -0.7411460958947168,
        0.893788661519638,
        0.6916950227628954
      ],
      "retAnn": -0.5148371334401749,
      "volAnn": 0.21184407500178384,
      "sharpeAnn": -2.619082612697584
    },
    {
      "weights": [
        0.15281232428207786,
        -0.7097288917880177,
        0.8895942223165372,
        0.6673223451894025
      ],
      "retAnn": -0.49596994732550015,
      "volAnn": 0.20427960316085816,
      "sharpeAnn": -2.623707599938186
    },
    {
      "weights": [
        0.14996223695197247,
        -0.6783116876813183,
        0.8853997831134364,
        0.6429496676159093
      ],
      "retAnn": -0.4771027612108253,
      "volAnn": 0.19673800300773547,
      "sharpeAnn": -2.628382688170793
    },
    {
      "weights": [
        0.14711214962186714,
        -0.6468944835746192,
        0.8812053439103356,
        0.6185769900424163
      ],
      "retAnn": -0.45823557509615054,
      "volAnn": 0.18922200927245114,
      "sharpeAnn": -2.6330741176031296
    },
    {
      "weights": [
        0.14426206229176175,
        -0.6154772794679199,
        0.877010904707235,
        0.5942043124689231
      ],
      "retAnn": -0.4393683889814757,
      "volAnn": 0.18173479899142383,
      "sharpeAnn": -2.637735819676986
    },
    {
      "weights": [
        0.14141197496165642,
        -0.5840600753612206,
        0.8728164655041342,
        0.5698316348954301
      ],
      "retAnn": -0.42050120286680087,
      "volAnn": 0.17428008188407723,
      "sharpeAnn": -2.6423054079874957
    },
    {
      "weights": [
        0.13856188763155103,
        -0.5526428712545214,
        0.8686220263010334,
        0.5454589573219368
      ],
      "retAnn": -0.40163401675212596,
      "volAnn": 0.16686221299115592,
      "sharpeAnn": -2.6466987871935603
    },
    {
      "weights": [
        0.13571180030144567,
        -0.5212256671478221,
        0.8644275870979325,
        0.5210862797484438
      ],
      "retAnn": -0.3827668306374512,
      "volAnn": 0.15948633393745343,
      "sharpeAnn": -2.650802863167259
    },
    {
      "weights": [
        0.13286171297134028,
        -0.4898084630411228,
        0.8602331478948319,
        0.4967136021749507
      ],
      "retAnn": -0.36389964452277634,
      "volAnn": 0.1521585512123118,
      "sharpeAnn": -2.6544656301255256
    },
    {
      "weights": [
        0.13001162564123492,
        -0.45839125893442356,
        0.856038708691731,
        0.4723409246014576
      ],
      "retAnn": -0.3450324584081015,
      "volAnn": 0.14488616257934475,
      "sharpeAnn": -2.6574826163764547
    },
    {
      "weights": [
        0.12716153831112953,
        -0.4269740548277243,
        0.8518442694886302,
        0.4479682470279645
      ],
      "retAnn": -0.32616527229342673,
      "volAnn": 0.13767794635534308,
      "sharpeAnn": -2.659578254808973
    },
    {
      "weights": [
        0.12431145098102415,
        -0.39555685072102503,
        0.8476498302855293,
        0.4235955694544713
      ],
      "retAnn": -0.30729808617875176,
      "volAnn": 0.13054453310651853,
      "sharpeAnn": -2.660380162341781
    },
    {
      "weights": [
        0.12146136365091878,
        -0.36413964661432585,
        0.8434553910824287,
        0.39922289188097826
      ],
      "retAnn": -0.288430900064077,
      "volAnn": 0.12349888558643317,
      "sharpeAnn": -2.6593835118796925
    },
    {
      "weights": [
        0.11861127632081342,
        -0.33272244250762645,
        0.8392609518793278,
        0.3748502143074851
      ],
      "retAnn": -0.26956371394940215,
      "volAnn": 0.11655692070358023,
      "sharpeAnn": -2.6559016151144204
    },
    {
      "weights": [
        0.11576118899070806,
        -0.30130523840092727,
        0.8350665126762271,
        0.35047753673399207
      ],
      "retAnn": -0.2506965278347274,
      "volAnn": 0.10973831688352191,
      "sharpeAnn": -2.648997506889754
    },
    {
      "weights": [
        0.11291110166060267,
        -0.269888034294228,
        0.8308720734731262,
        0.3261048591604989
      ],
      "retAnn": -0.23182934172005248,
      "volAnn": 0.10306756049637363,
      "sharpeAnn": -2.637389886894787
    },
    {
      "weights": [
        0.11006101433049731,
        -0.2384708301875288,
        0.8266776342700255,
        0.3017321815870058
      ],
      "retAnn": -0.2129621556053777,
      "volAnn": 0.09657529325162209,
      "sharpeAnn": -2.6193257829028536
    },
    {
      "weights": [
        0.10721092700039195,
        -0.2070536260808295,
        0.8224831950669247,
        0.2773595040135127
      ],
      "retAnn": -0.19409496949070287,
      "volAnn": 0.09030002166288645,
      "sharpeAnn": -2.5924132151888126
    },
    {
      "weights": [
        0.10436083967028655,
        -0.17563642197413015,
        0.8182887558638239,
        0.2529868264400196
      ],
      "retAnn": -0.175227783376028,
      "volAnn": 0.08429022460354767,
      "sharpeAnn": -2.55341333337685
    },
    {
      "weights": [
        0.1015107523401812,
        -0.14421921786743103,
        0.8140943166607231,
        0.22861414886652653
      ],
      "retAnn": -0.15636059726135323,
      "volAnn": 0.07860681535867652,
      "sharpeAnn": -2.498009827333365
    },
    {
      "weights": [
        0.09866066501007582,
        -0.11280201376073173,
        0.8098998774576223,
        0.2042414712930334
      ],
      "retAnn": -0.1374934111466784,
      "volAnn": 0.07332572729722767,
      "sharpeAnn": -2.4206157605120566
    },
    {
      "weights": [
        0.09581057767997045,
        -0.0813848096540324,
        0.8057054382545215,
        0.17986879371954023
      ],
      "retAnn": -0.11862622503200351,
      "volAnn": 0.06854002153646825,
      "sharpeAnn": -2.314359136108571
    },
    {
      "weights": [
        0.09296049034986507,
        -0.04996760554733319,
        0.8015109990514206,
        0.1554961161460472
      ],
      "retAnn": -0.09975903891732874,
      "volAnn": 0.06436030008079097,
      "sharpeAnn": -2.1715100573162394
    },
    {
      "weights": [
        0.0901104030197597,
        -0.0185504014406339,
        0.79731655984832,
        0.13112343857255404
      ],
      "retAnn": -0.08089185280265387,
      "volAnn": 0.06091143822367998,
      "sharpeAnn": -1.9847151262249438
    },
    {
      "weights": [
        0.08726031568965434,
        0.012866802666065422,
        0.7931221206452191,
        0.10675076099906089
      ],
      "retAnn": -0.06202466668797901,
      "volAnn": 0.05832323543994022,
      "sharpeAnn": -1.749297101204912
    },
    {
      "weights": [
        0.08441022835954898,
        0.04428400677276456,
        0.7889276814421184,
        0.08237808342556789
      ],
      "retAnn": -0.04315748057330426,
      "volAnn": 0.05671364636140061,
      "sharpeAnn": -1.4662693356620669
    },
    {
      "weights": [
        0.0815601410294436,
        0.07570121087946387,
        0.7847332422390176,
        0.05800540585207473
      ],
      "retAnn": -0.024290294458629395,
      "volAnn": 0.05616686728621342,
      "sharpeAnn": -1.1446302342450552
    },
    {
      "weights": [
        0.07871005369933824,
        0.10711841498616317,
        0.7805388030359169,
        0.0336327282785816
      ],
      "retAnn": -0.005423108343954559,
      "volAnn": 0.05671364636140062,
      "sharpeAnn": -0.8009202592000784
    },
    {
      "weights": [
        0.07585996636923287,
        0.1385356190928623,
        0.7763443638328161,
        0.00926005070508859
      ],
      "retAnn": 0.013444077770720202,
      "volAnn": 0.058323235439940224,
      "sharpeAnn": -0.455323200590036
    },
    {
      "weights": [
        0.07300987903912748,
        0.16995282319956162,
        0.7721499246297152,
        -0.015112626868404574
      ],
      "retAnn": 0.03231126388539506,
      "volAnn": 0.06091143822367998,
      "sharpeAnn": -0.12622811640681075
    },
    {
      "weights": [
        0.07015979170902212,
        0.2013700273062609,
        0.7679554854266145,
        -0.0394853044418977
      ],
      "retAnn": 0.0511784500000699,
      "volAnn": 0.06436030008079097,
      "sharpeAnn": 0.17368548602224793
    },
    {
      "weights": [
        0.06730970437891674,
        0.23278723141296026,
        0.7637610462235138,
        -0.06385798201539085
      ],
      "retAnn": 0.07004563611474476,
      "volAnn": 0.0685400215364683,
      "sharpeAnn": 0.43836630688477807
    },
    {
      "weights": [
        0.06445961704881138,
        0.2642044355196594,
        0.759566607020413,
        -0.08823065958888386
      ],
      "retAnn": 0.08891282222941954,
      "volAnn": 0.07332572729722768,
      "sharpeAnn": 0.6670622172099321
    },
    {
      "weights": [
        0.061609529718705994,
        0.2956216396263589,
        0.7553721678173122,
        -0.11260333716237715
      ],
      "retAnn": 0.1077800083440945,
      "volAnn": 0.07860681535867656,
      "sharpeAnn": 0.8622663064878
    },
    {
      "weights": [
        0.05875944238860064,
        0.32703884373305797,
        0.7511777286142115,
        -0.13697601473587015
      ],
      "retAnn": 0.12664719445876924,
      "volAnn": 0.08429022460354771,
      "sharpeAnn": 1.0279625527907577
    },
    {
      "weights": [
        0.05590935505849529,
        0.3584560478397571,
        0.7469832894111108,
        -0.1613486923093631
      ],
      "retAnn": 0.14551438057344396,
      "volAnn": 0.09030002166288645,
      "sharpeAnn": 1.1684867692209053
    },
    {
      "weights": [
        0.05305926772838988,
        0.38987325194645644,
        0.7427888502080097,
        -0.1857213698828563
      ],
      "retAnn": 0.16438156668811887,
      "volAnn": 0.09657529325162209,
      "sharpeAnn": 1.2879232617399248
    },
    {
      "weights": [
        0.05020918039828451,
        0.42129045605315574,
        0.7385944110049087,
        -0.21009404745634946
      ],
      "retAnn": 0.18324875280279374,
      "volAnn": 0.10306756049637364,
      "sharpeAnn": 1.3898529480362916
    },
    {
      "weights": [
        0.047359093068179134,
        0.45270766015985503,
        0.734399971801808,
        -0.23446672502984262
      ],
      "retAnn": 0.2021159389174686,
      "volAnn": 0.10973831688352191,
      "sharpeAnn": 1.4772956568081974
    },
    {
      "weights": [
        0.04450900573807379,
        0.48412486426655416,
        0.7302055325987075,
        -0.25883940260333554
      ],
      "retAnn": 0.2209831250321433,
      "volAnn": 0.11655692070358022,
      "sharpeAnn": 1.5527445641122202
    },
    {
      "weights": [
        0.0416589184079684,
        0.5155420683732537,
        0.7260110933956065,
        -0.28321208017682886
      ],
      "retAnn": 0.23985031114681826,
      "volAnn": 0.12349888558643322,
      "sharpeAnn": 1.6182357451877485
    },
    {
      "weights": [
        0.03880883107786305,
        0.5469592724799528,
        0.721816654192506,
        -0.30758475775032185
      ],
      "retAnn": 0.258717497261493,
      "volAnn": 0.1305445331065186,
      "sharpeAnn": 1.6754244092552628
    },
    {
      "weights": [
        0.03595874374775768,
        0.5783764765866519,
        0.717622214989405,
        -0.33195743532381494
      ],
      "retAnn": 0.2775846833761678,
      "volAnn": 0.13767794635534306,
      "sharpeAnn": 1.7256553403474524
    },
    {
      "weights": [
        0.033108656417652274,
        0.6097936806933514,
        0.7134277757863041,
        -0.3563301128973081
      ],
      "retAnn": 0.2964518694908427,
      "volAnn": 0.1448861625793448,
      "sharpeAnn": 1.7700232025290927
    },
    {
      "weights": [
        0.03025856908754694,
        0.6412108848000506,
        0.7092333365832036,
        -0.3807027904708012
      ],
      "retAnn": 0.31531905560551754,
      "volAnn": 0.15215855121231184,
      "sharpeAnn": 1.8094221679421474
    },
    {
      "weights": [
        0.027408481757441552,
        0.6726280889067499,
        0.7050388973801027,
        -0.4050754680442943
      ],
      "retAnn": 0.3341862417201924,
      "volAnn": 0.15948633393745343,
      "sharpeAnn": 1.844585893080751
    },
    {
      "weights": [
        0.024558394427336178,
        0.7040452930134492,
        0.7008444581770019,
        -0.42944814561778744
      ],
      "retAnn": 0.3530534278348672,
      "volAnn": 0.16686221299115597,
      "sharpeAnn": 1.8761193575411808
    },
    {
      "weights": [
        0.021708307097230817,
        0.7354624971201482,
        0.6966500189739011,
        -0.4538208231912804
      ],
      "retAnn": 0.3719206139495419,
      "volAnn": 0.1742800818840772,
      "sharpeAnn": 1.9045240876712446
    },
    {
      "weights": [
        0.018858219767125456,
        0.7668797012268477,
        0.6924555797708004,
        -0.4781935007647736
      ],
      "retAnn": 0.3907878000642169,
      "volAnn": 0.18173479899142386,
      "sharpeAnn": 1.930218109085265
    },
    {
      "weights": [
        0.016008132437020053,
        0.7982969053335469,
        0.6882611405676995,
        -0.5025661783382669
      ],
      "retAnn": 0.40965498617889173,
      "volAnn": 0.1892220092724512,
      "sharpeAnn": 1.953551743796591
    },
    {
      "weights": [
        0.013158045106914706,
        0.8297141094402463,
        0.6840667013645989,
        -0.5269388559117599
      ],
      "retAnn": 0.4285221722935666,
      "volAnn": 0.19673800300773556,
      "sharpeAnn": 1.97482014838938
    },
    {
      "weights": [
        0.010307957776809304,
        0.8611313135469454,
        0.6798722621614978,
        -0.5513115334852531
      ],
      "retAnn": 0.4473893584082414,
      "volAnn": 0.2042796031608582,
      "sharpeAnn": 1.99427330044031
    },
    {
      "weights": [
        0.007457870446703901,
        0.8925485176536451,
        0.6756778229583971,
        -0.5756842110587463
      ],
      "retAnn": 0.4662565445229163,
      "volAnn": 0.21184407500178398,
      "sharpeAnn": 2.0121239856216264
    },
    {
      "weights": [
        0.004607783116598596,
        0.9239657217603436,
        0.6714833837552963,
        -0.600056888632239
      ],
      "retAnn": 0.48512373063759084,
      "volAnn": 0.2194290531467585,
      "sharpeAnn": 2.028554214923779
    },
    {
      "weights": [
        0.0017576957864932352,
        0.9553829258670432,
        0.6672889445521956,
        -0.6244295662057323
      ],
      "retAnn": 0.5039909167522658,
      "volAnn": 0.2270324823062161,
      "sharpeAnn": 2.0437204052874063
    },
    {
      "weights": [
        -0.0010923915436121812,
        0.9868001299737427,
        0.6630945053490948,
        -0.6488022437792256
      ],
      "retAnn": 0.5228581028669408,
      "volAnn": 0.23465256888659766,
      "sharpeAnn": 2.0577575824464778
    },
    {
      "weights": [
        -0.003942478873717514,
        1.0182173340804417,
        0.6589000661459942,
        -0.6731749213527185
      ],
      "retAnn": 0.5417252889816155,
      "volAnn": 0.2422877412370555,
      "sharpeAnn": 2.070782807334545
    }
  ],
  "rfAnnual": 0.04
}

Frequently asked questions

What does the Efficient Frontier Builder methodology page document?
Closed-form Markowitz mean-variance derivation, two-fund theorem, min-var + tangency solutions, shorting assumption, and limitations for the Efficient. It states the formulas, assumptions, data sources, limitations, and reproducibility steps behind the Efficient Frontier Builder, in the Finance category.
When was the Efficient Frontier Builder methodology last reviewed?
This methodology was last reviewed on 2026-04-20. The matching tool is at https://aifinhub.io/efficient-frontier-builder/.
Are the Efficient Frontier Builder numbers reproducible?
Yes. This page embeds a worked example whose output is the verbatim result of running the shipped efficient-frontier-builder engine on a fixed input; the embedded JSON is recomputed and diffed against the engine in CI, so the numbers cannot drift from the code.

Methodology · Calculator · Last updated 2026-04-20

How Efficient Frontier Builder works

How the Efficient Frontier Builder tool actually works — Markowitz derivation, assumptions, limitations.

Scope

Closed-form Markowitz mean-variance optimisation. Given an asset universe's return history, the tool computes the efficient frontier (set of portfolios with the maximum expected return for each level of variance), the minimum-variance portfolio, and the tangency (max-Sharpe) portfolio.

Shorting is implicitly allowed — weights can be negative. Long-only optimisation requires a quadratic programming solver and is on the roadmap; it is not implemented in this release.

Inputs

date,asset_1,asset_2,asset_3,asset_4
2024-01-02,0.0012,0.0008,-0.0003,0.0015
2024-01-03,-0.0005,-0.0002,0.0004,-0.0006
...

Wide-format CSV with a date column (optional) and 2–20 numeric asset-return columns. Minimum 60 observations. Returns are treated as simple daily returns; annualisation uses 252 trading days.

Closed-form solutions

Let μ be the vector of annualised expected returns, Σ the annualised covariance matrix, 1 a vector of ones, and rf the annualised risk-free rate.

Minimum-variance portfolio

The unique portfolio with the lowest variance subject to weights summing to one:

w*_min = Σ⁻¹ · 1 / (1ᵀ · Σ⁻¹ · 1)

Tangency (max-Sharpe) portfolio

The portfolio that maximises the Sharpe ratio over the risk-free rate:

w*_tan = Σ⁻¹ · (μ − rf·1) / (1ᵀ · Σ⁻¹ · (μ − rf·1))

Frontier (two-fund theorem)

For any target return μ_t, the minimum-variance portfolio with that expected return is:

w(μ_t) = λ · Σ⁻¹ · μ + γ · Σ⁻¹ · 1
λ = (C · μ_t − A) / D
γ = (B − A · μ_t) / D
A = μᵀ Σ⁻¹ 1,  B = μᵀ Σ⁻¹ μ,  C = 1ᵀ Σ⁻¹ 1,  D = B · C − A²

The tool sweeps μ_t across a range centred on the minimum-variance return, producing 60 frontier points.

Numerical details

  • Covariance uses the sample estimator (divide by n − 1).
  • Matrix inversion: Gauss-Jordan elimination with partial pivoting. Matrices up to 20×20 — accuracy is not a concern.
  • If the covariance matrix is singular (e.g. two columns are perfectly correlated), the tool raises a diagnostic error rather than returning noise.
  • Annualisation: μ_ann = (1 + μ_daily)^252 − 1, Σ_ann = Σ_daily × 252.

Assumptions + limitations

  1. Shorting allowed. Weights are unconstrained in sign. A long-only frontier is strictly inside this one; real-world retail investors typically want long-only.
  2. Sample moments are true moments. Markowitz takes the sample mean and covariance at face value. Sample-mean estimation error is notoriously large; tiny shifts in μ produce wildly different tangency portfolios. For production, shrink μ toward a factor prior (Black-Litterman, James-Stein) and apply covariance shrinkage.
  3. Gaussian-in-spirit. Mean-variance is the correct objective if returns are normal and investor utility is quadratic. Under fat-tailed returns, minimising variance may not minimise risk; consider CVaR-based optimisation for tail-aware allocation.
  4. Static covariance. The covariance structure is assumed stationary. Crises change correlation structure dramatically; diversification benefits collapse precisely when needed.
  5. No transaction costs. The frontier presents in-sample, cost-free portfolios. Rebalancing frictions materially alter achievable outcomes; model them separately.
  6. No turnover or concentration constraints. Mean-variance optima frequently concentrate in two or three assets. Add weight caps in practice.

Privacy

Parsing, inversion, and frontier construction all run in the browser. Nothing is uploaded.

References

  • Markowitz, H. (1952). "Portfolio Selection." Journal of Finance 7(1), 77–91.
  • Merton, R. C. (1972). "An Analytic Derivation of the Efficient Portfolio Frontier." JFQA 7(4).
  • Black, F., & Litterman, R. (1992). "Global Portfolio Optimization." Financial Analysts Journal 48(5).
  • Ledoit, O., & Wolf, M. (2004). "A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices." JMVA 88(2).
  • Michaud, R. O. (1989). "The Markowitz Optimization Enigma: Is Optimized Optimal?" Financial Analysts Journal 45(1).

Connects to

External resources

Changelog

  • 2026-04-20 — Initial release: closed-form frontier + min-var + tangency, shorting allowed.
Planning estimates only — not financial, tax, or investment advice.