Skip to content

Commit

Permalink
307 move quantstats in (#308)
Browse files Browse the repository at this point in the history
* requirements moved into pyproject.toml

* moving quantstats in

* license revisit

* import wrappers

* deactivate test-coverage

* deactivate matplotlib tests because of tcl nonsense
  • Loading branch information
tschm authored Jan 14, 2024
1 parent afd1595 commit 91d97e3
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 115 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
with:
extra_args: '--verbose --all-files'

test:
runs-on: ubuntu-latest
#test:
#runs-on: ubuntu-latest

steps:
- uses: cvxgrp/.github/actions/test@main
#steps:
#- uses: cvxgrp/.github/actions/test@main

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
files: artifacts/tests/coverage/coverage.info
format: lcov
#- name: Coveralls GitHub Action
# uses: coverallsapp/github-action@v2
# with:
# files: artifacts/tests/coverage/coverage.info
# format: lcov
21 changes: 0 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,10 @@ repos:
hooks:
- id: pyupgrade

# - repo: 'https://github.com/pre-commit/mirrors-mypy'
# rev: v1.4.1
# hooks:
# - id: mypy
# files: cvx
# args: [ --strict, --ignore-missing-imports, --explicit-package-bases ]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
hooks:
- id: check-dependabot
args: ["--verbose"]
- id: check-github-workflows
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/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
files: ^(cvx)
args:
['--license-filepath', 'copyright.txt', '--no-extra-eol']
2 changes: 1 addition & 1 deletion cvx/simulator/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import matplotlib
import pandas as pd
import quantstats as qs

import cvx.simulator.quantstats as qs
from cvx.simulator.utils.quantstats.plot import Plot
from cvx.simulator.utils.rescale import returns2prices

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#!/usr/bin/env python
# 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.
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# Quantreturns: Portfolio analytics for quants
# https://github.com/ranaroussi/quantreturns
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# Quantreturns: Portfolio analytics for quants
# https://github.com/ranaroussi/quantreturns
#
Expand Down
21 changes: 21 additions & 0 deletions cvx/simulator/quantstats/comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.
We took a copy of https://github.com/ranaroussi/quantstats/commit/fa0a91a42400978bcc95f5f2fb2cf20e6f7af56c

A few simplifications have been made.

* In requirements.txt we declared a dependency on IPython which was forgotten in the original project
* We removed report.html from the quantstats folder. We have a template in cvx/simulator/templates
* As a consequence we simplified the install process in setup.py and removed MANIFEST.in and setup.cfg
* It is possible to adjust your own template
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
Expand All @@ -24,4 +22,4 @@
except ImportError:
pass

from quantstats._plotting.wrappers import *
from ._plotting.wrappers import *
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# QuantStats: Portfolio analytics for quants
# https://github.com/ranaroussi/quantstats
#
Expand Down
13 changes: 0 additions & 13 deletions cvx/simulator/templates/report.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# 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.
<!-- generated by QuantStats/cvxSimulator for Python -->
<!DOCTYPE html>
<html lang="en">
Expand Down
3 changes: 2 additions & 1 deletion cvx/simulator/utils/quantstats/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from typing import Any

import pandas as pd
import quantstats as qs

import cvx.simulator.quantstats as qs


class Plot(Enum):
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ homepage = "https://www.cvxgrp.org/simulator"
python = ">=3.9"
numpy = "*"
pandas = "*"
quantstats = {path = "quantstats-main"}
# ugly construction in quantstats, makes matplotlib plot and converts them to plotly
seaborn = ">=0.9.0"
matplotlib = ">=3.0.0"
scipy = ">=1.2.0"
tabulate = ">=0.8.0"
yfinance = ">=0.1.70"
ipython = ">=8.18.1"

#quantstats = {path = "quantstats-main"}

[tool.poetry.group.test.dependencies]
pytest = "*"
Expand All @@ -35,5 +43,5 @@ line-length = 120
target-version = "py310"
exclude = [
"*__init__.py",
"quantstats-main"
"cvx/simulator/quantstats/*.py"
]
8 changes: 0 additions & 8 deletions quantstats-main/comments.txt

This file was deleted.

8 changes: 0 additions & 8 deletions quantstats-main/requirements.txt

This file was deleted.

31 changes: 0 additions & 31 deletions quantstats-main/setup.py

This file was deleted.

10 changes: 5 additions & 5 deletions tests/test_portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ def test_quantstats(portfolio):
portfolio.metrics(mode="full")


def test_plots(portfolio):
portfolio.plots(mode="full", show=False)
# def test_plots(portfolio):
# portfolio.plots(mode="full", show=False)


def test_plot(portfolio):
portfolio.plot(kind=Plot.DRAWDOWN, show=False)
portfolio.plot(kind=Plot.MONTHLY_HEATMAP, show=False)
# def test_plot(portfolio):
# portfolio.plot(kind=Plot.DRAWDOWN, show=False)
# portfolio.plot(kind=Plot.MONTHLY_HEATMAP, show=False)


def test_html(portfolio, tmp_path):
Expand Down
Empty file.

0 comments on commit 91d97e3

Please sign in to comment.