8

You seem to have two distinct problems: How to generate random portfolios How optimal portfolios are structured Ad 1) A straightforward way to simulate the weights of random portfolios is to use the Dirichlet distribution $Dir(\alpha_1,\ldots,\alpha_n)$. This is a distribution on the Simplex (i.e. on $S=\{x\in\mathbb{R}^n | \sum x_i =1, x_i\geq 0\}$, ...


6

Let $R$ be a random vector of risky returns and let $r_f$ denote the risk free rate. Let vector of expected returns $\boldsymbol{\mu} = \operatorname{E}[R]$ and covariance matrix $\Sigma = \operatorname{Cov}(R)$. The maximum Sharpe ratio portfolio among risky assets is called the tangency portfolio. Quick method to tangency portfolio Let's find the ...


6

To complement @skoestimeier's answer on the shortselling-allowed case, I provide a vectorised version. Using the original notation in my post (you may change $r$ to something like $r-r_f$, but this doesn't affect the algebraic structure). Our goal is to find the maximiser for the problem $$\max_{w}f(w):=\frac{w^T r}{(w^T\Sigma w)^{1/2}}.$$ Let $$\phi: w\...


5

The Kelly Criterion aims to maximise the expected value of the logarithm of terminal wealth. The derivation starts off by assuming that there is a risky asset that is following a Geometric Brownian Motion: $$ \frac{\,dS}{S} = \mu \,dt + \sigma \,dZ_t $$ This is combined with a riskless asset that is continuously compounding: $$ \frac{dB}{B} = r \,dt $$ ...


4

Having read your comments I'm not sure where the implementation issue is: scipy.integrate.dblquad solves the following iterated integral problem: $$I(\alpha,\beta) = \int_{\alpha}^{\beta} \int_{g(x)}^{h(x)} f(x,y)\; dy \;dx $$ If I re-express your variables to be consistent with the scipy documentation, and suppose I changed your integral to be finite: $$...


4

Your statement about the properties of $\tau$ is correct. $\tau$ is a measure of uncertainty. I think the problem you are having is because in most practical situations nobody really knows what values should be used for $\tau$ and/or $\Omega$. There is plenty of practical advice out there, and some of it is very confusing! For example, Jay Walters has ...


4

There are two cases, where short sales are allowed: With riskless lending and borrowing and without. As mentioned in the comments, you just have to solve a linear system. With riskless lending and borrowing The existence of a riskless lending and borrowing rate $r_f$ implies that there is a single portfolio of risky assets, that is preferred to all other ...


3

Simulation for timeseries data is not a trivial matter and there are a number of methods to ensure you retain some of the relevant properties (mostly called dependent bootstrap methods): Block bootstrap - contiguous blocks of data chosen so that they are large enough to retain significant autocorrelations. Stationary bootstrap - randomised block size ...


3

This is a bit more complex than adding additional constraints. This is a well known problem in markowitz optimization - if you don't treat your covariance matrix and expected return vector with great care, markowitz will often spray your weights against the edges and result in a very non-diversified portfolio. I suggest robustly landscaping the literature - ...


3

As indicated in my comment, the function mvFrontier in the development version of the NMOF package may help you. (Disclosure: I am the package maintainer.) You may get the latest version from GitHub. Some remarks, first on correlation: an efficient frontier shows portfolio risk, typically volatility, compared with portfolio return. Portfolio volatility is ...


3

If you are willing to switch to CVXPY, it comes with a pretty example of exactly this exercise: http://nbviewer.jupyter.org/github/cvxgrp/cvx_short_course/blob/master/applications/portfolio_optimization.ipynb


2

There are two transformations of the input data to be made to go from the first problem to the second: the $\hat{\mu}$ are found by subtracting the scalar $r_f$ from all the $\mu$ vector components: $$\hat{\mu}=\mu-r_f=(\mu_1-r_f,\mu_2-r_f,\cdots,\mu_N-r_f)^T$$ in other words the $\mu$ are returns and the $\hat\mu$ are "excess returns". the $\hat{A}$ ...


2

I'm not sure what you're exactly looking for? Perhaps of use: Gradient descent ($Q = \frac{1}{\alpha} I$) or Newton's method ($Q = \nabla^2 f$) can both be interpreted as minimizing successive quadratic approximations of a function. A method where you repeatedly update your answer is called an iterative method. Constraining the feasible set to some ball ...


2

The minimum value is always attained at $d=0$. In this proof, I will assume that the distribution of the random variable $X$ is absolutely continuous and monotonically increasing, and thus the CDF of $X$ is invertible (though I believe the result holds generally). Fix $\beta\in(0,1)$. We have that $$ \Psi(d,\alpha)\equiv\int_{\min\{d,x\}\leqslant\alpha}p(...


2

At the terminal time $T$, the terminal condition is $g(T, q) = -\alpha q^2$, this implies, $$ \begin{aligned} g(T, q) &= \frac{1}{\kappa} \log{\omega(T, q)} = -\alpha q^2\\ \Rightarrow \omega(T,q) &= e^{-\kappa\alpha q^2} \end{aligned} $$ Therefore, $\mathbf{z}$ is given by, $$ \mathbf{z} = \boldsymbol{\omega(T)} = \begin{bmatrix} e^{-\alpha\kappa \...


2

Assuming the $\epsilon_i$ are zero mean, you should find that $$ \mu - r_f = \beta \left(E[r_m] - r_f\right). $$ Further assuming the $\epsilon_i$ are independent of each other, though possibly with different variances, let $\Gamma$ be the diagonal matrix with the variances of $\epsilon_i$ on the diagonal. Then you are to find (under the more usual MVO ...


1

Do you have correctly formulated the problem for the solver ? If you want to maximise a function (the sharpe ratio) $f$, it is equivalent to minimise $-f$. This kind of confusion (minimising instead of maximising) would basically lead to a similar outcome as yours.


1

For those experiencing a similar problem, here is the solution that worked for me: ## OPTIMIZE PORTFOLIO WEIGHTS UNDER THE OBJECTIVE OF MAXIMIZING THE SHARPE RATIO ## WHILE CONSTRAINING THE WEIGHTS TO SECTOR BOUNDS ## PAPER: # ACCORDING TO: http://people.stat.sc.edu/sshen/events/backtesting/reference/maximizing%20the%20sharpe%20ratio.pdf np.random.seed(101)...


1

This is very simply done. It involves ensuring the constraints are presented as part of the matrix standard form. You will typically have the constraint that all assets sum to one, i.e. the matrix-vector equation: $$ \delta^T x = 1 $$ If you want to create an inequality constraint for assets in a sector just isolate them: $$ \begin{bmatrix} 1 & 1 &...


1

The problem is how to generate random weights subject to a constraint that the sum of the weights has to be equal to 1. The following pseudo-code illustrate one method: Let free_weight := 1 For i=1 to N Select an asset j **at random** among the assets not yet given a weight If i < N then Let w(j) := free_weight * rand1() /* rand1() ...


1

I get the maximization problem $$ \max\limits_{w} \mathbb{E}\left[W_1\right] - \frac{\gamma}{2} Var(W_1) $$ $$ st. W_1 = W_0(1 + r_f + w^Tr)$$ So we have \begin{align*} L(w) &= \mathbb{E}\left[W_1\right] - \frac{\gamma}{2} Var(W_1)\\ & = \mathbb{E}\left[W_0(1 + r_f + w^Tr)\right] - \frac{\gamma}{2} Var(W_0(1 + r_f + w^Tr))\\ & = W_0 + ...


1

Please let me know if you have any questions.


1

To optimize: $$z = f(g(x))$$ using traditional calculus with chain rule: $$ \frac{dz}{dx} = \frac{df}{dg} \frac{dg}{dx} $$ Set $\frac{dz}{dx} = 0$ and that will determine either minimum, maximum or saddle points.


1

Try Quantopian. I believe they offer all that you are looking for. ps.: I have no affiliation with the company or anyone working there.


1

Looking at this a second time, your implementation is probably not very inefficient since for; $$ \quad \hat{f}(u) := \sum_{j}a_j \phi(u - z_j), \quad \int_{-\infty}^y \hat{f}(u) du = \sum_j a_j \Phi(y)\;, $$ where $\Phi(y)$ is the transformed cumulative normal distribution function of $y$. This function already exists as scipy.stats.norm.cdf and is ...


1

The simplest is to get the admissible return range using the cvxopt optimizer with $q = \alpha \mu$ and $q = -\alpha \mu$ for a large $\alpha$ instead of $q=0$ and then run the function compute_ep iteratively to find the portfolio with the highest Sharpe ratio in this range. Using code similar to the one posted above, one can get the bounds and optimal ...


1

Consider the Lagrangian: $$L = \sum_{t=0}^{\infty} \beta ^t \{ U(c_t) + \lambda _t [(1-\delta)k_t+f(k_t) - k_{t+1}-c_t]\}$$ The FOC of the Lagrangian with respect to $c_t$ gives: $$\frac{\partial L}{\partial c_t} = 0 \Rightarrow U'(c_t) = \lambda_t$$ The FOC with respect to $k_{t+1}$ gives: $$\frac{\partial L}{\partial k_{t+1}} = 0 \Rightarrow \lambda_t ...


Only top voted, non community-wiki answers of a minimum length are eligible