Skip to content

Commit

Permalink
Merging pep8 compliant version with master
Browse files Browse the repository at this point in the history
  • Loading branch information
domokane committed Jul 6, 2021
1 parent ac11cb6 commit dd691af
Show file tree
Hide file tree
Showing 680 changed files with 57,611 additions and 61,197 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_action
name: golden tests

on: [push, pull_request]

Expand All @@ -12,20 +12,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.7.6
- name: run test script
- name: Install dependencies and package
run: |
pip install numpy==1.19.2
pip install llvmlite==0.32.1
pip install scipy==1.5.2
pip install numba==0.49
pip install pandas==1.1.3
pip install matplotlib==3.3.2
pip install ipython==7.18.1
pip install -r requirements.txt
pip install -r requirements-dev.txt
python setup.py install
python tests/runAllTests.py
- name: Run tests
run:
python tests_golden/runAllTests.py
- name: Archive code coverage results
uses: actions/upload-artifact@v2
with:
name: result-differences-file-upload
path: tests/differences/*.testLog

path: tests_golden/differences/*.testLog
29 changes: 29 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: unit test action

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.7.6
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
pip install -e .
- name: show package is importable
run: |
python -c "import financepy as fp"
- name: list dependencies
run: |
pip list
- name: unit tests
run: |
pytest -vv
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# PYTHON AND JUPYTER FILES
build/
env/
.venv/
develop-eggs/
__pycache__/
dist/
Expand Down Expand Up @@ -43,7 +44,6 @@ TestFin*_COMPARE.testLog

# MYPY
.mypy_cache
financepy/__init__.py

# bytecode
*.py[cod]
Expand All @@ -66,6 +66,7 @@ coverage.xml
# virtualenv
venv/
ENV/
.env

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -124,3 +125,6 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

#MacOS Files
.DS_Store
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![unit test action](https://github.com/ru-corporate/FinancePy/actions/workflows/run-unit-tests.yml/badge.svg)](https://github.com/ru-corporate/FinancePy/actions/workflows/run-unit-tests.yml)

# Quick Start Guide

FinancePy can be installed from pip using the following command:
Expand Down Expand Up @@ -61,7 +63,7 @@ Contact me at quant@financepy.com.

The underlying Python library is split into a number of major modules:

* Finutils - These are utility functions used to assist you with modelling a security. These include dates (FinDate), calendars, schedule generation, some finance-related mathematics functions and some helper functions.
* Finutils - These are utility functions used to assist you with modelling a security. These include dates (Date), calendars, schedule generation, some finance-related mathematics functions and some helper functions.
* Market - These are modules that capture the market information used to value a security. These include interest rate and credit curves, volatility surfaces and prices.
* Models - These are the low-level models used to value derivative securities ranging from Black-Scholes to complex stochastic volatility models.
* Products - These are the actual securities and range from Government bonds to Bermudan swaptions.
Expand All @@ -88,9 +90,9 @@ See the changelog for a detailed history of changes.

Contributions are very welcome. There are a number of requirements:

* You can use either camel case or snail case. At some point I will try to make the code Pep8 compliant. But not yet.
* The code should be Pep8 compliant.
* Comments are required for every class and function and they should be a clear description.
* At least one test case must be provided for every function.
* At least one broad test case and a set of unit tests must be provided for every function.
* Avoid very pythonic constructions. For example a loop is as good as a list comprehension. And with numba it can be faster. Readability is the priority.

## License
Expand Down
File renamed without changes.
Binary file added docs/FinancePyManual.dvi
Binary file not shown.
Binary file modified docs/FinancePyManual.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/head.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
keywordstyle=\color{red},
commentstyle=\color{blue},
frame=single,
otherkeywords = {FinDate, FinCalendarTypes, FinBusDayAdjustTypes, FinDateGenRuleTypes, FinDayCountTypes, FinFrequencyTypes,
FinLiborSwaptionTypes, FinOptionExerciseTypes, FinOptionTypes, FinEquityBarrierTypes, FinEquityRainbowOptionTypes, List}
otherkeywords = {Date, CalendarTypes, BusDayAdjustTypes, DateGenRuleTypes, DayCountTypes, FrequencyTypes,
FinLiborSwaptionTypes, FinOptionExerciseTypes, FinOptionTypes, EquityBarrierTypes, EquityRainbowOptionTypes, List}
}

%\makeindex
Expand Down
42 changes: 21 additions & 21 deletions docs/makeUserGuide.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def open_file(filename):


def buildHead():
''' Start latex file with a header that sets all of the document
properties. '''
""" Start latex file with a header that sets all of the document
properties. """

f = open(newHeadFile, 'r')
lines = f.readlines()
Expand All @@ -169,7 +169,7 @@ def buildHead():


def buildTail():
''' Add on end latex to close document. '''
""" Add on end latex to close document. """
f = open(tailFile, 'r')
lines = f.readlines()
f.close()
Expand All @@ -182,7 +182,7 @@ def buildTail():


def buildIntro(introfile):
''' Add on end latex to close document. '''
""" Add on end latex to close document. """
print("Building introduction from file:", introfile)

f = open(introfile, 'r')
Expand All @@ -201,8 +201,8 @@ def buildIntro(introfile):


def buildChapter(folderName):
''' Parse a folder by loading up all of the modules in that folder that
start with the threee letters - Fin. '''
""" Parse a folder by loading up all of the modules in that folder that
start with the threee letters - Fin. """

print("Building chapter in folder:", folderName)

Expand Down Expand Up @@ -282,8 +282,8 @@ def buildChapter(folderName):


def parseModule(moduleName):
''' Parse a module looking for classes, functions and classes for
enumerated types. Functions inside classes are parsed inside the class. '''
""" Parse a module looking for classes, functions and classes for
enumerated types. Functions inside classes are parsed inside the class. """
print(moduleName)
f = open(moduleName, 'r', encoding="utf8")
lines = f.readlines()
Expand Down Expand Up @@ -353,7 +353,7 @@ def parseModule(moduleName):


def parseClass(lines, startLine, endLine):
''' Parse a Python class consisting of data members and functions. '''
""" Parse a Python class consisting of data members and functions. """

n1 = lines[startLine].find("class")

Expand Down Expand Up @@ -388,15 +388,15 @@ def parseClass(lines, startLine, endLine):

for rowNum in range(startLine, commentEndLine):
line = lines[rowNum]
if line.find("'''") > 0:
if line.find(""""") > 0:
startCommentRow = rowNum
startComment = True
startLine = rowNum + 1
break
for rowNum in range(startLine, commentEndLine):
line = lines[rowNum]
if line.find("'''") > 0:
if line.find(""""") > 0:
endCommentRow = rowNum
endComment = True
break
Expand Down Expand Up @@ -501,9 +501,9 @@ def parseClass(lines, startLine, endLine):


def parseFunction(lines, startLine, endLine, className=""):
''' Given a set of lines and a start line I extract the function definiton
""" Given a set of lines and a start line I extract the function definiton
and any comment that goes below.
TODO: Add parsing of function arguments and any comments.'''
TODO: Add parsing of function arguments and any comments."""

functionLine = lines[startLine]
leftCol = functionLine.find("def ")
Expand Down Expand Up @@ -658,7 +658,7 @@ def parseFunction(lines, startLine, endLine, className=""):


def parseEnum(lines, startLine, endLine):
''' Parse a Class that implements an Enumerated type. '''
""" Parse a Class that implements an Enumerated type. """
enumDescription = []

enumLine = lines[startLine]
Expand Down Expand Up @@ -697,9 +697,9 @@ def parseEnum(lines, startLine, endLine):


def extractParams(functionSignature):
''' Parse a function signature into a table containing each function
argument's name, type, description and default value'''
# A good example to look at for testing is `FinBondConvertible`
""" Parse a function signature into a table containing each function
argument's name, type, description and default value"""
# A good example to look at for testing is `BondConvertible`

functionSignature = functionSignature.replace("\\", "\\textbackslash ")
functionSignature = functionSignature.replace("_", "\_")
Expand Down Expand Up @@ -730,7 +730,7 @@ def extractParams(functionSignature):

line = line.strip()
# Split by comma while leaving commas that are in square brackets '[]'.
# This allows us to parse 'Union[FinDate, str]' for maturityDateOrTenor.
# This allows us to parse 'Union[Date, str]' for maturity_date_or_tenor.
if line.find("[") != -1 or line.find("(") != -1:
# https://stackoverflow.com/questions/26808913/split-string-at-commas-except-when-in-bracket-environment
params = []
Expand Down Expand Up @@ -823,8 +823,8 @@ def parseType(pType):
buildIntro("..//README.md")

if 1 == 1:
buildChapter("..//financepy//finutils")
buildChapter("..//financepy//market//curves")
buildChapter("..//financepy//utils")
buildChapter("..//financepy//market//discount")
buildChapter("..//financepy//market//volatility")
buildChapter("..//financepy//products//equity")
buildChapter("..//financepy//products//credit")
Expand Down Expand Up @@ -856,7 +856,7 @@ def parseType(pType):

print("Removing unneeded files.")
os.remove(fileName + ".out")
os.remove(fileName + ".tex")
# os.remove(fileName + ".tex")
os.remove(fileName + ".toc")
os.remove(fileName + ".aux")
os.remove(fileName + ".log")
Expand Down
2 changes: 1 addition & 1 deletion financepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cr = "\n"

s = "####################################################################" + cr
s += "# FINANCEPY BETA Version " + str('0.194') + " - This build: 12 Jun 2021 at 18:20 #" + cr
s += "# FINANCEPY BETA Version " + str('0.200') + " - This build: 18 Jun 2021 at 21:08 #" + cr
s += "# This software is distributed FREE & WITHOUT ANY WARRANTY #" + cr
s += "# For info and disclaimer - https://github.com/domokane/FinancePy #" + cr
s += "# Send any bug reports or comments to quant@financepy.com #" + cr
Expand Down
46 changes: 0 additions & 46 deletions financepy/finutils/FinFrequency.py

This file was deleted.

Loading

0 comments on commit dd691af

Please sign in to comment.