Skip to content

Commit 9f771bc

Browse files
fmilthalerPietropaoloFrisonigithub-actions[bot]
authored
Chore/auto formatting workflow (fmilthaler#109)
This PR adds a new GitHub workflow. Purpose of that is, for every commit to either of the branches master or develop as well as any commit pushed to a branch that is in a PR with a base branch of either master or develop the new workflow should run and automatically apply code formatting with black, import sorting with isort as well as update the README.tex.md (porting changes over from README.md). --------- Co-authored-by: Pietropaolo Frisoni <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent fa1a433 commit 9f771bc

18 files changed

+145
-60
lines changed

.github/workflows/auto-format.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: AutoUpdateFormatting
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
branches:
9+
- master
10+
- develop
11+
12+
jobs:
13+
code-formatting:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.head_ref }}
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10' # Specify the desired Python version
26+
27+
- name: Install dependencies
28+
run: |
29+
pip install -r requirements_test.txt
30+
31+
- name: Updating README files
32+
id: update_readme
33+
run: |
34+
bash scripts/update-readme.sh
35+
bash scripts/auto-commit.sh "Updating README files"
36+
continue-on-error: true
37+
38+
- name: Code formatting and committing changes
39+
id: code_format
40+
run: |
41+
bash scripts/auto-format.sh
42+
bash scripts/auto-commit.sh "Automated formatting changes"
43+
continue-on-error: true
44+
45+
- name: Push changes
46+
if: ${{ steps.update_readme.outcome == 'success' || steps.code_format.outcome == 'success' }}
47+
uses: ad-m/github-push-action@master
48+
with:
49+
branch: ${{ github.head_ref }}

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,3 @@ Furthermore, it is also shown how the entire *Efficient Frontier* and the optima
268268
Also, the optimisation of a portfolio and its visualisation based on a *Monte Carlo* is shown.
269269

270270
Finally, *FinQuant*'s visualisation methods allow for overlays, if this is desired. Thus, with only the following few lines of code, one can create an overlay of the *Monte Carlo* run, the *Efficient Frontier*, its optimised portfolios for *Minimum Volatility* and *Maximum Sharpe Ratio*, as well as the portfolio's individual stocks.
271-

example/Example-Analysis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
# <codecell>
1111

12+
import datetime
1213
import pathlib
14+
1315
import matplotlib.pyplot as plt
1416
import pandas as pd
15-
import datetime
1617

1718
# importing FinQuant's function to automatically build the portfolio
1819
from finquant.portfolio import build_portfolio

example/Example-Build-Portfolio-from-file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
# <codecell>
1111

12+
import datetime
1213
import pathlib
14+
1315
import pandas as pd
14-
import datetime
1516

1617
# importing FinQuant's function to automatically build the portfolio
1718
from finquant.portfolio import build_portfolio

example/Example-Build-Portfolio-from-web.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
# <codecell>
1111

12-
import pandas as pd
1312
import datetime
1413

14+
import pandas as pd
15+
1516
# importing some custom functions/objects
1617
from finquant.portfolio import build_portfolio
1718

example/Example-Optimisation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
# <codecell>
2828

29+
import datetime
2930
import pathlib
31+
3032
import matplotlib.pyplot as plt
3133
import numpy as np
3234
import pandas as pd
33-
import datetime
3435

3536
# importing FinQuant's function to automatically build the portfolio
3637
from finquant.portfolio import build_portfolio

finquant/asset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class Asset:
4545
4646
"""
4747

48-
def __init__(self, data: pd.Series, name: str, asset_type: str = 'Market index') -> None:
48+
def __init__(
49+
self, data: pd.Series, name: str, asset_type: str = "Market index"
50+
) -> None:
4951
"""
5052
:Input:
5153
:data: ``pandas.Series``, of asset prices
@@ -119,4 +121,4 @@ def properties(self):
119121
def __str__(self):
120122
# print short description
121123
string = f"Contains information about {self.asset_type}: {self.name}."
122-
return string
124+
return string

finquant/market.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import numpy as np
1616
import pandas as pd
17+
1718
from finquant.asset import Asset
1819
from finquant.returns import daily_returns, historical_mean_return
1920

@@ -43,4 +44,4 @@ def comp_daily_returns(self) -> pd.Series:
4344
"""Computes the daily returns (percentage change) of the market index.
4445
See ``finquant.returns.daily_returns``.
4546
"""
46-
return daily_returns(self.data)
47+
return daily_returns(self.data)

finquant/portfolio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
- Individual stocks of the portfolio (Expected Return over Volatility)
5050
"""
5151

52-
from typing import List
5352
import datetime
53+
from typing import List
5454

5555
import matplotlib.pylab as plt
5656
import numpy as np

finquant/stock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import numpy as np
2727
import pandas as pd
28+
2829
from finquant.asset import Asset
2930
from finquant.returns import daily_returns, historical_mean_return
3031

0 commit comments

Comments
 (0)