问题

I'm using CVXOPT to do quadratic programming to compute the optimal weights of a potfolio using mean-variance optimization. There is a great example at http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#quadratic-programming. However, the arguments are in a regularized form (according to the author). The example is a basic version. I am looking to do a bit of a more complex problem where:

min:

x'Sx

s.t.:

x'a >= g

x'1 = 0

x >= -Wb

x <= c1 - Wb

where:

x: active weights of assets (active weight = portfolio weight - benchmark weight)

S: covariance matrix of asset returns

a: expected stock excess returns

g: target gain

Wb: weights of assets in the benchmark

c: upper limit (weight) of any asset in the portfolio

Assume all the variables are computed or known.

The basic example presented in the documentation:

min:

x'Sx

s.t.

p'x >= g

1'x = 1

Where p are the asset returns.

What I do not know (referring to the code at http://abel.ee.ucla.edu/cvxopt/examples/book/portfolio.html and optimization problem above):

1.I think these arguments setup the constraints but I'm not entirely sure:

G = matrix(0.0, (n,n))

G[::n+1] = -1.0

h = matrix(0.0, (n,1))

A = matrix(1.0, (1,n))

b = matrix(1.0)

2.I believe this is part of the minimization problem in "regulated form", which I'm not sure what means:

mus = [ 10**(5.0*t/N-1.0) for t in xrange(N) ]

3.What the arguments to qp are (solver.qp is the quadratic optimizer):

xs = [ qp(mu*S, -pbar, G, h, A, b)['x'] for mu in mus ]

Looking at the documentation, I'm pretty sure that mu*S (the first argument) is the objective function to be minimzed and -pbar are the returns. This looks like a maximization problem however (maximizing negative returns).

I do not know, however how the other arguments are used.

I am looking for help using the optimizer given my minimization problem and constraints above.

回答1:

I read the docs and I think you have to use the function with the following parameters. I assume that x has size n:

P = S

q = (0,....0)

A = (1, ...... 1)

b = (0)

G is vertically stacked from

-a

+I_n

-I_n

where I_n is the identity matrix of size n x n . And the corresponding right hand side h is

-g

Wb

...

Wb

C1-Wb

...

C1-Wb

That is: one -g, n times Wb and n times C1-Wb.

HTH.

来源:https://stackoverflow.com/questions/7572698/python-using-cvxopt-for-quadratic-programming

python中quadratic,Python: Using CVXOPT for quadratic programming相关推荐

  1. 在python中安装python库

    1.安装numpy库 win+R -> cmd ->where python(有种情况是输入where python之后,出现"  'where不是内部或外部命令,也不是可运行的 ...

  2. python中年月日,python日期和时间

    今天是第17天,在Python中通常用时间戳,时间字符串和元组三种方式表示,今天学习的是time和datetime常用时间和日期函数的用法 一.日期和时间的处理 1,时间戳 指1970年1月1日0时0 ...

  3. python中变量,Python中的变量、数据类型、运算符

    Python第四课 Python中的变量.数据类型.运算符 Hello,小伙伴们,今天我们来聊一聊Python里面的变量.数据类型.运算符. 一. 变量:什么是变量呢? 我们来看这样一个例子:李四在银 ...

  4. python中fig_matplotlib python:fig.figimage和fig.savefig的图形大小

    我正在尝试将png图像添加到在 python中使用matplotlib创建的绘图中. 这是我的情节代码 import matplotlib as mpl mpl.use('Agg') import m ...

  5. python中变量,python中变量的概念

    python中变量的概念 在python中,变量就是一种标识符, 它是数据的名字,更专业的理解,变量是内存中数据的引用, 编程语言里的变量和初中学习代数时的方程变量很相似. 前面学习数字类型,bool ...

  6. python中获取python版本号的方法

    #!/usr/bin/python  # 第1种方法 import platform  print(platform.python_version()) 1 2 3 >>> impo ...

  7. Python中使用python -m pip install --upgrade pip升级pip时老是不成功

    场景 在使用python -m pip install --upgrade pip进行pip升级时,每次到最后就是报一大堆红色,最终升级不成功. 实现 使用默认的镜像源时间过长就会没响应,使用豆瓣的镜 ...

  8. callable python中意义,Python之callable

    callable(object) return True if the object argument appears callable, False if not. 可以检查一个对象是否是可调用的( ...

  9. python中mxnet_mxnet Python 笔记

    1.查看mxnet的版本 import mxnet as mx mx.__version__ 2.扩展nd的维度 image_data = mx.random.normal(shape = (3, 1 ...

  10. 如何注释python中html,Python在HTML中提取带注释的代码,python,html,被

    假设被注释代码段如下: html=""" """ 如果直接对此代码段使用pyquery转换并提取 from pyquery import P ...

最新文章

  1. Rushcrm:客户关系管理适合的才是好的
  2. java opencv 开发环境_Java + opencv学习:在Eclipse下配置基于Java的OpenCV开发环境
  3. Linux - Sysstat [ All-in-One System Performance and Usage Activity Monitoring Tool For Linux]
  4. 【转载】MySQL Show命令总结
  5. AcWing 320. 能量项链
  6. 使用Bootstrap制作右键单击自定义菜单
  7. D/E盘根目录出现Msdia80.dll操作;dllregisterserver调用失败错误代码0x80004005 解决
  8. 树莓派的浏览器无法上网
  9. 炸!微信Windows版可以刷朋友圈了
  10. EKL日志平台架构概括
  11. spring boot 作业管理系统
  12. 莘城苑:面包种类选择
  13. 干接点信号_百度百科
  14. 如何让销售管理更高效?
  15. 知识竞赛答题小程序的管理后台搭建教程
  16. 即时聊天APP(一)
  17. android开发——分秒计时器(可 开始/暂停/继续/停止)
  18. carton num_Carton先生–世界上第一个卡通系列MadeWithUnity
  19. Hotspot源码解析一
  20. 锐起无盘xp 1.5 试装手记(转)

热门文章

  1. Python数据分析(1):Matplotlib
  2. 人们有时对机率存在的错误的认识
  3. do还是doing imagine加to_to-do和doing用法及区别
  4. 基于CNN的人脸 性别、年龄识别
  5. Python画四张子图-导入数据
  6. Android 实现搜索历史(1)
  7. 编写程序求解百鸡百钱问题。公鸡5元一只,母鸡3元一只,小鸡一元3只,问100元钱买100只鸡,可买公鸡、母鸡、小鸡各多少只?
  8. android inflate,android inflate详解
  9. 学霸题 - 数正方形
  10. 【Python】 Python小游戏-贪吃蛇大冒险