Giter VIP home page Giter VIP logo

pycla's People

Contributors

phschiele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pycla's Issues

Code for init_algo using a lp

I have used this fragment.

def init_algo_lp(
    mean: MATRIX,
    lower_bounds: MATRIX,
    upper_bounds: MATRIX,
    A_eq: MATRIX | None = None,
    b_eq: MATRIX | None = None,
    A_ub: MATRIX | None = None,
    b_ub: MATRIX | None = None,
) -> Next:
    if A_eq is None:
        A_eq = np.atleast_2d(np.ones_like(mean))

    if b_eq is None:
        b_eq = np.array([1.0])

    if A_ub is None:
        A_ub = np.atleast_2d(np.zeros_like(mean))

    if b_ub is None:
        b_ub = np.array([0.0])

    w = cp.Variable(mean.shape[0], "weights")

    objective = cp.Maximize(mean.T @ w)
    constraints = [
        A_eq @ w == b_eq,
        A_ub @ w <= b_ub,
        lower_bounds <= w,
        w <= upper_bounds,
    ]

    cp.Problem(objective, constraints).solve()

    w = w.value

    # compute the distance from the closest bound
    distance = np.min(
        np.array([np.abs(w - lower_bounds), np.abs(upper_bounds - w)]), axis=0
    )

    # which element has the largest distance to any bound?
    # Even if all assets are at their bounds,
    # we get a (somewhat random) free asset.
    index = np.argmax(distance)

    free = np.full_like(mean, False, dtype=np.bool_)
    free[index] = True

    return Next(free=free, weights=w, mean=mean.T @ w)

Weights given volatility target

Hi,

Thank you for developing this package.
I was playing a bit with it and I am wondering how to increase the number of points computed to draw the efficient frontier?
With my input, only 9 points are computed, which is too low to achieve my goal of finding the optimal weights for a given volatility target (let say 10%).
Is there a way to achieve what I am looking for?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.