title: Calculating Value At Risk or "most probable loss", for a given distribution of returns
body: <p>Given historical daily returns, how can I calculate the portfolio allocation for a single stock position, based on not losing more than 10% of the starting portfolio value over 21 days? (with 95% confidence.)</p>
  
  <p>Based on some starting code of e.g.</p>
  
  <pre><code>import numpy as np
  from scipy.stats import norm
  
  returns = [-0.01, -0.02, -0.01, 0.04, 0.02, 0.01, -0.03]
  mu = np.mean(returns)
  std = np.std(returns)
  valueAtRisk = norm.ppf(0.05, mu, sigma)
  </code></pre>
  
  <p>However, the above only tells me my risk for 1 day. My question goes in the other direction; what can I allocate given the distribution of returns, assuming that I don't want to lose more than 10% over 21 days.</p>
  
  <p>I would prefer an answer that can be computed directly, but a Monte Carlo answer would be acceptable.</p>
  
  <p>Thanking you kindly for your help.</p>