We formulate a new, computationally inexpensive framework based on Mean–Variance Portfolio Theory to determine the optimal allocation of wind and solar capacity, which can leverage the complementarity between intermittent solar and wind generation to meet electricity demand at the lowest cost, with gas acting as reserve generation in times of insufficient wind and solar output, and the variance of the mismatch between demand and the output of wind and solar is taken as the risk indicator. We then apply this framework to the context of the National Electricity Market in Australia. Our result reveals that, assuming sufficient network capacity, the estimated lowest generation cost achievable is $45.26/MWh, where the expected percentage of unserved energy (USE) is 0.0044%. For a risk-averse planner, a level of USE less than 0.0001% may be achieved at the expense of almost doubling the cost to $88.23/MWh. Under the current network capacity constraints, we estimate these costs to increase to $53.09/MWh and $89.90/MWh respectively, while the USE could rise to 0.017%. Moreover, network expansions in Queensland are found to be the most beneficial. On the other hand, a 4-hour battery storage system with power capacity equivalent to 20% of the peak load could help reduce the cost by up to 6.8% alongside further decrease in the USE. Our results are also shown to differ drastically from the conventional, output-based approach. Since the two approaches address two different questions depending on whether demand is flexible, demand flexibility is also an important factor.