Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperjo committed Sep 24, 2023
2 parents 219d596 + c0ed799 commit 783df1d
Show file tree
Hide file tree
Showing 47 changed files with 949 additions and 177 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.9-bookworm

RUN pipx install poetry && \
poetry config virtualenvs.in-project true
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Python 3",
"name": "cvxmarkowitz",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.9-bookworm",
"build": { "dockerfile": "Dockerfile" },
"onCreateCommand": ".devcontainer/startup.sh",
"customizations": {
"vscode": {
Expand Down
2 changes: 0 additions & 2 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash
pipx install poetry
poetry config virtualenvs.in-project true
poetry install
poetry run pre-commit install
3 changes: 3 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ jobs:
# Uncomment once the package is public
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
files: artifacts/tests/coverage/coverage.info
format: lcov
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: ['3.8', '3.9', '3.10' ]
python-version: ['3.9', '3.10', '3.11' ]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
32 changes: 18 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ repos:
- id: markdownlint-fix
args: [ "--ignore", "book/**/*.md" ]

- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade

- repo: 'https://github.com/pre-commit/mirrors-mypy'
rev: v1.4.1
Expand All @@ -31,24 +35,24 @@ repos:
files: cvx
args: [ --strict, --ignore-missing-imports, --explicit-package-bases ]


# enforcing the use of new python syntax with pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
hooks:
- id: check-dependabot
args: ['--verbose']

args: ["--verbose"]
- id: check-github-workflows
args: ['--verbose']
args: ["--verbose"]

#- repo: https://github.com/python-poetry/poetry
# rev: '1.6.1' # add version here
# hooks:
# - id: poetry-check
# - id: poetry-lock

- repo: https://github.com/python-poetry/poetry
rev: '1.6.1' # add version here
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: poetry-check
- id: poetry-lock
- id: insert-license
files: ^(cvx)
args:
['--license-filepath', 'copyright.txt', '--no-extra-eol']
14 changes: 0 additions & 14 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,3 @@
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

Copyright 2023 Stanford University Convex Optimization Group

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
13 changes: 13 additions & 0 deletions copyright.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2023 Stanford University Convex Optimization Group

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
13 changes: 13 additions & 0 deletions cvx/linalg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Linalg module"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/linalg/cholesky.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Cholesky decomposition with numpy"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/linalg/pca.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""PCA analysis with numpy"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/linalg/random.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np

from cvx.linalg.types import Matrix
Expand Down
13 changes: 13 additions & 0 deletions cvx/linalg/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import numpy.typing as npt
from typing_extensions import TypeAlias
Expand Down
13 changes: 13 additions & 0 deletions cvx/linalg/valid.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Extract valid submatrix of a matrix"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
13 changes: 13 additions & 0 deletions cvx/markowitz/builder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

import pickle
Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/cvxerror.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CvxError(Exception):
pass
13 changes: 13 additions & 0 deletions cvx/markowitz/model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Abstract cp model
"""
from __future__ import annotations
Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
13 changes: 13 additions & 0 deletions cvx/markowitz/models/bounds.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Bounds"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/models/expected_returns.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Model for expected returns"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/models/holding_costs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Model for holding costs"""
from __future__ import annotations

Expand Down
13 changes: 13 additions & 0 deletions cvx/markowitz/models/trading_costs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Model for trading costs"""
from __future__ import annotations

Expand Down
15 changes: 15 additions & 0 deletions cvx/markowitz/names.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# see https://stackoverflow.com/a/54950492/1695486


Expand Down Expand Up @@ -38,3 +51,5 @@ class ConstraintName:

class ParameterName:
SIGMA_MAX = "sigma_max"
OMEGA = "omega"
SIGMA_TARGET = "sigma_target"
Loading

0 comments on commit 783df1d

Please sign in to comment.