Skip to content

Commit

Permalink
Release/0.3.4 (#36)
Browse files Browse the repository at this point in the history
* Update __init__.py

* Update pandas-datareader requirement from ^0.9.0 to ^0.10.0 (#31)

Updates the requirements on [pandas-datareader](https://github.com/pydata/pandas-datareader) to permit the latest version.
- [Release notes](https://github.com/pydata/pandas-datareader/releases)
- [Changelog](https://github.com/pydata/pandas-datareader/blob/main/release-procedure.md)
- [Commits](pydata/pandas-datareader@v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: pandas-datareader
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update publish.yml (#32)

* Create bump.yml (#33)

* Update ci.yml (#34)

* bump version (#37)

Co-authored-by: GitHub Actions <action@github.com>

* fix ci.yml

* Update ci.yml

* format (#38)

Co-authored-by: GitHub Actions <action@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <action@github.com>
  • Loading branch information
4 people authored Jul 14, 2021
1 parent 0132482 commit ae21c52
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 136 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Bump

on:
create:
branches:
workflow_dispatch:

jobs:

bump:

name: Bump

runs-on: ubuntu-latest

if: ${{ contains(github.ref, 'release/') }}

steps:

- uses: actions/checkout@v2

- uses: actions/setup-python@v2

- run: pip install poetry

- name: Bump version
run: git branch --show-current | sed 's|release/||' | xargs poetry version | { printf '::set-output name=PR_TITLE::'; cat; }
id: bump

- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
author: GitHub Actions <action@github.com>
commit-message: bump version
delete-branch: true
branch-suffix: short-commit-hash
title: ${{ steps.bump.outputs.PR_TITLE }}
89 changes: 54 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ on:
workflow_dispatch:

jobs:
Test:

test:

name: Test

runs-on: ubuntu-latest
Expand All @@ -28,61 +30,78 @@ jobs:

steps:

- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install package
run: |
python3 -m pip install --upgrade pip
python3 -m pip install .
python3 -m pip install pytest pytest-cov codecov
- name: Install
run: pip install . && pip install pytest pytest-cov codecov

- name: Run doctest
run: |
python3 -m pytest --doctest-modules ${PROJECT_NAME}
run: python3 -m pytest --doctest-modules ${PROJECT_NAME}
if: always()

- name: Run pytest
run: |
python3 -m pytest --cov=${PROJECT_NAME} tests
run: python3 -m pytest --cov=${PROJECT_NAME} tests
if: always()

- name: Upload codecov report
uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.9' }}

Lint:
lint:

name: Lint

runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.9']

outputs:
status: ${{ job.status }}

steps:

- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: actions/setup-python@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: psf/black@stable
with:
python-version: ${{ matrix.python-version }}
options: '--check --diff --skip-magic-trailing-comma'

- name: Install linter
run: python3 -m pip install black isort
if: always()
- uses: jamescurtin/isort-action@master
with:
configuration: --check-only --diff --force-single-line

- name: Run black
run: python3 -m black --check ${PROJECT_NAME}
if: always()
format:

- name: Run isort
run: python3 -m isort --check --force-single-line-imports ${PROJECT_NAME}
if: always()
name: Format

runs-on: ubuntu-latest

needs: lint

if: ${{ always() && needs.lint.outputs.status == 'failure' }}

steps:

- uses: actions/checkout@v2

- uses: actions/setup-python@v2

- uses: psf/black@stable
with:
options: --skip-magic-trailing-comma

- uses: jamescurtin/isort-action@master
with:
configuration: --force-single-line

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
author: GitHub Actions <action@github.com>
commit-message: format
delete-branch: true
branch-suffix: short-commit-hash
title: Automated Format
22 changes: 7 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ env:
PYPI_USER_NAME: simaki

on:
release:
types:
- created
workflow_dispatch:

jobs:
Expand All @@ -12,25 +15,14 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.9']

steps:

- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-python@v2

- name: Install poetry
run: |
python3 -m pip install --upgrade pip
python3 -m pip install poetry
run: pip install poetry

- name: Publish
run: |
python3 -m poetry publish --build --username ${PYPI_USER_NAME} --password ${{ secrets.PYPI_PASSWORD }}
run: poetry publish --build --username ${PYPI_USER_NAME} --password ${{ secrets.PYPI_PASSWORD }}
2 changes: 0 additions & 2 deletions cointanalysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# flake8: noqa

from .coint import CointAnalysis
46 changes: 23 additions & 23 deletions examples/howto/howto.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pandas_datareader
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters

from cointanalysis import CointAnalysis

from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()


def fetch_etf(ticker):
return pandas_datareader.data.DataReader(
ticker, 'yahoo', '2012-01-01', '2018-12-31'
)['Adj Close']
ticker, "yahoo", "2012-01-01", "2018-12-31"
)["Adj Close"]


def plot_prices(hyg, bkln):
plt.figure(figsize=(16, 4))

plt.title('HYG and BKLN')
plt.title("HYG and BKLN")
hyg_norm = 100 * hyg / hyg[0]
bkln_norm = 100 * bkln / bkln[0]
plt.plot(hyg_norm, label='HYG (2012-01-01 = 100)', linewidth=1)
plt.plot(bkln_norm, label='BKLN (2012-01-01 = 100)', linewidth=1)
plt.plot(hyg_norm, label="HYG (2012-01-01 = 100)", linewidth=1)
plt.plot(bkln_norm, label="BKLN (2012-01-01 = 100)", linewidth=1)

plt.legend()
plt.savefig('hyg-bkln.png', bbox_inches="tight", pad_inches=0.1)
plt.savefig("hyg-bkln.png", bbox_inches="tight", pad_inches=0.1)


def plot_adjust(hyg, bkln, coint):
plt.figure(figsize=(16, 4))

hyg_ = (-coint.coef_[0]) * hyg + coint.mean_

plt.title('HYG and BKLN')
plt.plot(hyg_,
label=f'{-coint.coef_[0]:.2f} * HYG + {coint.mean_:.2f}',
linewidth=1)
plt.plot(bkln, label='BKLN', linewidth=1)
plt.title("HYG and BKLN")
plt.plot(
hyg_, label=f"{-coint.coef_[0]:.2f} * HYG + {coint.mean_:.2f}", linewidth=1
)
plt.plot(bkln, label="BKLN", linewidth=1)

plt.legend()
plt.savefig('hyg-bkln-adjust.png', bbox_inches="tight", pad_inches=0.1)
plt.savefig("hyg-bkln-adjust.png", bbox_inches="tight", pad_inches=0.1)


def plot_spread(spread):
plt.figure(figsize=(16, 4))

plt.title('Spread between HYG and BKLN')
plt.title("Spread between HYG and BKLN")
plt.plot(spread, linewidth=1)

plt.savefig('hyg-bkln-spread.png', bbox_inches="tight", pad_inches=0.1)
plt.savefig("hyg-bkln-spread.png", bbox_inches="tight", pad_inches=0.1)


def main():
hyg = fetch_etf('HYG')
bkln = fetch_etf('BKLN')
hyg = fetch_etf("HYG")
bkln = fetch_etf("BKLN")

X = np.array([hyg, bkln]).T
coint = CointAnalysis()

# pvalue
pvalue = coint.test(X).pvalue_
print(f'pvalue: {pvalue}')
print(f"pvalue: {pvalue}")

# fit, transform
spread = pd.Series(coint.fit_transform(X), index=hyg.index)
print(f'coef: {coint.coef_}')
print(f'mean: {coint.mean_}')
print(f'std: {coint.std_}')
print(f"coef: {coint.coef_}")
print(f"mean: {coint.mean_}")
print(f"std: {coint.std_}")

# plot
plot_prices(hyg, bkln)
plot_adjust(hyg, bkln, coint)
plot_spread(spread)


if __name__ == '__main__':
if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cointanalysis"
version = "0.3.3"
version = "0.3.4"
description = "Python package for cointegration analysis."
authors = ["Shota Imaki <shota.imaki.0801@gmail.com>"]
license = "BSD-3-Clause"
Expand All @@ -16,7 +16,7 @@ pytest = "^6.1.0"
pytest-cov = "^2.10.0"
codecov = "^2.1.0"
pandas = "^1.1.0"
pandas-datareader = "^0.9.0"
pandas-datareader = "^0.10.0"
matplotlib = "^3.3.0"
isort = "^5.6.4"

Expand Down
Loading

0 comments on commit ae21c52

Please sign in to comment.