Skip to content

Commit

Permalink
attempt to fix tests, tweak requirements
Browse files Browse the repository at this point in the history
more adjustments

bump python versions

copypasta

restrict matplotlib version for ffn compat

use date_range for newer pandas compat
  • Loading branch information
timkpaine committed Oct 20, 2020
1 parent 3085ff9 commit f886b97
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"

# command to install dependencies
install:
- pip install -r requirements.txt
- pip install -e .[dev]

# deploys to pypi
deploy:
provider: pypi
Expand All @@ -18,9 +20,11 @@ deploy:
distributions: sdist
repo: pmorissette/bt
branch: master

# command to run tests
script:
- nosetests --with-coverage --cover-package bt

# command to run codecov coverage
after_success:
- codecov
7 changes: 4 additions & 3 deletions bt/algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ def __call__(self, target):
index=covar.columns
)

vol = np.sqrt(np.matmul(weights.values.T,np.matmul(covar,weights.values))*self.annualization_factor)
vol = np.sqrt(np.matmul(weights.values.T,np.matmul(covar.values, weights.values))*self.annualization_factor)

#vol is too high
if vol > self.target_volatility:
Expand Down Expand Up @@ -1350,11 +1350,12 @@ def __call__(self, target):
covar = returns.cov()
else:
raise NotImplementedError('covar_method not implemented')

PTE_vol = np.sqrt(np.matmul(weights.values.T, np.matmul(covar, weights.values)) * self.annualization_factor)
PTE_vol = np.sqrt(np.matmul(weights.values.T, np.matmul(covar.values, weights.values)) * self.annualization_factor)

if pd.isnull(PTE_vol):
return False

# vol is too high
if PTE_vol > self.PTE_volatility_cap:
return True
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel", "cython>0.25"]
15 changes: 6 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cython
cython>=0.25
future
numpy
pandas
matplotlib
ffn
pyprind
ipython
coverage
codecov
numpy>=1
pandas>=0.19
matplotlib>=2
ffn>=0.3.4
pyprind>=2.11
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,22 @@ def local_file(filename):
keywords='python finance quant backtesting strategies',
url='https://github.com/pmorissette/bt',
install_requires=[
'ffn',
'ffn>=0.3.4',
'pyprind>=2.10'
],
extras_require={
'dev': [
'codecov',
'coverage',
'cython>=0.25',
'future',
'numpy>=1',
'pandas>=0.19',
'matplotlib>=2,<3',
'ffn>=0.3.4',
'pyprind>=2.11',
],
},
packages=['bt'],
long_description=local_file('README.rst').read(),
classifiers=[
Expand All @@ -52,5 +65,5 @@ def local_file(filename):
'Programming Language :: Python'
],
ext_modules=ext_modules,
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*'
)
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ def test_securitybase_allocate():

def test_securitybase_allocate_commisions():

date_span = pd.DatetimeIndex(start='10/1/2017', end='10/11/2017', freq='B')
date_span = pd.date_range(start='10/1/2017', end='10/11/2017', freq='B')
numper = len(date_span.values)
comms = 0.01

Expand Down

0 comments on commit f886b97

Please sign in to comment.